web3dart 0.2.1

  • README.md
  • Example
  • Installing
  • Versions
  • 74


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.


  • Send valid and signed transactions to an Ethereum client using the JSON-RPC API.
  • Generate private keys and Ethereum accounts
  • (sort of) Send messages and function calls to smart contracts


  • Code generation based on smart contract ABI for easier interaction
  • Smart Contract events
  • Encode all supported solidity types, although only tuple and (u)fixed, which are not commonly used, are not supported at the moment.


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:http/http.dart'; //You can also import the browser version
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 httpClient = new Client();

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

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

See example/crypto_kittens_example.dart for an example on how to call methods from smart contracts deployed on the blockchain.

Feature requests and bugs

Please file feature requests and bugs at the issue tracker.



  • More solidity types, not with encoding.


  • Send transactions and call messages from smart contracts on the Blockchain.


  • Create new Ethereum accounts


  • Send and sign transactions


  • Initial version, created by Stagehand


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

const String _PRIVATE_KEY = "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const String _URL = "http://localhost:7545";

main() async {
	var httpClient = new Client();
	Web3Client client = new Web3Client(_URL, httpClient);
	client.printErrors = true;

	var credentials = Credentials.fromHexPrivateKey(_PRIVATE_KEY);

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

1. Depend on it

Add this to your package's pubspec.yaml file:

  web3dart: "^0.2.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:web3dart/web3dart.dart';
Version Uploaded Documentation Archive
0.2.1 Jan 17, 2018 Go to the documentation of web3dart 0.2.1 Download web3dart 0.2.1 archive
0.2.0 Jan 15, 2018 Go to the documentation of web3dart 0.2.0 Download web3dart 0.2.0 archive
0.1.0 Jan 14, 2018 Go to the documentation of web3dart 0.1.0 Download web3dart 0.1.0 archive
0.0.2 Jan 13, 2018 Go to the documentation of web3dart 0.0.2 Download web3dart 0.0.2 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6


Describes how popular the package is relative to other packages. [more]
58 / 100
Code health derived from static analysis. [more]
84 / 100
Reflects how tidy and up-to-date the package is. [more]
98 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:web3dart/web3dart.dart.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 4 errors 22 hints.

    Strong-mode analysis of lib/src/web3client.dart failed with the following error:

    line: 145 col: 24
    The argument type '(String) → List<int>' can't be assigned to the parameter type '(dynamic) → FutureOr<List<int>>'.

    Run dartfmt to format lib/src/contracts/abi.dart.

    Similar analysis of the following files failed:

    • lib/src/contracts/types/arrays.dart (hint)
    • lib/src/contracts/types/integers.dart (hint)
    • lib/src/contracts/types/type.dart (hint)
    • lib/src/io/jsonrpc.dart (hint)
    • lib/src/io/rawtransaction.dart (hint)
    • lib/src/transaction.dart (hint)
    • lib/src/utils/amounts.dart (hint)
    • lib/src/utils/credentials.dart (hint)
    • lib/src/utils/dartrandom.dart (hint)
    • lib/src/utils/keys.dart (hint)
    • lib/src/utils/numbers.dart (hint)
    • lib/src/utils/rlp.dart (hint)
    • lib/web3dart.dart (hint)
  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
bignum ^0.1.0 0.1.0
convert ^2.0.1 2.0.1
http ^0.11.3+16 0.11.3+16
meta ^1.1.2 1.1.2
pointycastle ^0.10.0+5 0.10.0+5 0.11.1
tuple ^1.0.1 1.0.1
Transitive dependencies
analyzer 0.30.0+4 0.31.1
args 1.4.2
async 2.0.6
barback 0.15.2+15
charcode 1.1.1
cli_util 0.1.2+1
code_transformers 0.5.1+4
collection 1.14.9
crypto 2.0.2+1
csslib 0.14.1
dart_style 1.0.9+1 1.0.10
fixnum 0.10.7
front_end 0.1.0-alpha.4.1 0.1.0-alpha.11
glob 1.1.5
html 0.13.3
http_parser 3.1.1
isolate 1.1.0 2.0.0
kernel 0.3.0-alpha.1.1 0.3.0-alpha.11
logging 0.11.3+1
package_config 1.0.3
path 1.4.2 1.5.1
plugin 0.2.0+2
pool 1.3.4
quiver_collection 1.0.0
quiver_hashcode 1.0.0
quiver_iterables 1.0.1
quiver_pattern 1.0.0
reflectable 1.0.4 2.0.0
source_maps 0.10.4
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
yaml 2.1.13
Dev dependencies
test ^0.12.0