我创建了一个虚拟的solidity合约(https://learn.aion.network/docs/deploy-a-smart-contract-using-web3)并部署它。当我尝试使用aion-web3拨打电话时出现问题。
const contract = require('aion-web3-eth-contract');
contract.setProvider("https://aion.api.nodesmith.io/v1/mastery/jsonrpc?apiKey=*");
const Web3 = require('aion-web3');
const web3 = new Web3(new Web3.providers.HttpProvider("https://aion.api.nodesmith.io/v1/mastery/jsonrpc?apiKey=*"));
const account = web3.eth.accounts.privateKeyToAccount("****");
let myContract = new contract([...], "0xa0e1166A455a0d75CFC2bfa32D7f76f0e1852c106b981Acf59EDE327CFD36811");
// console.log("C a",myContract.options.address);
myContract.methods.getCount().call({from: account.address}, function (error, result) {
if (error){
console.log("err=>", error)
} else {
console.log("res=>", result)
}
});
我期望 0 因为它是第一次调用,但它抛出以下错误:
TypeError: myContract.methods.getCount is not a function