Skip to main content
Once a user has signed in with a non-custodial wallet, your app can read balances, sign messages, and submit transactions, all without the user leaving your product. The examples below use the OMS Wallet SDKs.

Get wallet address

const address = oms.wallet.walletAddress

if (!address) {
  throw new Error('No active wallet session')
}

console.log('Wallet address:', address)

Read balances

import { Networks } from '@0xsequence/typescript-sdk'

const walletAddress = oms.wallet.walletAddress

if (!walletAddress) {
  throw new Error('No active wallet session')
}

const result = await oms.indexer.getBalances({
  walletAddress,
  networks: [Networks.polygon],
})

for (const balance of result.nativeBalances) {
  console.log(balance.symbol, balance.balance)
}

Send a stablecoin payment (USDC)

import { Networks } from '@0xsequence/typescript-sdk'
import { parseUnits, type Abi, type Address } from 'viem'

const usdcContract = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' as Address
const recipient = '0x1111111111111111111111111111111111111111' as Address
const amount = parseUnits('10', 6)

const erc20Abi = [
  {
    name: 'transfer',
    type: 'function',
    stateMutability: 'nonpayable',
    inputs: [
      { name: 'to', type: 'address' },
      { name: 'amount', type: 'uint256' },
    ],
    outputs: [{ type: 'bool' }],
  },
] as const satisfies Abi

const tx = await oms.wallet.sendTransaction({
  network: Networks.polygon,
  to: usdcContract,
  abi: erc20Abi,
  functionName: 'transfer',
  args: [recipient, amount],
})

console.log('Transaction:', tx.txnHash ?? tx.txnId)

Send encoded calldata

import { Networks } from '@0xsequence/typescript-sdk'
import type { Address, Hex } from 'viem'

const tx = await oms.wallet.sendTransaction({
  network: Networks.polygon,
  to: '0x3333333333333333333333333333333333333333' as Address,
  value: 0n,
  data: '0x...' as Hex,
})

console.log('Transaction:', tx.txnHash ?? tx.txnId)

Call a contract

import { Networks } from '@0xsequence/typescript-sdk'
import { parseUnits, type Abi, type Address } from 'viem'

const abi = [
  {
    name: 'transfer',
    type: 'function',
    stateMutability: 'nonpayable',
    inputs: [
      { name: 'to', type: 'address' },
      { name: 'amount', type: 'uint256' },
    ],
    outputs: [{ type: 'bool' }],
  },
] as const satisfies Abi

const tx = await oms.wallet.sendTransaction({
  network: Networks.polygon,
  to: '0x3333333333333333333333333333333333333333' as Address,
  abi,
  functionName: 'transfer',
  args: ['0x1111111111111111111111111111111111111111' as Address, parseUnits('10', 6)],
})

console.log('Transaction:', tx.txnHash ?? tx.txnId)

Sign a message

Used for authentication, consent flows, or off-chain verifications:
import { Networks } from '@0xsequence/typescript-sdk'

const signature = await oms.wallet.signMessage({
  network: Networks.polygon,
  message: 'I authorize this payment of 10 USDC',
})

console.log('Signature:', signature)

Send ERC-20, ERC-721, ERC-1155

Use standard ABI calls for token types that do not have dedicated helpers:
import { Networks } from '@0xsequence/typescript-sdk'
import type { Abi, Address } from 'viem'

const erc721Abi = [
  {
    name: 'safeTransferFrom',
    type: 'function',
    stateMutability: 'nonpayable',
    inputs: [
      { name: 'from', type: 'address' },
      { name: 'to', type: 'address' },
      { name: 'tokenId', type: 'uint256' },
    ],
    outputs: [],
  },
] as const satisfies Abi

const walletAddress = oms.wallet.walletAddress

if (!walletAddress) {
  throw new Error('No active wallet session')
}

const tx = await oms.wallet.sendTransaction({
  network: Networks.polygon,
  to: '0x4444444444444444444444444444444444444444' as Address,
  abi: erc721Abi,
  functionName: 'safeTransferFrom',
  args: [
    walletAddress as Address,
    '0x1111111111111111111111111111111111111111' as Address,
    42n,
  ],
})

console.log('NFT transfer:', tx.txnHash ?? tx.txnId)

Transaction receipts

import { Networks } from '@0xsequence/typescript-sdk'
import type { Address } from 'viem'

const tx = await oms.wallet.sendTransaction({
  network: Networks.polygon,
  to: '0x1111111111111111111111111111111111111111' as Address,
  value: 0n,
})

console.log('Wallet transaction ID:', tx.txnId)
console.log('Onchain hash:', tx.txnHash ?? 'pending')