Skip to content

Wallet SDK Examples

Creating a wallet

import { Wallet, rostrumProvider } from 'nexa-wallet-sdk'

// Connect to the default mainnet node
await rostrumProvider.connect()

// Connect to a specific network (mainnet or testnet)
await rostrumProvider.connect('testnet')  // Uses predefined testnet node
await rostrumProvider.connect('mainnet')  // Uses predefined mainnet node

// Connect to a custom node (ignores network parameter)
await rostrumProvider.connect({
    host: 'your-custom-node.example.com',
    port: 30004,
    scheme: 'wss' // or 'ws' for unencrypted connection
})

// Create wallet from seed phrase
const wallet = new Wallet(
    'your twelve word seed phrase goes here for wallet creation',
    'testnet' // or 'mainnet'
)

// Initialize wallet to discover accounts
await wallet.initialize()

// Get the default account
const account = wallet.accountStore.getAccount('1.0')

Creating a Transaction

// Send 100 NEXA
const tx = await wallet.newTransaction(account)
    .onNetwork('testnet')
    .sendTo('nexatest:nqtsq5g5jsdmqqywaqd82lhnnk3a8wqunjz6gtxdtavnnekc', '10000')
    .populate()
    .sign()
    .build()

console.log('Transaction:', tx)

More Examples

More examples using the typescript wallet sdk can be found here: Typescript Wallet SDK