Getting Started with Neo Rust SDK

Welcome to the Neo Rust SDK documentation! This guide will help you set up and start using the Neo Rust SDK in your projects.

Prerequisites

Before you begin, make sure you have:

  • Rust installed (version 1.65 or later)
  • Cargo package manager
  • Basic understanding of Rust programming
  • Basic understanding of blockchain concepts

Installation

Add Neo Rust SDK to your project by adding the following to your Cargo.toml file:

Cargo.toml
[dependencies]
neo3 = "0.1.9"

For the latest development version, you can use the Git repository:

Cargo.toml
[dependencies]
neo3 = { git = "https://github.com/R3E-Network/NeoRust.git", branch = "main" }

Basic Example

Here's a simple example to create a new wallet:

main.rs
use neo3::prelude::*;

fn main() -> Result<()> {
    // Create a new wallet
    let wallet = Wallet::new();
    
    // Print the wallet address
    println!("New wallet address: {}", wallet.address());
    
    Ok(())
}

Connecting to a Neo Node

To interact with the Neo blockchain, you'll need to connect to a Neo node:

connect.rs
use neo3::prelude::*;

async fn connect_example() -> Result<()> {
    // Connect to Neo TestNet
    let client = NeoClient::connect_to_testnet().await?;
    
    // Get the current block height
    let block_count = client.get_block_count().await?;
    println!("Current block height: {}", block_count);
    
    // To connect to MainNet instead
    // let client = NeoClient::connect_to_mainnet().await?;
    
    // Or connect to a custom node
    // let client = NeoClient::connect("http://seed1.neo.org:10332").await?;
    
    Ok(())
}

Next Steps

Now that you have installed the Neo Rust SDK and learned the basics, you can explore the following topics: