Crate ethane[][src]

Ethane is an alternative web3 implementation with the aim of being slim and simple. It does not depend on futures or any executors. It currently supports http and websockets (both plain and TLS) and inter process communication via Unix domain sockets (Unix only). For http and websockets it also supports Http Basic and Bearer Authentication.

Currently only Eth1 is supported and not all namespaces are implemented. You can have a look here (supported RPCs) to see what is supported. Please note that the JSON spec is a bit outdated, and there is some effort to create a new one, so expect some breaking changes in the future.

This library is very raw and under heavy development. Expect to find some bugs and use at your own risk!

In order to get started, create a connection over some transport. The following examples show you how to make a request and how to subscribe to events.

Examples

Request over http

use ethane::{Connection, Http};
use ethane::rpc::eth_get_balance;
use ethane::types::Address;

// Start up connection
let node_endpoint = "http://127.0.0.1:8545";
let mut connection = Connection::new(Http::new(node_endpoint, None));

// Make a request
let address = Address::zero();
let balance = connection.call(eth_get_balance(address, None)).unwrap();

Starting a subscription over websocket

use ethane::{Connection, WebSocket};
use ethane::rpc::sub::eth_subscribe_new_pending_transactions;


// Start up connection with websockets
let node_endpoint = "ws://127.0.0.1:8546";
let mut connection = Connection::new(WebSocket::new(node_endpoint, None).unwrap());

// Subscribe to pending transactions
let mut tx_subscription = connection
    .subscribe(eth_subscribe_new_pending_transactions()).unwrap();

// Get next transaction item
let tx = tx_subscription.next_item().unwrap();

Modules

contract
rpc

Functions to generate Rpcs

types

Collects all the needed Ethereum types

Structs

Connection
Http

Wraps a http client

JsonError

Used to deserialize errors returned from the ethereum node.

Subscription

An active subscription

Uds

An interprocess connection using a unix domain socket (Unix only)

WebSocket

Wraps a websocket connection

Enums

ConnectionError

Wraps the different transport errors that may occur.

Credentials

Credentials used for authentication.

HttpError

An error type collecting what can go wrong with http requests

SubscriptionError

An error type collecting what can go wrong during a subscription

UdsError

An error type collecting what can go wrong with unix domain sockets

WebSocketError

An error type collecting what can go wrong with a websocket

Traits

Request
Subscribe