I am getting the error calling the mint function on a contract.

Error:  Nethereum.JsonRpc.Client.RpcResponseException: execution reverted

I used ERC721PresetMinterPauserAutoId from OpenZeppelin for the erc721 contract. Then used VsCode Solidity extension to generate the code. The generated files are: ERC721PresetMinterPauserAutoIdService

When I tested the code using truffle in the development environment and in ropsten it worked.

When I try to call with the Nethereum code below, I get the execution reverted.

var account = new Account(privateKey);
var web3 = new Web3(account, $"https://ropsten.infura.io/v3/{projectId}");    
ERC721PresetMinterPauserAutoIdService srv = new ERC721PresetMinterPauserAutoIdService(web3, contractAddress);
MintFunction mint = new MintFunction { To = toAddress };    
var result = await srv.MintRequestAndWaitForReceiptAsync(mint, null);   
Console.WriteLine($"transaction index: {result.TransactionIndex}");

Any help woudld be appreciated.

  • I used the Nethereum Playground Abi Code Gen to generate the code. I was able to get the mint function working with this code.
    – eloew
    May 5 '21 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.