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
| Parameter | Type | Description |
|---|
network | Network | SDK network entry, such as Networks.polygon or Networks.amoy. |
to | Address | Recipient address or contract address. |
value | bigint or undefined | Raw base-unit native token value. Required for native transfers and optional for calldata or ABI transactions. |
data | Hex or undefined | Encoded calldata for raw calldata transactions. |
abi | Abi, readonly array, or undefined | viem-compatible ABI for ABI transactions. |
functionName | ContractFunctionName | ABI function name when abi is provided. |
args | ABI-derived tuple | Function arguments when abi is provided. |
mode | TransactionMode or undefined | Transaction mode. Defaults to TransactionMode.Relayer. |
selectFeeOption | FeeOptionSelector or undefined | Optional callback for selecting a fee option. |
waitForStatus | boolean or undefined | Set to false to return after execution without polling transaction status. |
statusPolling | TransactionStatusPollingOptions or undefined | Polling timeout and interval overrides. |
Returns
Returns Promise<SendTransactionResponse>.
| Field | Type | Description |
|---|
txnId | string | Wallet transaction ID. |
status | TransactionStatus | Latest transaction status returned by OMS Wallet. |
txnHash | string or undefined | On-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
| Parameter | Type | Description |
|---|
network | Network | SDK network entry, such as Networks.polygon or Networks.amoy. |
contractAddress | Address | Contract address to call. |
method | string | ABI method signature, such as transfer(address,uint256). |
args | AbiArg[] or undefined | Method arguments as Wallet API ABI args. |
mode | TransactionMode or undefined | Transaction mode. Defaults to TransactionMode.Relayer. |
selectFeeOption | FeeOptionSelector or undefined | Optional callback for selecting a fee option. |
waitForStatus | boolean or undefined | Set to false to return after execution without polling transaction status. |
statusPolling | TransactionStatusPollingOptions or undefined | Polling 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
| Parameter | Type | Description |
|---|
txnId | string | Wallet transaction ID returned by sendTransaction or callContract. |
Returns
Returns Promise<TransactionStatusResponse>.
| Field | Type | Description |
|---|
status | TransactionStatus | Latest Wallet transaction status. |
txnHash | string or undefined | On-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
| Parameter | Type | Description |
|---|
network | Network | SDK network entry. |
message | string | Plaintext 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
| Parameter | Type | Description |
|---|
network | Network or undefined | SDK network entry. |
walletAddress | Address or undefined | Wallet address to verify the signature against. |
walletId | string or undefined | Wallet ID to verify when walletAddress is not supplied. |
message | string | Original plaintext message. |
signature | string | Hex-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
| Parameter | Type | Description |
|---|
network | Network | SDK network entry. |
typedData | any | EIP-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
| Parameter | Type | Description |
|---|
network | Network or undefined | SDK network entry. |
walletAddress | Address or undefined | Wallet address to verify the signature against. |
walletId | string or undefined | Wallet ID to verify when walletAddress is not supplied. |
typedData | any | Original EIP-712 typed-data payload. |
signature | string | Hex-encoded signature to verify. |
Returns
Returns Promise<boolean>.