web3dart 0.0.2 copy "web3dart: ^0.0.2" to clipboard
web3dart: ^0.0.2 copied to clipboard

outdatedDart 1 only

Ethereum library, build DApps in Dart

web3dart #

A library for making transactions in Ethereum using Dart. This library is in early development, has not been through a security audit and should not be used in a productive environment.

Features #

  • Send valid and signed transactions to an Ethereum client using the JSON-RPC API.

TODO #

  • Interact with smart contracts deployed on the Ethereum blockchain.
  • Key/Account generation.

Usage #

In order to use this library, you will need an client connected to Ethereum nodes so that your transactions can actually be processed. You can either set up a local, private blockchain (by for instance using truffle and ganache), run an Ethereum node yourself (for instance with geth, or use a public RPC API, like infura.

import 'package:web3dart/web3dart.dart';

main() {
//Replace with private key of an account that can transfer ether
var privateKeyHex = "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
var apiUrl = "http://localhost:7545"; //Replace with your API

var credentials = Credentials.fromHexPrivateKey(privateKeyHex);
var client = new Web3Client(apiUrl);

//Set up a new transaction
new Transaction(keys: credentials, maximumGas: 100000)
.prepareForSimpleTransaction( //that will transfer 2 ether
    "0xf17f52151EbEF6C7334FAD080c5704D77216b732",
    EtherAmount.fromUnitAndValue(EtherUnit.ETHER, 2))
.send(client); //and send.
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.