-
Get your API keys: Your API requests are authenticated using API keys. You can get your free API key by signing up for an NFTPort account.
-
Download Unity 2020.3.18f here
SDK is made using Unity 2020.3.18f , however is compatible with other versions as well. We'll be working towards Unity Asset Store release to make process easier.
-
Download the NFTPort extension:
- Option 1: clone this Github repository and open the Unity project.
- Option 2: download the Unity package and import in your project
- Option 3: copy the NFT_UnitySDK Folder in your project Assets directory.
- Setup your NFTPort API Key in Window / NFTPort
*The best way to learn is by doing! We've provided a basic demo scene for play in demo.cs
.
Add NFTPort_Interface.cs in your scene.
NFTPort_Interface
provides a globally accessible class which routes into individual components. You can only have one of this in your scene, other instances will get deleted at runtime. AddingNFTPort_Interface.cs
will automatically add other required components.
In your script, include NFTPort:
using NFTPort;
Getting All Addresses Of an NFT:
NFTPort_Interface.Instance.NFTsOfAccount(addressString);
Getting All NFT's of a Contract:
NFTPort_Interface.Instance.NFTsFromContract(ContractString);
Easy Mint NFT via URL:
NFTPort_Interface.Instance.Mint(FileUrlString, AddressString, NFTMintNameString);
Retrieve NFTDetails:
NFTPort_Interface.Instance.NFTDetails(ContractString, TokenIdString);
If you do not need to change chain ID at runtime, you can get most done by above and set the chain ID and include parameters in the inspector on individual components.
When you call general functions above using NFTPort_Interface.cs, the data gets sorted according to each NFT and populated in model of the following individual components below it, as seen in Unity Inpector Window. Any further actions utilising this data can be refrenced from these scripts. You can also link events from these individual components (view editor window of components(on object NFTPort) in demo scene and demo.cs)
NFTsOwnedbyanAccount._ownedbyAddressModel.nfts[i].name;
These can be setup directly through inspector. For Runtime or setting up through script following can be used by refrencing the component, in this example as : _NFTsOwnedbyanAccount .
_NFTsOwnedbyanAccount.Address = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B";
_NFTsOwnedbyanAccount.chain = "ethereum";
_NFTsOwnedbyanAccount.include = "all";
_NFTsOwnedbyanAccount.Run();
Any events after a successful fetch can be done via:
we will be iterating this extension and this is meant to provide a starter pack and tools in your journey with NFTPort and Unity3D. NFT's and GameEngines opens up a huge metaverse of creativity where possibilities are endless! What will you build?
NFTPort has a number of api endpoints available at: https://docs.nftport.xyz/docs/nftport
Get support, showcase your work, share your thoughts and feedback, and engage in a vibrant community at: https://discord.gg/w92sXkNmBR