如何在 Flutter 中动态连接 metaMask 钱包私钥?

问题描述 投票:0回答:0

目前我正在使用 https://pub.dev/packages/web3dart 发送交易包,需要 metaMask 钱包私钥。我怎样才能得到私钥

transactionForAddProduct({String? functionName, var params, Web3Client? web3client}) async {

try {
  DeployedContract _contract = await loadContract();
  final sendFunction = contract.function(functionName!);
  Transaction transaction = Transaction.callContract(
    from: EthereumAddress.fromHex("walletAddress"),
    contract: _contract,
    function: _sendFunction,
    parameters: params,
  );
  var transactionValue = web3client!.sendTransaction(
    EthPrivateKey.fromHex("privateKey"),
    transaction,
    chainId: 80001,
    fetchChainIdFromNetworkId: false,
  );
  print("=====> transaction is ${transactionValue}");
} catch (exception) {
  print("=======> exception is ${exception.toString()}");
}

}

flutter dart payment metamask wallet
© www.soinside.com 2019 - 2024. All rights reserved.