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.

All wallet operations require an active wallet session. The TypeScript SDK uses Networks entries from @0xsequence/typescript-sdk for network arguments and viem-compatible EVM values for addresses, calldata, ABI definitions, and bigint amounts.
if (!oms.wallet.walletAddress) {
  throw new Error('No active wallet session')
}

Supported Networks

Use the SDK network registry when passing network to wallet and indexer calls.
import {
  Networks,
  findNetworkById,
  findNetworkByName,
  supportedNetworks,
} from '@0xsequence/typescript-sdk'

const amoy = findNetworkById(80002) ?? Networks.amoy
const polygon = findNetworkByName('polygon')

console.log(amoy.displayName, polygon?.id)

for (const network of supportedNetworks) {
  console.log(network.id, network.displayName, network.nativeTokenSymbol)
}
Parameters findNetworkById takes a numeric chain ID. findNetworkByName takes a registry name such as polygon, amoy, or base-sepolia. Returns Networks is the named network registry. supportedNetworks returns every Network supported by the SDK build. findNetworkById and findNetworkByName return a Network or undefined.

Send A Transaction

sendTransaction sends native tokens when you pass to and value. Values are raw base-unit bigint values.
import { Networks } from '@0xsequence/typescript-sdk'
import { parseEther, type Address } from 'viem'

const recipient = '0xRecipient' as Address

const tx = await oms.wallet.sendTransaction({
  network: Networks.amoy,
  to: recipient,
  value: parseEther('0.01'),
})

console.log(tx.txnHash ?? tx.txnId)
Parameters
ParameterTypeDescription
networkNetworkSDK network entry, such as Networks.polygon or Networks.amoy.
toAddressRecipient address or contract address.
valuebigint or undefinedRaw base-unit native token value. Required for native transfers and optional for calldata or ABI transactions.
dataHex or undefinedEncoded calldata for raw calldata transactions.
abiAbi, readonly array, or undefinedviem-compatible ABI for ABI transactions.
functionNameContractFunctionNameABI function name when abi is provided.
argsABI-derived tupleFunction arguments when abi is provided.
modeTransactionMode or undefinedTransaction mode. Defaults to TransactionMode.Relayer.
selectFeeOptionFeeOptionSelector or undefinedOptional callback for selecting a fee option.
waitForStatusboolean or undefinedSet to false to return after execution without polling transaction status.
statusPollingTransactionStatusPollingOptions or undefinedPolling timeout and interval overrides.
Returns Returns Promise<SendTransactionResponse>.
FieldTypeDescription
txnIdstringWallet transaction ID.
statusTransactionStatusLatest transaction status returned by OMS Wallet.
txnHashstring or undefinedOn-chain transaction hash when available.

Send Raw Calldata

Use data when you already have encoded calldata.
import { Networks } from '@0xsequence/typescript-sdk'
import type { Address, Hex } from 'viem'

const tokenContract = '0xTokenContract' as Address
const calldata = '0xa9059cbb000000000000000000000000...' as Hex

const tx = await oms.wallet.sendTransaction({
  network: Networks.amoy,
  to: tokenContract,
  value: 0n,
  data: calldata,
})

console.log('Contract transaction:', tx.txnHash ?? tx.txnId)
Parameters Use the same sendTransaction parameters. Returns Returns Promise<SendTransactionResponse>.

Call A Contract With An ABI

Pass a viem-compatible ABI, function name, and args. The SDK uses viem to encode calldata.
import { Networks } from '@0xsequence/typescript-sdk'
import { parseUnits, type Abi, type Address } from 'viem'

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

const tokenContract = '0xTokenContract' as Address
const recipient = '0xRecipient' as Address
const amount = parseUnits('1', 6)

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

console.log('Contract transaction:', tx.txnHash ?? tx.txnId)
Parameters Use the same sendTransaction parameters. Returns Returns Promise<SendTransactionResponse>.

Call A Contract With Method And Args

The wallet client also exposes callContract for method-string calls.
import { Networks } from '@0xsequence/typescript-sdk'
import { parseUnits, type Address } from 'viem'

const tokenContract = '0xTokenContract' as Address
const recipient = '0xRecipient' as Address
const amount = parseUnits('1', 6)

const tx = await oms.wallet.callContract({
  network: Networks.amoy,
  contractAddress: tokenContract,
  method: 'transfer(address,uint256)',
  args: [
    { type: 'address', value: recipient },
    { type: 'uint256', value: amount.toString() },
  ],
})

console.log('Contract transaction:', tx.txnHash ?? tx.txnId)
Parameters
ParameterTypeDescription
networkNetworkSDK network entry, such as Networks.polygon or Networks.amoy.
contractAddressAddressContract address to call.
methodstringABI method signature, such as transfer(address,uint256).
argsAbiArg[] or undefinedMethod arguments as Wallet API ABI args.
modeTransactionMode or undefinedTransaction mode. Defaults to TransactionMode.Relayer.
selectFeeOptionFeeOptionSelector or undefinedOptional callback for selecting a fee option.
waitForStatusboolean or undefinedSet to false to return after execution without polling transaction status.
statusPollingTransactionStatusPollingOptions or undefinedPolling timeout and interval overrides.
Returns Returns Promise<SendTransactionResponse>.

