Hello,
I added the unity-web3-game-kit to my unity project, the webgl build is success, it can connect to the wallet.
Then I go back to unity editor and test the GetNFTs function, get an error:
Following is the unity function:
public async void CheckNFT()
{
string userAddress = "0xb57c648b5e6992b4c58accc236c9a0979c2c08d3";
ChainList chainId = ChainList.eth;
NftOwnerCollection nftCollection = await Moralis.Web3Api.Account.GetNFTs(userAddress, chainId);
if (nftCollection.Total < 1)
{
Debug.Log($"User {userAddress} does not have any NFTs on chain {chainId.ToString()}");
}
else
{
Debug.Log($"Nfts for User {userAddress}");
foreach (NftOwner nft in nftCollection.Result)
{
Debug.Log($"TokenId: {nft.TokenId}, Name: {nft.Name}, Balance: {nft.Amount}");
}
}
}
The error message:
NullReferenceException: Object reference not set to an instance of an object
MoralisUnity.Web3Api.Client.ApiClient+<CallApi>d__12.MoveNext () (at Library/PackageCache/[email protected]/Runtime/Web3Api/Client/ApiClient.cs:97)
The error is from this code:
await Moralis.Web3Api.Account.GetNFTs(userAddress, chainId);
Is there something I missed?
Thanks a lot