I have deployed this simple smart contract using Remix
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
contract Counter {
uint256 private count = 0;
function setCount(uint256 val) external payable {
count = val;
}
function viewCount() external view returns (uint256) {
return count;
}
}
I deployed this contract using evm version: paris. Code has been successfully deployed and working fine on Remix IDE.
I am trying to interact this using web3.js in my next app in following way using metamask
const loadWeb3 = async () => {
if (window.ethereum) {
const web = new Web3(window.ethereum);
const accounts = await window.ethereum.request({
method: "eth_requestAccounts",
});
console.log("Accounts requested from MetaMask RPC: ", accounts);
try {
const contract = new web.eth.Contract(abi,contract-address);
const transactionReceipt = await contract.methods
.setCount(10)
.send({ from: accounts[0], gas: 3000000 });
console.log(transaction);
} catch (err) {
console.log(`error: ${err}`);
}
} else {
console.log("Please install metamask");
}
};
I was expecting that transaction would be successful but I am receiving this in my transactionReceipt
error: TransactionRevertedWithoutReasonError: Transaction has been reverted by the EVM:
{"blockHash":"0x6138b0cdd3a047486419f066ef056aab7b28c11bbaea82b5812c095f96cf86c7","blockNumber":"1382940","cumulativeGasUsed":"21046","from":"0x9ded1ae475bd50a15dde12bbc34b7ea04969cd0b","gasUsed":"21046","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","status":"0","to":"0xb69254cc37d818fdbcff6501acff400913147c1c","transactionHash":"0x6d3a2d51bae3746069db1cc778b357b92a6348a37d157181943c894cfbfc0d76","transactionIndex":"1"}
Unable to figure out why this error is happening.