This repo contains the Rust SDK for interacting with the Symbol platform.
- 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 thePATH
environment variable as explained in the instructions.
-
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.
-
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
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>
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());
}
This project is in full development.
Licensed under the Apache License 2.0