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

outdatedDart 1 only

Dart library to connect to Ethereum clients. Allows you to send transactions and 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.
  • Generate private keys and Ethereum accounts

TODO #

  • Interact with smart contracts deployed on the Ethereum blockchain.

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: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
        "0xf17f52151EbEF6C7334FAD080c5704D77216b732",
        EtherAmount.fromUnitAndValue(EtherUnit.ETHER, 2))
    .send(client); //and send.
    }

Features and bugs #

Please file feature requests and bugs at the issue tracker.

496
likes
0
pub points
96%
popularity

Publisher

verified publisherpwa.ir

Dart library to connect to Ethereum clients. Allows you to send transactions and build DApps in Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bignum, convert, http, meta, pointycastle

More

Packages that depend on web3dart