Skip to content

Rust SDK API Overview

This page summarizes the current Rust SDK public surface and links to the complete reference pages for detailed RPC methods, result fields, wire structures, and low-level helpers.

For the deeper API material, use the complete API reference:

Crate

ItemValue
Cratephantasma-sdk
Import pathphantasma_sdk
Current source version3.0.1
Version constantSDK_VERSION
Rust edition2021
Minimum Rust version1.74

Top-Level Imports

The crate re-exports common APIs from phantasma_sdk.

use phantasma_sdk::{
    Address, PhantasmaKeys, PhantasmaRpc, Result, ScriptBuilder, Transaction,
};

crypto

APIPurpose
AddressChecked Phantasma address with from_text, from_public_key, from_hash, null, to_text, kind, and public_key.
PhantasmaKeysEd25519 key pair with private_key, generate, from_wif, to_wif, public_key, address, and sign.
Ed25519SignatureSignature wrapper with verify and serialize_data.
HashSHA-256 hash wrapper with to_hex and difficulty.
AddressKind, SignatureKindTyped enums for address and signature kinds.

See Keys And Addresses for WIF, signing, address parsing, and Carbon Bytes32 conversion examples.

Details: VM and Transaction APIs.

vm

APIPurpose
ScriptBuilderChainable VM script builder.
ScriptArgStrongly typed script argument enum.
OpcodeVM opcode enum.
VMObjectVM object decoding and typed conversion.

Common ScriptBuilder methods include call_interop, call_contract, allow_gas, spend_gas, transfer_tokens, transfer_nft, stake, unstake, call_nft, end_script, end_script_hex, and end_script_with_error.

Method and helper reference: VM and Transaction APIs.

transaction

APIPurpose
TransactionVM script transaction with new, with_payload, to_bytes, from_bytes, hash, sign, is_signed_by, and mine.
tx_state_is_successReturns true for HALT.
tx_state_is_faultReturns true for FAULT or BREAK.
SDK_PAYLOADDefault SDK payload bytes.

rpc

APIPurpose
PhantasmaRpcAsync typed RPC facade.
RpcTransportTransport trait for live or test transports.
ReqwestTransportDefault HTTP transport.
Result structsAccountResult, BlockResult, TransactionResult, TokenResult, TokenDataResult, TokenSeriesResult, ScriptResult, and related RPC models.

PhantasmaRpc exposes read wrappers, invoke-script wrappers, and send helpers. See RPC for workflow usage, RPC Methods for signatures, and RPC Models for result fields.

carbon

APIPurpose
CarbonSerializable, CarbonWriter, CarbonReaderCarbon wire-format primitives.
Bytes16, Bytes32, Bytes64, SmallString, IntXChecked Carbon primitive types.
serialize, deserializeGeneric Carbon round-trip helpers.
TokenInfo, SeriesInfo, TokenSchemasToken and schema structures.
TokenSchemaField, TokenSchemasJson, VMStructSchema, VMDynamicStruct, VMDynamicVariableSchema and metadata structures used by token series, ROM, and RAM.
TxMsg, SignedTxMsg, WitnessCarbon transaction message structures.
build_token_metadata, build_token_info, prepare_standard_token_schemasMetadata and schema helpers.
token_schemas_from_json, parse_token_schemas_json, build_token_schemas_from_fields, verify_token_schemasCustom schema parsing and validation helpers.
build_create_token_tx, build_create_token_series_tx, build_mint_phantasma_non_fungible_txToken lifecycle transaction builders.
build_transfer_fungible_tx, build_transfer_non_fungible_tx, build_mint_fungible_tx, build_burn_fungible_tx, build_burn_non_fungible_txNative transfer, mint and burn builders, which need no VM script.
sign_tx_msg, sign_and_serialize_tx_msg, sign_and_serialize_tx_msg_hexCarbon transaction signing helpers.
plan_fees, FeePlan, FeePlanOptions, summarize_fee_plan, burned_instances, TxLimits, expiry_withinFee planning from the message and the chain’s gas configuration.
Result parsersparse_create_token_result, parse_create_token_series_result, parse_mint_non_fungible_result, parse_mint_phantasma_non_fungible_result.

See Schemas And Metadata, Fees And Broadcasting, and Carbon Operations for usage examples and workflow guidance.

Carbon type and builder reference: Carbon API and Wire Format.

encoding, binary, And error

ModulePurpose
encodingBase58 and hex helpers: encode_base58, decode_base58, encode_hex, decode_hex, encode_hex_upper.
binaryVM binary readers, writers, and VM bigint helpers.
errorPhantasmaError and Result<T>.

Specialized helpers remain public for tooling even though workflow examples do not call them directly: crypto::double_sha256(...) for WIF-style checksum work, vm::script_arg_number_to_i64(...) for compiler-style script argument inspection, and transaction::big_int(...) for concise BigInt construction in tests and examples.

Every public parsing, RPC, and builder path returns Result<T> for fallible work.