How to properly call a Nethereum smart contract overloaded function

4 weeks ago 15
ARTICLE AD BOX

Ran into this challenge, interacting with a smart contract that I had deployed to Polygon Amoy testnet. There are two functions for safeTransferFrom. Which is the preferred way to move an ERC-721 between two wallets.

safeTransferFrom(from: address, to: address, tokenId: uint256)

safeTransferFrom(from: address, to: address, tokenId: uint256, _data: bytes)

In my Nethereum C# project, I first started working with the overloaded safeTransferFrom function like this:

var transferNftFunction = contract.GetFunction("safeTransferFrom"); var gasEstimate = transferNftFunction.EstimateGasAsync(accountAddress, null, null, senderAddress, recipientAddress, tokenId, byteComments).Result;

But getting the gas estimate was failing, due to an invalid number of arguments. I was passing along four arguments to the function, when the function was only expecting three. So apparently Nethereum doesn't natively honor overloading functions as you'd encounter when overloading your basic C# methods.

Read Entire Article