Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt

Use this file to discover all available pages before exploring further.

Once a user has signed in with an embedded wallet, your app can read balances, sign messages, and submit transactions, all without the user leaving your product. The examples below use the active 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)

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 = '0xRecipient' as Address
const amount = parseUnits('10', 6)

const erc20Abi = [
  {
    name: 'transfer',
    type: 'function',
    inputs: [
      { name: 'to', type: 'address' },
      { name: 'amount', type: 'uint256' },
    ],
  },
] 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 a raw transaction

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

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

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

Call a contract by ABI

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

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

const tx = await oms.wallet.sendTransaction({
  network: Networks.polygon,
  to: '0xContractAddress' as Address,
  abi,
  functionName: 'transfer',
  args: ['0xRecipient' 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',
    inputs: [
      { name: 'from', type: 'address' },
      { name: 'to', type: 'address' },
      { name: 'tokenId', type: 'uint256' },
    ],
  },
] as const satisfies Abi

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

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

Gas sponsorship

By default, users pay their own gas in MATIC. To avoid prompting users for gas, sponsor it via the Sequence Gas Tank in Builder. Sponsored transactions submit without prompting the user for gas. See fee options on the Sequence docs for configuration.

Transaction receipts

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

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

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