https://github.com/cdylan320/rust-web3

https://github.com/cdylan320/rust-web3

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.7%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: cdylan320
  • License: mit
  • Language: Rust
  • Default Branch: master
  • Size: 877 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 8
  • Releases: 0
Created about 1 year ago · Last pushed 12 months ago
Metadata Files
Readme License

README.md

web3

Ethereum JSON-RPC multi-transport client. Rust implementation of Web3.js library.

Build Status Crates.io

Documentation: crates.io

Status

Note this package is barely maintained and I am looking for an active maintainer (see #664). If you are starting a new project, I'd recommend choosing https://github.com/gakonst/ethers-rs instead.

Usage

First, add this to your Cargo.toml:

toml [dependencies] web3 = "0.19.0"

Example

```rust

[tokio::main]

async fn main() -> web3::Result<()> { let transport = web3::transports::Http::new("http://localhost:8545")?; let web3 = web3::Web3::new(transport);

println!("Calling accounts.");
let mut accounts = web3.eth().accounts().await?;
println!("Accounts: {:?}", accounts);
accounts.push("00a329c0648769a73afac7f9381e08fb43dbea72".parse().unwrap());

println!("Calling balance.");
for account in accounts {
    let balance = web3.eth().balance(account, None).await?;
    println!("Balance of {:?}: {}", account, balance);
}

Ok(())

} ```

If you want to deploy smart contracts you have written you can do something like this (make sure you have the solidity compiler installed):

solc -o build --bin --abi contracts/*.sol

The solidity compiler is generating the binary and abi code for the smart contracts in a directory called contracts and is being output to a directory called build.

For more see examples folder.

Futures migration

  • [ ] Get rid of parking_lot (replace with async-aware locks if really needed).
  • [ ] Consider getting rid of Unpin requirements. (#361)
  • [x] WebSockets: TLS support (#360)
  • [ ] WebSockets: Reconnecting & Pings
  • [x] Consider using tokio instead of async-std for ws.rs transport (issue with test).
  • [x] Restore IPC Transport

General

  • [ ] More flexible API (accept Into<X>)
  • [x] Contract calls (ABI encoding; debris/ethabi)
  • [X] Batch Requests

Transports

  • [x] HTTP transport
  • [x] IPC transport
  • [x] WebSockets transport

Types

  • [x] Types for U256,H256,Address(H160)
  • [x] Index type (numeric, encoded to hex)
  • [x] Transaction type (Transaction from Parity)
  • [x] Transaction receipt type (TransactionReceipt from Parity)
  • [x] Block type (RichBlock from Parity)
  • [x] Work type (Work from Parity)
  • [X] Syncing type (SyncStats from Parity)

APIs

  • [x] Eth: eth_*
  • [x] Eth filters: eth_*
  • [x] Eth pubsub: eth_*
  • [x] net_*
  • [x] web3_*
  • [x] personal_*
  • [ ] traces_*

Parity-specific APIs

  • [ ] Parity read-only: parity_*
  • [ ] Parity accounts: parity_* (partially implemented)
  • [x] Parity set: parity_*
  • [ ] signer_*

  • [x] Own APIs (Extendable) rust let web3 = Web3::new(transport); web3.api::<CustomNamespace>().custom_method().wait().unwrap()

Installation on Windows

Currently, Windows does not support IPC, which is enabled in the library by default. To compile, you need to disable the IPC feature: toml web3 = { version = "_", default-features = false, features = ["http"] }

Avoiding OpenSSL dependency

On Linux, native-tls is implemented using OpenSSL. To avoid that dependency for HTTPS or WSS use the corresponding features. toml web3 = { version = "_", default-features = false, features = ["http-rustls-tls", "ws-rustls-tokio"] }

Note: To fully replicate the default features also add signing & ipc-tokio features.

Cargo Features

The library supports following features: - http - Enables HTTP transport (requires tokio runtime, because of hyper). - http-tls - Enables TLS support via reqwest/default-tls for HTTP transport (implies http; default). - http-native-tls - Enables TLS support via reqwest/native-tls for HTTP transport (implies http). - http-rustls-tls - Enables TLS support via reqwest/rustls-tls for HTTP transport (implies http). - ws-tokio - Enables WS transport using tokio runtime. - ws-tls-tokio - Enables TLS support for WS transport (implies ws-tokio; default). - ws-rustls-tokio - Enables rustls TLS support for WS transport (implies ws-tokio). - ws-async-std - Enables WS transport using async-std runtime. - ws-tls-async-std - Enables TLS support for WS transport (implies ws-async-std). - ipc-tokio - Enables IPC transport using tokio runtime (default). - signing - Enable account namespace and local-signing support (default). - eip-1193 - Enable EIP-1193 support. - wasm - Compile for WASM (make sure to disable default features). - arbitrary_precision - Enable arbitrary_precision in serde_json. - allow-missing-fields - Some response fields are mandatory in Ethereum but not present in EVM-compatible chains such as Celo and Fantom. This feature enables compatibility by setting a default value on those fields.

Owner

  • Name: Dylan Combs
  • Login: cdylan320
  • Kind: user

GitHub Events

Total
Last Year

Dependencies

.github/workflows/deny.yml actions
  • EmbarkStudios/cargo-deny-action v1 composite
  • actions/checkout master composite
.github/workflows/lint.yml actions
  • actions-rs/cargo master composite
  • actions/checkout master composite
.github/workflows/rust.yml actions
  • actions-rs/cargo master composite
  • actions/checkout master composite
.github/workflows/typo.yml actions
  • actions/checkout v2 composite
  • crate-ci/typos v1.11.1 composite
Cargo.toml cargo
  • env_logger 0.11 development
  • hex-literal 0.4 development
  • wasm-bindgen-test 0.3.19 development
  • arrayvec 0.7.1
  • async-native-tls 0.4
  • async-std 1.6
  • base64 0.22
  • bytes 1.0
  • derive_more 0.99.1
  • ethabi 18.0.0
  • ethereum-types 0.14.1
  • futures 0.3.5
  • futures-timer 3.0.2
  • getrandom 0.2
  • headers 0.4
  • hex 0.4
  • idna 1.0
  • js-sys 0.3.45
  • jsonrpc-core 18.0.0
  • log 0.4.6
  • once_cell 1.8.0
  • parking_lot 0.12.0
  • pin-project 1.0
  • rand 0.8.1
  • reqwest 0.12
  • rlp 0.5
  • rustls-pki-types 1
  • secp256k1 0.28
  • serde 1.0.90
  • serde-wasm-bindgen 0.6.0
  • serde_json 1.0.39
  • soketto 0.8.0
  • tiny-keccak 2.0.1
  • tokio 1.0
  • tokio-rustls 0.26
  • tokio-stream 0.1
  • tokio-util 0.7
  • url 2.1
  • wasm-bindgen 0.2.68
  • wasm-bindgen-futures 0.4.18
  • webpki-roots 0.26