Select A Fee Option

When OMS Wallet returns fee options, pass selectFeeOption. The selector receives fee options enriched with the wallet balance for each token when available. On testnets, fee options are automatically sponsored, so you usually do not need to choose a fee token.
import { Networks } from '@0xsequence/typescript-sdk'
import type { Address } from 'viem'

const recipient = '0xRecipient' as Address

const tx = await oms.wallet.sendTransaction({
  network: Networks.amoy,
  to: recipient,
  value: 0n,
  selectFeeOption: async (feeOptions) => {
    const usdc = feeOptions.find((option) => option.feeOption.token.symbol === 'USDC')
    return usdc ? { token: usdc.feeOption.token.symbol } : undefined
  },
})
If no selector is provided, the SDK uses the first required fee option, or no fee option for sponsored transactions. Parameters selectFeeOption receives FeeOptionWithBalance[]. Returns Return FeeOptionSelection, undefined, or a promise for either value.

Polling And Status

By default, sendTransaction executes and polls for transaction status.
import { Networks } from '@0xsequence/typescript-sdk'
import type { Address } from 'viem'

const recipient = '0xRecipient' as Address

const tx = await oms.wallet.sendTransaction({
  network: Networks.amoy,
  to: recipient,
  value: 1n,
  statusPolling: {
    timeoutMs: 30_000,
    intervalMs: 1_000,
  },
})
Return immediately after execution with waitForStatus: false, then fetch status later.
const tx = await oms.wallet.sendTransaction({
  network: Networks.amoy,
  to: recipient,
  value: 1n,
  waitForStatus: false,
})

const status = await oms.wallet.getTransactionStatus({ txnId: tx.txnId })
Parameters
ParameterTypeDescription
txnIdstringWallet transaction ID returned by sendTransaction or callContract.
Returns Returns Promise<TransactionStatusResponse>.
FieldTypeDescription
statusTransactionStatusLatest Wallet transaction status.
txnHashstring or undefinedOn-chain transaction hash when available.

Sign A Message

signMessage returns a hex-encoded signature for the active wallet.
import { Networks } from '@0xsequence/typescript-sdk'

const signature = await oms.wallet.signMessage({
  network: Networks.amoy,
  message: 'Hello from OMS',
})

console.log('Signature:', signature)
Parameters
ParameterTypeDescription
networkNetworkSDK network entry.
messagestringPlaintext message to sign.
Returns Returns Promise<string>, the hex-encoded signature.

Verify A Message Signature

isValidMessageSignature verifies a message signature against the wallet address or wallet ID you provide. If neither is provided, the active wallet session ID is used when available.
import { Networks } from '@0xsequence/typescript-sdk'

const isValid = await oms.wallet.isValidMessageSignature({
  network: Networks.amoy,
  walletAddress: oms.wallet.walletAddress,
  message: 'Hello from OMS',
  signature,
})

console.log('Signature valid:', isValid)
Parameters
ParameterTypeDescription
networkNetwork or undefinedSDK network entry.
walletAddressAddress or undefinedWallet address to verify the signature against.
walletIdstring or undefinedWallet ID to verify when walletAddress is not supplied.
messagestringOriginal plaintext message.
signaturestringHex-encoded signature to verify.
Returns Returns Promise<boolean>.

Sign Typed Data

Use signTypedData for EIP-712 typed data.
import { Networks } from '@0xsequence/typescript-sdk'

const typedData = {
  domain: {
    name: 'Example App',
    version: '1',
    chainId: 80002,
  },
  types: {
    Message: [{ name: 'contents', type: 'string' }],
  },
  primaryType: 'Message',
  message: {
    contents: 'Hello from OMS',
  },
}

const typedSignature = await oms.wallet.signTypedData({
  network: Networks.amoy,
  typedData,
})
Parameters
ParameterTypeDescription
networkNetworkSDK network entry.
typedDataanyEIP-712 typed-data payload.
Returns Returns Promise<string>, the hex-encoded signature.

Verify Typed Data

Verify an EIP-712 signature against the wallet address or wallet ID you provide.
const isTypedDataValid = await oms.wallet.isValidTypedDataSignature({
  network: Networks.amoy,
  walletAddress: oms.wallet.walletAddress,
  typedData,
  signature: typedSignature,
})
Parameters
ParameterTypeDescription
networkNetwork or undefinedSDK network entry.
walletAddressAddress or undefinedWallet address to verify the signature against.
walletIdstring or undefinedWallet ID to verify when walletAddress is not supplied.
typedDataanyOriginal EIP-712 typed-data payload.
signaturestringHex-encoded signature to verify.
Returns Returns Promise<boolean>.