Skip to main content

Go SDK

The Go SDK is the full-coverage Mintlayer SDK: it wraps the node RPC, the indexer REST API, and the wallet RPC as typed Go clients, and embeds the WASM cryptography runtime for key management and transaction building without the wallet daemon.

go get github.com/mintlayer/go-sdk

Architecture

A top-level Client wires four independent sub-clients. Import only what you need.

PackagePurposeDefault port
sdk/nodeJSON-RPC 2.0 client for the node daemon3030 (mainnet)
sdk/indexerREST client for the indexer (api-web-server)3000 (mainnet)
sdk/walletJSON-RPC 2.0 client for the wallet daemon3034 (mainnet)
sdk/wasmCryptography and transaction building via WASMnone (embedded)

The sub-clients map 1:1 to the services documented in Developer Setup, and the indexer client mirrors the API endpoints endpoint-for-endpoint.

Quick start

package main

import (
"context"
"fmt"
"log"

sdk "github.com/mintlayer/go-sdk"
)

func main() {
client := sdk.New(sdk.Config{
NodeURL: "http://127.0.0.1:3030",
IndexerURL: "http://127.0.0.1:3000",
WalletURL: "http://127.0.0.1:3034",
})
defer client.Close()

ctx := context.Background()

// Query the chain tip from the indexer.
tip, err := client.Indexer.GetTip(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("chain tip: height=%d id=%s\n", tip.BlockHeight, tip.BlockID)

// Optionally initialise the embedded WASM runtime (~400 ms).
if err := client.InitWASM(ctx); err != nil {
log.Fatal(err)
}

privKey, err := client.WASM.MakePrivateKey()
if err != nil {
log.Fatal(err)
}
_ = privKey
}

Guides

GuideContents
Node clientChainstate, mempool, P2P, block submission
Indexer clientChain, blocks, transactions, addresses, pools, tokens, orders, statistics
Wallet clientWallet lifecycle, accounts, balances, transactions
WASM clientKeys, addresses, inputs, outputs, signing, fees
TransactionsBuilding and signing transactions without the wallet daemon
StakingPool creation, delegation, withdrawal
TokensFungible tokens and NFTs: issuance, minting, freezing

Runnable examples live in the repository under examples/ (send-coins, issue-token) and testnet-live/.