使用JavaScript中的web3的参数具有callin智能合约功能

时间:2018-12-09 23:08:43

标签: javascript call smartcontracts web3

这是我遇到的问题:

//this is just a smart contract i just picked up from etherscan
var c = web3.eth.contract([{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"token","type":"address"}],"name":"tokenBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"users","type":"address[]"},{"name":"tokens","type":"address[]"}],"name":"balances","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"}]);
var contract = c.at("0xb1F8e55c7f64D203C1400B9D8555d050F94aDF39");

//This is not working
contract.methods.tokenBalance("0x", "0x").call((err, balance) => {
        console.log({err, balance});
})

它说contract.methods不是函数。我不知道我在做什么错。

0 个答案:

没有答案