A dart library that connects to interact with the Ethereum blockchain. It connects to an Ethereum node to send transactions, interact with smart contracts and much more!
- Connect to an Ethereum node with the rpc-api, call common methods
- Send signed Ethereum transactions
- Generate private keys, setup new Ethereum addresses
- Call functions on smart contracts and listen for contract events
- Code generation based on smart contract ABI for easier interaction
- Encode all supported solidity types, although only (u)fixed, which are not commonly used, are not supported at the moment.
In order to send transactions on the Ethereum network, some credentials are required. The library supports raw private keys and v3 wallet files.
import 'package:transaction/web3dart.dart';
// You can setup private keys first
web3dart.initEthClient(privateKey:'d1bdc683fbeb9fa0b4ceb26adb39eaffb21b16891ea28e4cf1bc3118fdd39295');
Of course, this library supports creating, signing and sending Ethereum transactions:
import 'package:web3dart/web3dart.dart';
/// send ETH Token Transaction
web3dart.sendETHFromMainnet(amount: EtherAmount.fromUnitAndValue(EtherUnit.finney, 1),toAddress:'0xA3B4dE5E90A18512BD82c1A640AC99b39ef2258A');
/// send ERC20 Token Transaction
/// if usdt Decimals is 18 than 1000000000000000000 = 1 amount for example: BigInt.from(1000000000000000000)
web3dart.sendERC20FromMainnet(contractAddress: '0x7e0480ca9fd50eb7a3855cf53c347a1b4d6a2ff5',amount: BigInt.from(1000000000000000000),toAddress:'0xA3B4dE5E90A18512BD82c1A640AC99b39ef2258A');
import 'package:transaction/model/coinPrice.dart';
import 'package:transaction/transaction.dart';
import 'dart:async';
/// getTopErc20CoinPrice
CoinPriceList coinPrice = await transaction.getTopErc20CoinPrice();
print("result:$coinPrice");