home / skills / multiversx / mx-ai-skills / mvx_sdk_go_interactors

mvx_sdk_go_interactors skill

/antigravity/skills/mvx_sdk_go_interactors

This skill simplifies blockchain integration in Go by providing wallet management, nonce handling, and transaction interactor utilities for secure key handling

npx playbooks add skill multiversx/mx-ai-skills --skill mvx_sdk_go_interactors

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.9 KB
---
name: mvx_sdk_go_interactors
description: Components for interacting with the blockchain (Wallets, Transaction Interactors, Nonce Handlers) in Go.
---

# MultiversX SDK-Go Interactors

## Wallet Management

Loading keys and addresses.

```go
import "github.com/multiversx/mx-sdk-go/interactors"

wallet := interactors.NewWallet()

// Load PEM
privateKey, err := wallet.LoadPrivateKeyFromPemFile("wallet.pem")

// Load Keystore
privateKey, err := wallet.LoadPrivateKeyFromKeystoreFile("wallet.json", "password")

// Get Address
address, err := wallet.GetAddressFromPrivateKey(privateKey)
bech32Address := address.AddressAsBech32String()
```

## Transaction Nonce Handler (V3)

Automatically fetches and increments nonces. Recommended way to manage nonces.

```go
import "github.com/multiversx/mx-sdk-go/interactors/nonceHandlerV3"

// Initialize Handler
args := nonceHandlerV3.ArgsAddressNonceHandler{
    Proxy: proxy,
    Address: address,
}
handler, err := nonceHandlerV3.NewAddressNonceHandler(args)

// Fetch Initial Nonce
nonce, err := handler.GetNonce(ctx)

// Apply Nonce to Transaction & Increment
handler.ApplyNonceAndGasPrice(tx) // Sets tx.Nonce = current, then increments internal counter
```

## Transaction Interactor

High-level wrapper for sending transactions.

```go
import "github.com/multiversx/mx-sdk-go/interactors"

// Setup
txInteractor, err := interactors.NewTransactionInteractor(proxy, txBuilder)

// Send Transaction
txHash, err := txInteractor.SendTransaction(ctx, tx, privateKey)

// Send Multiple Transactions
txHashes, err := txInteractor.SendTransactions(ctx, txs, privateKey)
```

## Creating a Wallet Instance

```go
// Helper to create new keypair
privateKey, publicKey := wallet.GeneratePrivateKey()
```

## Best Practices

1. **Use NonceHandlerV3** for robust nonce management, especially in concurrent environments
2. **Use TransactionInteractor** to simplify signing + sending flow
3. **Secure Key Management** - avoid hardcoding private keys

Overview

This skill provides Go components for interacting with the MultiversX blockchain: wallet utilities, transaction interactors, and nonce handlers. It bundles secure key loading and generation, a robust nonce handler (V3) for concurrent scenarios, and a high-level transaction interactor to sign and send transactions. The focus is on simplifying common blockchain tasks while encouraging safe key and nonce management.

How this skill works

The wallet component loads private keys from PEM or keystore files, generates keypairs, and derives addresses in Bech32 format. The nonce handler (V3) fetches the current on-chain nonce for an address, maintains an internal counter, and can apply and increment nonces to transactions to avoid collisions. The transaction interactor wraps signing and network submission, supporting single or batch sends and returning transaction hashes.

When to use it

  • When you need to load or generate wallet keys and derive Bech32 addresses in Go.
  • When sending signed transactions and you want a simple sign-and-send API.
  • When running concurrent transaction submissions from the same address and you need reliable nonce handling.
  • When batching multiple transactions and needing consistent signing plus submission.
  • When you want to replace manual RPC nonce fetch + increment logic with a tested handler.

Best practices

  • Use the NonceHandlerV3 for production or concurrent flows to avoid nonce reuse and failed transactions.
  • Use TransactionInteractor to centralize signing and network submission logic to reduce errors.
  • Never hardcode private keys; load them from encrypted keystore files or secure stores.
  • Fetch the initial nonce via the handler and rely on ApplyNonceAndGasPrice to increment safely.
  • Handle and log transaction hashes for reconciliation and retry logic when needed.

Example use cases

  • A high-throughput payment service that submits many transactions concurrently from the same address.
  • A CLI tool that loads a keystore, builds a transaction, signs it, and broadcasts it to a proxy.
  • A batch token transfer job that constructs multiple transactions, signs them, and collects hashes.
  • A backend service that generates ephemeral keypairs for short-lived operations and derives addresses.

FAQ

How do I avoid nonce collisions when sending many transactions?

Use the NonceHandlerV3: it fetches the current on-chain nonce, applies it to each transaction, and increments an internal counter to prevent reuse.

Can I load keys from keystore files securely?

Yes. Load encrypted keystore files with the wallet loader and provide the password; avoid storing passwords or keys in source code.