web3x 1.0.9 copy "web3x: ^1.0.9" to clipboard
web3x: ^1.0.9 copied to clipboard

Dart library to connect to Ethereum clients. Send transactions and interact with smart contracts!

example/lib/main.dart

// ignore_for_file: public_member_api_docs

import 'package:http/http.dart';
import 'package:web3x/web3x.dart';

const String privateKey =
    'a2fd51b96dc55aeb14b30d55a6b3121c7b9c599500c1beb92a389c3377adc86e';
const String rpcUrl = 'http://localhost:7545';

Future<void> main() async {
  // start a client we can use to send transactions
  final client = Web3Client(rpcUrl, Client());

  final credentials = EthPrivateKey.fromHex(privateKey);
  final address = credentials.address;

  print(address.hexEip55);
  print(await client.getBalance(address));

  await client.sendTransaction(
    credentials,
    Transaction(
      to: EthereumAddress.fromHex('0xC914Bb2ba888e3367bcecEb5C2d99DF7C7423706'),
      gasPrice: EtherAmount.inWei(BigInt.one),
      maxGas: 100000,
      value: EtherAmount.fromInt(EtherUnit.ether, 1),
    ),
  );

  await client.dispose();
}
0
likes
150
points
52
downloads

Documentation

API reference

Publisher

verified publisherastrox.io

Weekly Downloads

Dart library to connect to Ethereum clients. Send transactions and interact with smart contracts!

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

async, convert, eip1559, eip55, eth_sig_util, http, json_rpc_2, pointycastle, sec, stream_channel, stream_transform, typed_data, uuid, wallet

More

Packages that depend on web3x