import 'package:http/http.dart'; //You can also import the browser version
import 'package:web3dart/web3dart.dart';
var apiUrl = "http://localhost:7545"; //Replace with your API
var httpClient = Client();
var ethClient = Web3Client(apiUrl, httpClient);
var credentials = ethClient.credentialsFromPrivateKey("0x...");
// You can now call rpc methods. This one will query the amount of Ether you own
EtherAmount balance = ethClient.getBalance(credentials.address);
print(balance.getValueInUnit(EtherUnit.ether));这是web3dart包中的代码。我想用Metamask移动应用程序本身的一些url替换apiUrl (通过walletConnect包连接)。有帮手吗?
发布于 2022-10-09 20:01:51
您可以使用此方法连接到rpc最终凭据=EthPrivateKey.fromHex(私钥);因为另一个是不推荐的。
print("Accediendo al servidor blockchain...");
var rpcUrl = "HTTP://127.0.0.1:8545";
const String privatekey = "2812d889332dce9256c385355839102910ae8cc1c16c6e1212174d1dc91d9738";
final client = Web3Client(rpcUrl, Client());
final credentials = EthPrivateKey.fromHex(privatekey);
final address = credentials.address;
print(address.hexEip55);发布于 2022-10-24 13:46:05
使用此包进行颤振。链接:https://pub.dev/packages/web3dart
var apiUrl = "http://localhost:7545"; //Replace with your API
var httpClient = new Client();
var ethClient = Web3Client(apiUrl, httpClient);
EthPrivateKey credentials = await ethClient.credentialsFromPrivateKey("0x...........");
EthereumAddress address=credentials.address;
print("ADDRESS FORM PRIVATE KEY : "+address.hex);https://stackoverflow.com/questions/73268176
复制相似问题