如何连接web3合约和flutter
我想用 flutter 创建一个 web d-App。我使用 flutter_web3 使用以下代码连接到浏览器上的元掩码钱包:
final access = await ethereum!.requestAccount();
if (access.isNotEmpty) currentAddress = access.first;
它连接成功,我可以获取账户地址。我还有 Solidity 中的这些函数:
pragma solidity ^0.8.0;
contract Money {
uint public money = 0;
function getMoney() public view returns(uint256) {
return money;
}
function updateMoney() external {
money += 1;
}
}
此外,我还有合约地址、RPC URL 和 abi.json 文件。那么,如何通过合约调用 getMoney 函数和 updateMoney 函数呢?
I want to create a web d-App with flutter. I use flutter_web3 to connect to a metamask wallet on the browser with this code:
final access = await ethereum!.requestAccount();
if (access.isNotEmpty) currentAddress = access.first;
It connects successfully and I can get the address of the account. also I have these functions in solidity:
pragma solidity ^0.8.0;
contract Money {
uint public money = 0;
function getMoney() public view returns(uint256) {
return money;
}
function updateMoney() external {
money += 1;
}
}
Also, I have the contract address, RPC URL, and an abi.json file. So, How can I call getMoney function and updateMoney function with the contract?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论