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