【发布时间】:2021-08-28 02:23:34
【问题描述】:
我正在尝试学习如何与 web3 集成,但我遇到了一些问题。 (正常我刚开始)
但是有一个问题我解决不了。
Uncaught TypeError: Cannot read property 'retrieve' of undefined
我尝试调用一个函数,但它不起作用,我不知道如何解决它。
代码如下:
const abi_c = [{"inputs": [],"name": "retrieve","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "uint256","name": "num","type": "uint256"}],"name": "store","outputs": [],"stateMutability": "nonpayable","type": "function"}];
const account = "0x644f1439DBfc743853031d79021890af54bCA8Ae";
const web3js = new Web3(window.ethereum);
ethereum.autoRefreshOnNetworkChange = false;
var contract = web3js.eth.contract(abi_c, account);
var result = contract.methods.retrieve().call();
console.log(result);
【问题讨论】: