Skip to content

Rust SDK

The Rust SDK is a checked Rust crate for Phantasma applications, services, and tooling. It covers JSON-RPC access, Ed25519 keys and signatures, VM script building, VM script transaction signing, and Carbon wire-format transactions.

Crate name:

[dependencies]
phantasma-sdk = "3.0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Import path:

use phantasma_sdk::{PhantasmaRpc, Result};

All fallible public APIs return phantasma_sdk::Result<T>. Parsing and builder code rejects malformed input with PhantasmaError instead of panicking.

What It Covers

AreaModuleUse it for
RPCphantasma_sdk::rpcAsync JSON-RPC calls and typed response models.
Keys and addressesphantasma_sdk::cryptoWIF, Ed25519 signatures, address parsing, hashes.
VM scriptsphantasma_sdk::vmBuilding VM scripts for contract calls, interop calls, gas, transfers, staking, and NFT calls.
VM transactionsphantasma_sdk::transactionSerializing, signing, mining, and checking VM script transactions.
Carbonphantasma_sdk::carbonCarbon serialization, schemas, token creation payloads, NFT mint payloads, signed Carbon messages.

Carbon Workflows

Use the Carbon workflow pages when creating native assets:

Read-Only RPC Example

use phantasma_sdk::{PhantasmaRpc, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let rpc = PhantasmaRpc::new("http://localhost:5172/rpc");
    let version = rpc.get_version().await?;
    println!("{} {}", version.version, version.commit);
    Ok(())
}

Guides