0

I want to connect to trustwallet or metamask with web3dart package and do the transaction for example send USDT. I am using this library because it supports all platforms, but it lacks documentation and good example. The problem is there is no working example for what I want to do. I could call rpcUrl for binance smart chain as bellow but I still stuck in how to call wallet for connection, get wallet address and amounts, do the transaction and sign the transaction as well.

import 'package:flutter/material.dart';
import 'package:http/http.dart';

import 'package:web3dart/web3dart.dart';

void main() {
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: MyHomePage(),
  ));
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Test'),
        actions: [
          IconButton(
            icon: const Icon(Icons.add),
            onPressed: () async {
              var rpcUrl = 'https://bsc-dataseed1.binance.org:443';

              var httpClient = Client();
              var ethClient = Web3Client(rpcUrl, httpClient);

              var chainId = await ethClient.getChainId();
              var networkId = await ethClient.getNetworkId();

              print(chainId);
              print(networkId);
            },
          ),
        ],
      ),
    );
  }
}
TylerH
  • 20,799
  • 66
  • 75
  • 101
Davoud
  • 2,576
  • 1
  • 32
  • 53

0 Answers0