Skip to content

Go SDK

The Go SDK is a typed Go module for Phantasma applications, services, and tooling. It covers JSON-RPC access, context-aware calls, Ed25519 keys and addresses, VM script building, VM transaction signing, and Carbon wire-format transactions.

Module path:

go get github.com/phantasma-io/phantasma-sdk-go

Main packages:

import (
    "github.com/phantasma-io/phantasma-sdk-go/pkg/carbon"
    "github.com/phantasma-io/phantasma-sdk-go/pkg/cryptography"
    "github.com/phantasma-io/phantasma-sdk-go/pkg/rpc"
    scriptbuilder "github.com/phantasma-io/phantasma-sdk-go/pkg/vm/script_builder"
)

What It Covers

AreaPackageUse it for
RPCpkg/rpc, pkg/rpc/responseContext-aware JSON-RPC calls and typed response models.
Keys and addressespkg/cryptographyWIF import/export, Ed25519 signatures, address parsing, hashes.
VM scriptspkg/vm/script_builderContract calls, interop calls, gas handling, transfers, staking, and NFT calls.
VM transactionspkg/blockchainScript transaction construction, signing, serialization, and state helpers.
Carbonpkg/carbonCarbon serialization, schemas, token creation payloads, NFT mint payloads, signed Carbon messages.

Carbon Workflows

Read-Only RPC Example

package main

import (
    "context"
    "fmt"
    "log"
    "time"

    "github.com/phantasma-io/phantasma-sdk-go/pkg/rpc"
)

func main() {
    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()

    client := rpc.NewRPCTestnet()
    version, err := client.GetVersion(ctx)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(version.Version, version.Commit)
}

Read-only calls do not require a signing key. Broadcasting helpers require a funded key and an endpoint selected by the application.

Guides