Crate zilliqa_rs

source ·
Expand description

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.

Here are some examples to get you started working with this crate.

First, create the project in a new directory:

$ mkdir zilliqa-rs-example
$ cd zilliqa-rs-example
$ cargo init

Second, zilliqa-rs and tokio to the dependencies:

$ 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.

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(())
}

Re-exports

Modules

  • Interact with scilla contracts.
  • Shared data types and functionalities.
  • Different error variations that are possible in zilliqa-rs
  • Clients for interacting with zilliqa network.
  • A unified interface for locally signing zilliqa transactions.
  • Send transaction to zilliqa network