【发布时间】:2022-06-14 23:35:59
【问题描述】:
我尝试将 web3 中的合同与颤振连接起来,并在其中运行一个方法。我们的 react-js 开发人员给了我这些代码来连接到 getMoney 方法:
const web3 = new Web3(Web3.givenProvider ||"https://rinkeby.infura.io/v3/...");
const contactList = new web3.eth.Contract(CONTACT_ABI, CONTACT_ADDRESS);
const getMoney = await contactList.methods.getMoney().call();
console.log(getMoney);
我尝试使用flutter_web3 包来连接元掩码和合约:
String abi = await rootBundle.loadString("assets/json/Counter.json");
final contract = Contract(CONTACT_ADDRESS, abi, Web3Provider("https://rinkeby.infura.io/v3/..."),);
int money = await contract.call("getMoney");
print(money.toString());
但我无法连接到合约并调用getMoney 方法。你能帮帮我吗?
【问题讨论】:
标签: flutter flutter-web web3js