sendTransaction method

  1. @override
Future<String> sendTransaction(
  1. Transaction transaction
)

Implementation

@override
Future<String> sendTransaction(Transaction transaction) async {
  String walletConnectTopicVersion =
      'wc:${walletConnect.session.handshakeTopic}@${walletConnect.session.version}';
  String walletConnectUri = '';

  // Android OS helps the user choose their wallet
  walletConnectUri = walletConnectTopicVersion;

  bool result = await launchUrl(Uri.parse(walletConnectUri),
      mode: LaunchMode.externalApplication);
  if (result == false) {
    // Application specific link didn't work, so we may redirect to the app store to get a wallet
    result = await launchUrl(Uri.parse(walletConnectUri));
    if (result == false) {
      if (kDebugMode) {
        print('Could not launch $walletConnectUri');
      }
    }
  }
  sleep(const Duration(milliseconds: 4000));
  dynamic requestResult = await walletConnect.sendCustomRequest(
    method: "eth_sendTransaction",
    params: <dynamic>[
      {
        "from":
            EthereumAddress.fromHex(walletConnect.session.accounts[0]).hex,
        "to": "0x916E1b5b57DCE7F2f11085a2d259a5D562dc7295",
        "value":
            transaction.value!.getInWei.toRadixString(16), // 2441406250 279
      }
    ],
  );
  return requestResult;
}