Before you start
SDK walk-through
Components interaction
AnkrSDK enables interacting with the blockchain for the latest Unreal Engine 5+.
The interaction components are the following:
- Frontend: Unreal Engine 5+
- Backend:
- Unreal Engine uses Ankr API to interact with the blockchain.
- Ankr handles the Unreal Engine to blockchain communication.
SDK's functionality
Currently, the SDK supports the following functionality for Unreal Engine:
- Connecting a wallet (MetaMask) and authenticating a user.
- Updating NFTs.
- Minting NFTs.
Prerequisites
- Having smart contracts deployed on the blockchain.
- Having smart contract addresses and ABI for those smart contracts deployed.
SDK Installation
- Download the
AnkrSDK.zip
package from the latest release. - Unzip the
AnkrSDK.zip
package to your Unreal Project's Plugins folder. - Delete the Binaries, Intermediate, and Saved folders.
- Right-click
.uproject
and then select Generate Visual Studio project (or Services > Generate Xcode project) to generate either of those. - Open the generated Visual Studio (or Xcode) project and check if the plugin is included inside the Game project.
- Locate your
GameInstance.h
if already created. If not, add the C++ class from Content Browser in Unreal Engine, check Show All Classes and select GameInstance. Name your class MyGameInstance. - Open
MyGameInstance.h
and include the following code:#include "AnkrClient.h" UPROPERTY() UAnkrClient* ankrClient; UFUNCTION(BlueprintCallable, Category = "ANKR SDK") UAnkrClient* GetAnkrClient();
- Open
MyGameInstance.cpp
and include the following code:UAnkrClient* UMyGameInstance::GetAnkrClient() { if (ankrClient == nullptr) { ankrClient = NewObject<UAnkrClient>(); } return ankrClient; }
- Add AnkrSDK to your Unreal Project/Source/Unreal
Project/Build.cs
as follows:PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AnkrSDK" });
- Click Edit > Project Settings > Maps and Modes, and select your newly created or already created GameInstance from the GameInstance Class dropdown.
- Now you can call all the functions in the blueprint by getting GetGameInstance > GetAnkrClient.