web3dart 0.4.2 web3dart: ^0.4.2 copied to clipboard
Dart library to connect to Ethereum clients. Allows you to send transactions and build DApps in Dart.
import 'dart:async';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
const String _PRIVATE_KEY = "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const String _URL = "http://localhost:7545";
Future<Null> main() async {
var httpClient = new Client();
Web3Client client = new Web3Client(_URL, httpClient);
client.printErrors = true;
var credentials = Credentials.fromPrivateKeyHex(_PRIVATE_KEY);
//Set up a new transaction
new Transaction(keys: credentials, maximumGas: 100000)
.prepareForSimpleTransaction( //that will transfer 2 ether
new EthereumAddress("0xf17f52151EbEF6C7334FAD080c5704D77216b732"),
EtherAmount.fromUnitAndValue(EtherUnit.ether, 2))
.send(client); //and send.
}