【发布时间】:2019-05-23 12:27:46
【问题描述】:
我创建了一个虚拟的 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
【问题讨论】:
标签: aion