zilliqa_rs/lib.rs
1/*!
2This crate provides routines for interacting with the [Zilliqa] network.
3Sending [JSON-RPC requests], sending transactions, deploying [scilla contracts],
4and interacting with them is easily possible using this crate.
5
6[Zilliqa]: https://www.zilliqa.com/
7[JSON-RPC requests]: https://dev.zilliqa.com/api/introduction/api-introduction/
8[scilla contracts]: https://scilla-lang.org/
9
10Here are some examples to get you started working with this crate.
11
12First, create the project in a new directory:
13
14```text
15$ mkdir zilliqa-rs-example
16$ cd zilliqa-rs-example
17$ cargo init
18```
19
20Second, `zilliqa-rs` and `tokio` to the dependencies:
21
22```text
23$ cargo add zilliqa-rs tokio
24```
25
26Third, edit `src/main.rs`. Delete what's there and replace it with each example.
27
28# Sending JSON-RPC requests
29The first step to do anything in zilliqa-rs is to create a `Provider`.
30Here we create an HTTP provider and call `GetBalance` JSON-RPC request.
31```rust
32use zilliqa_rs::providers::{Http, Provider};
33use zilliqa_rs::middlewares::Middleware;
34
35#[tokio::main]
36async fn main() -> anyhow::Result<()> {
37 let provider = Provider::<Http>::try_from("http://127.0.0.1:5555")?.with_chain_id(222);
38 let balance = provider.get_balance("0x381f4008505e940ad7681ec3468a719060caf796").await;
39 Ok(())
40}
41```
42*/
43
44pub mod contract;
45pub mod core;
46pub mod crypto;
47pub mod error;
48pub mod middlewares;
49pub mod providers;
50pub mod signers;
51pub mod transaction;
52pub use error::Error;
53
54/// Run them with `cargo test --doc`
55#[doc = include_str!("../README.md")]
56#[cfg(doctest)]
57pub struct ReadmeDoctests;