Issue with getting the Nonce from GetTransaction ( C# )

Hi ,

I am using Moralis SDK in Unity using C# , and I am facing an issue …wish anyone can help me toward the direction of fixing it .

The error occurred exactly at getting the Nonce .
There is a Moralis function , which is ( Moralis.Web3Api.Account.GetTransaction ) .

I call it like that :

TransactionCollection transactions = await Moralis.Web3Api.Account.GetTransactions(ethAddress.ToLower(), LeaderBoardContractData.requiredChain);

Where ethAddress value is : 0xf598…319ac1
And the value of LeaderBoardContractData.requiredChain is 0x61 ( it comes from an enum I created )

The output of Moralis.Web3Api.Account.GetTransaction at this case gives the output as per screenshot ( in the green border box ) ,where result is an empty array .

The nonce should be extracted from the result , as follows : int currentNonce = int.Parse(transCollection.result[0].nonce);

So since result is an empty array , an error is thrown …I want to know why it returns an empty array .

what is the exact endpoint that you are trying to use?

you can also test it in docs page directly to see if you get the expected result

My endpoint is the bsc testnet ( if I understood your question correctly ) .

I tested in the docs page , and it gives me :

{
“message”: “No transaction found”
}

I will check with the backend dev. and returns back to you

What is the endpoint you are using and which address/chain (parameters)? You mentioned getTransactions and getTransaction, both are different.

Oh , it’s " Moralis.Web3Api.Account.GetTransactions " …so it’s ( transactions )

eth address :
0xf598e416211c5cc653d91943631c94b6dc3a9ac1

chain
0x61

I tested GetTransactions from this link :

And it gives the same result that it gives in the Unity C# project …result array is empty .

For the EndPoint , Do you mean an NFT endpoint ( getNFTTransfersByBlock , search NFTs. …etc ) ?
Because I am a bit confused about this point , so kindly explain …so I can answer clearly about that .

Endpoint is any API method/name e.g. getTransaction or getWalletTransactions which is what you’re using.

There are no BSC testnet transactions for that 0xf598e416211c5cc653d91943631c94b6dc3a9ac1 address, you can check it on bscscan.com.

Since that address has some ERC20/BEP20 tokens, if you want that transfer info, you can use getWalletTokenTransfers or getWalletTokenBalances for info about the token.

Okay , thanks for clarifying .

I will check with the backend developer , since I am working inside Unity , so me and him work together on this part . I will pass him all the info. I got from you , and will try to solve the issue according to that .

Just one more confirmation that I want to be sure about :

(getWalletTransactions) end point is equivalent in the C# API call to : (Moralis.Web3Api.Account.GetTransactions) , true ? just to be 100% sure it’s the right call .

(getWalletTransactions) end point is equivalent in the C# API call to : (Moralis.Web3Api.Account.GetTransactions) , true ? just to be 100% sure it’s the right call .

Yes getTransactions has been renamed to getWalletTransactions, but any existing use of getTransactions with the SDK should still work.

1 Like