Errors when calling Nft.TryGetNftData() method #97
-
I log in with the wallet, the tokens get correctly with GetTokenAccounts(), but when i try to: Solana.Unity.SDK.Nft.Nft.TryGetNftData() it fails. Unity version: 2021.3.11f1
The errors are:
My gues is the error is from Packages/Solana Sdk/Runtime/codebase/nft/CandyMachineV2.cs in this line of code:
But i do not know. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You are mixing the use of Otherwise, your code could be: async void GetNftFromWallet()
{
var options = new SolanaWalletAdapterWebGLOptions();
WalletBase wallet = new SolanaWalletAdapterWebGL(options, RpcCluster.MainNet, "https://api.metaplex.solana.com/", null, true);
await wallet.Login();
// Get Tokens of wallet
var tokens = await wallet.GetTokenAccounts(Commitment.Confirmed);
// Sort tokens in descending
var tokenAccounts = tokens.OrderByDescending(tk => tk.Account.Data.Parsed.Info.TokenAmount.AmountUlong);
foreach (var item in tokenAccounts)
{
Nft.TryGetNftData(item.Account.Data.Parsed.Info.Mint, wallet.ActiveRpcClient).AsUniTask().ContinueWith(nftData =>
{
Debug.Log(nftData);
}).Forget();
}
} |
Beta Was this translation helpful? Give feedback.
You are mixing the use of
WalletBase
andWeb3
.Web3
is a wrapper that internally have an instance ofWalletBase
, so either you define your own managing logic, or you attach Web3.cs to a gameObject and use the login function on it (e.g.:LoginWalletAdapter
). I suggest the second option.Otherwise, your code could be: