BlockPuppets / symbol-sdk-rust

Symbol SDK for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Symbol SDK for Rust Rust logo

License

This repo contains the Rust SDK for interacting with the Symbol platform.

Prerequisites

Software

  • Rust – can be downloaded using these instructions.
    • Where possible, use of rustup is highly recommended as it facilitates version and dependency management.

    • An introduction to the Rust programming language can be found here.

    • To confirm that you have successfully installed Rust and Cargo (the Rust build tool and package manager) the following command can be executed from a terminal window:

      cargo --version

      You should see version 1.51.0 or higher. If this command fails, the most likely reason relates to the PATH environment variable as explained in the instructions.

Installing the Symbol SDK for Rust

This SDK can be run be cloning the SDK or by creating a new project folder that includes a dependency on the Symbol SDK for Rust.

From an existing clone of this SDK repo

  • For those who have already cloned this github repo, running the following command from the root folder of the SDK in a terminal window should be sufficient to retrieve all required packages:

    cargo build

Running the examples

After running cargo build it should be possible to run the examples contained within this repo.

Running the following command from a terminal window will execute the example. Make sure you replace <filename> with the name (e.g. generate_account) of one of the example files. The .rs suffix is not required.

cargo run --example <filename>

Creating a public/private keypair for testnet use

As a general principle, it is bad practice to use your mainnet keys on a testnet. The code below shows the content of the generate_accounts example file. This shows how you can create new public and private keys using the Symbol SDK for Rust:

use symbol_sdk::account::Account;
use symbol_sdk::network::NetworkType;

fn main() {
    let account = Account::random(NetworkType::TEST_NET);
    println!("network_type: {}", account.network_type());
    println!("address: {}", account.address_str());
    println!("public_key: {}", account.public_key_to_hex());
    println!("private_key: {}", account.private_key_to_hex());
}

Note:

This project is in full development.

License

Licensed under the Apache License 2.0

About

Symbol SDK for Rust

License:Apache License 2.0


Languages

Language:Rust 100.0%