"Error: Transaction has been reverted by the EVM" in Ethereum mainnet

Viewed 192

A source that works well on the Rinkeby network does not work on the Ethereum mainnet, so I would like to ask.

My Smart contract is

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/Ownable.sol";
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

contract Basic is ERC721A, Ownable {
    using Strings for uint256;
    string private BaseURI;

    constructor() ERC721A("NAME", "SYMBOL") {
        BaseURI = "ipfs://...";
    }

    function _startTokenId() internal view virtual override returns (uint256) {
        return 1;
    }

    function setBaseURI(string memory _uri) external onlyOwner {
        BaseURI = _uri;
    }

    function tokenURI(uint256 _tokenId)
        public
        view
        override
        returns (string memory)
    {
        require(_exists(_tokenId), "tokenURI : nonexistent token");
        return
            string(
                abi.encodePacked(
                    BaseURI,
                    "/",
                    Strings.toString(_tokenId),
                    ".json"
                )
            );
    }

    function mint(address _address, uint256 quantity) external onlyOwner {
        _mint(_address, quantity);
    }
}

And I wanted to interact with the smart contract with JavaScript code.

const Web3 = require("web3");
var contractInfo;
var owner_pk;
var owner_address;
var RPC;

const INV = {
  Ganache: 0,
  Rinkeby: 1,
  Mainnet: 2,
};
const TEST_INV = INV.Mainnet;

.........
} else if (TEST_INV == INV.Mainnet) {
  contractInfo = require("./mainnet-info.js");
  owner_pk = "............";
  owner_address = "0x1D15A2D8d660bf24Bdf9ddec0F94Cfc5D6d5Ab39";
  RPC = "https://mainnet.infura.io/v3/.......";
}

const web3 = new Web3(new Web3.providers.HttpProvider(RPC));

var contract = new web3.eth.Contract(
  contractInfo.ABI,
  contractInfo.CONTRACT_ADDRESS
);

async function mint(_address, quantity) {
  var functionData = contract.methods.mint(_address, quantity).encodeABI();

  txCount = await web3.eth.getTransactionCount(owner_address, "latest");

  const ntx = {
    to: contractInfo.CONTRACT_ADDRESS,
    gas: 5500000,
    nonce: web3.utils.toHex(txCount),
    data: functionData,
  };
  const signedTx = await web3.eth.accounts.signTransaction(ntx, owner_pk);
  var transactionReceipt;
  web3.eth.sendSignedTransaction(
    signedTx.rawTransaction,
    function (error, hash) {
      if (!error) {
        console.log("The hash of your transaction is: ", hash);
      } else {
        console.log(
          "Something went wrong while submitting your transaction:",
          error
        );
      }
    }
  );

  console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
  return "complete";
}

mint("0x1D15A2D8d660bf24Bdf9ddec0F94Cfc5D6d5Ab39", 1);

But when I run the JavaScript code, this error occurs:

Error: Transaction has been reverted by the EVM

The full error message is:

{
  "blockHash": "0xdf1035c5018127732b70ec545cf5ef8286768788173087de64156684a4ad30e2",
  "blockNumber": 15173679,
  "contractAddress": null,
  "cumulativeGasUsed": 2251524,
  "effectiveGasPrice": 62243679156,
  "from": "0x1d15a2d8d660bf24bdf9ddec0f94cfc5d6d5ab39",
  "gasUsed": 22384,
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xa9e27be51a8520b4d794c62cdac8263d2304da05",
  "transactionHash": "0x821f25e88c3ad9dbb55a8782690ca289c69cab0bae1f3412a4916f08a9d8ad0b",
  "transactionIndex": 51,
  "type": "0x0"
}

This is my smart contract and my account information.

Wallet Address: 0x1D15A2D8d660bf24Bdf9ddec0F94Cfc5D6d5Ab39

Smart Contract Address: 0xa9e27Be51A8520B4d794c62cDac8263d2304dA05

A list of all failed transactions can be viewed at the following link: https://etherscan.io/address/0x1D15A2D8d660bf24Bdf9ddec0F94Cfc5D6d5Ab39

0 Answers
Related