Skip to main content

Go SDK

Go Reference License: MIT Official Go SDK for the Paratro MPC Wallet Gateway.

Installation

go get github.com/paratro/paratro-sdk-go@latest
Requirements: Go 1.21 or higher. New wallets are created asynchronously. Wait until both status and key_status are ACTIVE before creating accounts or transfers. The gateway derives account network automatically from the selected chain.

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

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

func main() {
    client, err := paratro.NewMPCClient(
        "your-api-key",
        "your-api-secret",
        paratro.Production(),
    )
    if err != nil {
        log.Fatal(err)
    }
    ctx := context.Background()

    // Create wallet
    wallet, err := client.Wallet.CreateWallet(ctx, &paratro.CreateWalletRequest{
        WalletName:  "My Wallet",
        Description: "Primary wallet",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Wallet ID: %s\n", wallet.WalletID)

    // Create account
    account, err := client.Account.CreateAccount(ctx, &paratro.CreateAccountRequest{
        WalletID: wallet.WalletID,
        Chain:    "ethereum",
        Label:    "Deposit Account",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Account: %s (%s)\n", account.AccountID, account.Address)

    // Add asset
    asset, err := client.Asset.CreateAsset(ctx, &paratro.CreateAssetRequest{
        AccountID: account.AccountID,
        Symbol:    "USDT",
        Chain:     "ethereum",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Asset: %s (%s)\n", asset.AssetID, asset.Symbol)

    // Create transfer
    transfer, err := client.Transaction.CreateTransfer(ctx, &paratro.CreateTransferRequest{
        FromAddress: account.Address,
        ToAddress:   "0xbbbb...",
        Chain:       "ethereum",
        TokenSymbol: "USDT",
        Amount:      "10.5",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Transfer: %s (%s)\n", transfer.TxID, transfer.Status)
}

Configuration

// Sandbox: https://api-sandbox.paratro.com
client, err := paratro.NewMPCClient(apiKey, apiSecret, paratro.Sandbox())

Services

The SDK organizes API access into service objects:
ServiceMethods
client.WalletCreateWallet, GetWallet, ListWallets
client.AccountCreateAccount, GetAccount, ListAccounts
client.AssetCreateAsset, GetAsset, ListAssets
client.TransactionCreateTransfer, GetTransaction, ListTransactions

Error Handling

The SDK returns structured *paratro.APIError for API failures:
wallet, err := client.Wallet.GetWallet(ctx, walletID)
if err != nil {
    if paratro.IsNotFound(err) {
        log.Println("Wallet not found")
    } else if paratro.IsAuthError(err) {
        log.Println("Authentication failed")
    } else if paratro.IsRateLimited(err) {
        log.Println("Rate limited, retry later")
    }
    return
}
For detailed error inspection, use errors.As:
import "errors"

wallet, err := client.Wallet.GetWallet(ctx, walletID)
if err != nil {
    var apiErr *paratro.APIError
    if errors.As(err, &apiErr) {
        switch apiErr.ErrorBody.Code {
        case "asset_already_exists":
            log.Println("Asset already added to this account")
        case "account_not_active":
            log.Println("Account is not active")
        default:
            log.Printf("API error: %s - %s", apiErr.ErrorBody.Code, apiErr.ErrorBody.Message)
        }
    }
    return
}

Helper Functions

FunctionDescription
paratro.IsNotFound(err)Detects 404 responses
paratro.IsRateLimited(err)Identifies 429 rate-limit responses
paratro.IsAuthError(err)Catches 401/403 permission issues
See Error Handling Guide for more patterns.

Pagination

List methods support pagination:
txList, err := client.Transaction.ListTransactions(ctx, &paratro.ListTransactionsRequest{
    WalletID: wallet.WalletID,
    Page:     1,
    PageSize: 20,
})
if err != nil {
    log.Fatal(err)
}

for _, tx := range txList.Items {
    fmt.Printf("TX: %s %s %s (%s)\n", tx.TxHash, tx.Amount, tx.TokenSymbol, tx.Status)
}

if txList.HasMore {
    // Fetch next page
}

Project Structure

paratro-sdk-go/
├── client.go           # HTTP client, error types, service infrastructure
├── config.go           # Environment configuration
├── token.go            # JWT token management
├── wallet.go           # Wallet API
├── account.go          # Account API
├── asset.go            # Asset API
├── transaction.go      # Transaction API
├── transfer.go         # Transfer API
└── docs/               # Documentation