ethereum 1.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 69

ethereum

Build Status

An ethereum RPC 2 client for Dart.

This package provides a client to access the Ethereum JSON RPC API documented here It uses the JSON RPC2 interface and can be configured to use any of the endpoints described. The client runs on the server using HTTP, and in the browser using both HTTP and web sockets.

The package currently implements 55 of the API calls documented, the main omissions being ones documented but no longer implemented in the latest version of geth. This encompasses the Solidity interface and most of the SHH whisper interface. As this Ethereum API is updated the package will be updated to suit.

The mapping of Ethereum RPC data types to Dart types is as follows :-

  • boolean - bool
  • string - String
  • quantity - int
  • data - BigInt(see below)

Examples can be found in the examples directory, also the unit test suite contains examples of calling every API interface.

The package was tested against a geth client, version 1.7.2. The API provided should work on older geth clients but be aware some calls may return an error of not implemented.

The package currently depends on the BigNum package, this package is not currently Dart 2.0 ready and may be superceded by a new BigInt implementation in Dart. This package will be updated approprately as and when any changes are needed.

#1.1.0 Minor API(default block parameter) and coverage updates

1.0.1

Updates from publishing analysis ob pub site.

1.0.0

Initial release

example/example.dart

/*
 * Package : Ethereum
 * Author : S. Hamblett <steve.hamblett@linux.com>
 * Date   : 03/11/2017
 * Copyright :  S.Hamblett
 */

import 'dart:async';
import 'package:ethereum/ethereum_server_client.dart';

/// Example client usage
/// Please refer to https://github.com/ethereum/wiki/wiki/JSON-RPC for further details of ports etc.

Future main() async {
  // Create a client using default parameters
  final EthereumServerClient client =
      new EthereumServerClient.withConnectionParameters("localhost");

  // Or, with a specified port for WS working in the browser
  // new EthereumBrowserWSClient.withConnectionParameters("localhost", 8546);

  // Turn on error printing if needed.
  client.printError = true;

  // Make an API call, the client is stateless form a connection point of view.
  final String version = await client.protocolVersion();

  // Check for an error if you think anything is wrong
  if (version == null) {
    print("We have errored -> ${client.lastError}");
  } else {
    print("We are OK -> ${client.lastError}");
  }

  // The transaction id increments every time, first call sets it to one
  print("Transaction Id is -->  ${client.rpcClient.id}");

  // You can have as many clients as you wish, this has its own transaction id
  final EthereumServerClient client2 =
      new EthereumServerClient.withConnectionParameters("localhost");

  client2.printError = true;
}

Use this package as a library

1. Depend on it

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


dependencies:
  ethereum: "^1.1.0"

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 flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:ethereum/ethereum.dart';
  
Version Uploaded Documentation Archive
1.1.0 Jan 19, 2018 Go to the documentation of ethereum 1.1.0 Download ethereum 1.1.0 archive
1.0.1 Jan 16, 2018 Go to the documentation of ethereum 1.0.1 Download ethereum 1.0.1 archive
1.0.0 Jan 15, 2018 Go to the documentation of ethereum 1.0.0 Download ethereum 1.0.0 archive

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
40 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95 / 100
Overall score:
Weighted score of the above. [more]
69
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Use constrained dependencies.

    The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: bignum.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 15 hints.

    Run dartfmt to format lib/ethereum.dart.

    Run dartfmt to format lib/ethereum_browser_http_client.dart.

    Similar analysis of the following files failed:

    • lib/ethereum_browser_ws_client.dart (hint)
    • lib/ethereum_server_client.dart (hint)
    • lib/src/adapters/ethereum_browser_http_adapter.dart (hint)
    • lib/src/adapters/ethereum_browser_ws_adapter.dart (hint)
    • lib/src/adapters/ethereum_server_http_adapter.dart (hint)
    • lib/src/ethereum.dart (hint)
    • lib/src/ethereum_error.dart (hint)
    • lib/src/ethereum_utilities.dart (hint)
    • lib/src/messages/ethereum_block.dart (hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
bignum any 0.1.0
Transitive dependencies
fixnum 0.10.7
Dev dependencies
coverage ^0.7.3
dart_dev ^1.0.0
dart_style >=0.2.0 <0.3.0
dartdoc >=0.8.0 <=0.10.0
test ^0.12.0