Initialize SDK

To initiate and utilize the Rust SDK, the initial step involves adding an entry to the Cargo.toml file for the SDK.

```toml
[dependencies]
cess-rust-sdk = { git = "https://github.com/CESSProject/cess-rust-sdk.git", version="0.1.0"}
tokio = { version = "1.29.1", features = ["full"] }

```

Open the main.rs file and initialize the ChainSDK as follows:-

```rust
use cess_rust_sdk::chain::ChainSdk;

// This module has default Cess chain URL and gateway URL
// and gateway account address.
use cess_rust_sdk::config;

// The account mnemonic that will be used to sign transactions.
const MNEMONIC: &str = "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice";

#[tokio::main]
async fn main() {
    // Default URL is set to CESS Testnet.
    // To change to local or other open CESS node 
    // call the set_custom_url function with URL:port
    config::set_custom_url(Some("ws://127.0.0.1:9944".to_string()));

    // Similarly for gateway url and account call the following 
    // functions with correct url and account.
    // config::set_custom_deoss_url(Some("gateway_url".to_string()));
    // config::set_custom_deoss_account(Some("gateway_account".to_string()));

    // Initialize the SDK object
    let sdk = ChainSdk::new(MNEMONIC, "service_name");
    
    // Other task
}

```

Last updated