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.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.
Get wallet address
- TypeScript
- Swift
- Kotlin
const address = oms.wallet.walletAddress
if (!address) {
throw new Error('No active wallet session')
}
console.log('Wallet address:', address)
let address = oms.wallet.walletAddress
precondition(!address.isEmpty, "No active wallet session")
print("Wallet address:", address)
val address = requireNotNull(client.wallet.walletAddress) {
"No wallet selected"
}
println("Wallet address: $address")
Send a stablecoin payment (USDC)
- TypeScript
- Swift
- Kotlin
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)
let amount = try parseUnits(value: "10", decimals: 6)
let tx = try await oms.wallet.callContract(
network: .polygon,
contract: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
method: "transfer(address,uint256)",
args: [
AbiArg(type: "address", value: .string("0xRecipient")),
AbiArg(type: "uint256", value: .string(amount))
]
)
print("Transaction:", tx.txnHash ?? tx.txnId)
import com.omsclient.kotlin_sdk.Network
import com.omsclient.kotlin_sdk.models.AbiArg
import com.omsclient.kotlin_sdk.utils.parseUnits
import kotlinx.serialization.json.JsonPrimitive
val amount = parseUnits("10", 6)
val tx = client.wallet.callContract(
network = Network.POLYGON,
contract = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
method = "transfer(address,uint256)",
args = listOf(
AbiArg(type = "address", value = JsonPrimitive("0xRecipient")),
AbiArg(type = "uint256", value = JsonPrimitive(amount.toString())),
),
)
println("Transaction id: ${tx.txnId}")
println("Transaction hash: ${tx.txnHash}")
Send a raw transaction
- TypeScript
- Swift
- Kotlin
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)
let tx = try await oms.wallet.sendTransaction(
network: .polygon,
request: SendTransactionRequest(
to: "0xContractAddress",
value: "0",
data: "0x..."
)
)
print("Transaction:", tx.txnHash ?? tx.txnId)
import com.omsclient.kotlin_sdk.Network
import com.omsclient.kotlin_sdk.models.SendTransactionRequest
import java.math.BigInteger
val tx = client.wallet.sendTransaction(
network = Network.POLYGON,
request = SendTransactionRequest(
to = "0xContractAddress",
value = BigInteger.ZERO,
data = "0x...",
),
)
println("Transaction id: ${tx.txnId}")
println("Transaction hash: ${tx.txnHash}")
Call a contract by ABI
- TypeScript
- Swift
- Kotlin
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)
let tx = try await oms.wallet.callContract(
network: .polygon,
contract: "0xContractAddress",
method: "transfer(address,uint256)",
args: [
AbiArg(type: "address", value: .string("0xRecipient")),
AbiArg(type: "uint256", value: .string("10000000"))
]
)
print("Transaction:", tx.txnHash ?? tx.txnId)
import com.omsclient.kotlin_sdk.Network
import com.omsclient.kotlin_sdk.models.AbiArg
import kotlinx.serialization.json.JsonPrimitive
val tx = client.wallet.callContract(
network = Network.POLYGON,
contract = "0xContractAddress",
method = "transfer(address,uint256)",
args = listOf(
AbiArg(type = "address", value = JsonPrimitive("0xRecipient")),
AbiArg(type = "uint256", value = JsonPrimitive("10000000")),
),
)
println("Transaction id: ${tx.txnId}")
println("Transaction hash: ${tx.txnHash}")
Sign a message
Used for authentication, consent flows, or off-chain verifications:- TypeScript
- Swift
- Kotlin
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)
let signature = try await oms.wallet.signMessage(
network: .polygon,
message: "I authorize this payment of 10 USDC"
)
print("Signature:", signature)
import com.omsclient.kotlin_sdk.Network
val signature = client.wallet.signMessage(
network = Network.POLYGON,
message = "I authorize this payment of 10 USDC",
)
println("Signature: $signature")
Send ERC-20, ERC-721, ERC-1155
Use standard ABI calls for token types that do not have dedicated helpers:- TypeScript
- Swift
- Kotlin
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)
let tx = try await oms.wallet.callContract(
network: .polygon,
contract: "0xNFTContractAddress",
method: "safeTransferFrom(address,address,uint256)",
args: [
AbiArg(type: "address", value: .string(oms.wallet.walletAddress)),
AbiArg(type: "address", value: .string("0xRecipient")),
AbiArg(type: "uint256", value: .string("42"))
]
)
print("NFT transfer:", tx.txnHash ?? tx.txnId)
import com.omsclient.kotlin_sdk.Network
import com.omsclient.kotlin_sdk.models.AbiArg
import kotlinx.serialization.json.JsonPrimitive
val walletAddress = requireNotNull(client.wallet.walletAddress) {
"No wallet selected"
}
val tx = client.wallet.callContract(
network = Network.POLYGON,
contract = "0xNFTContractAddress",
method = "safeTransferFrom(address,address,uint256)",
args = listOf(
AbiArg(type = "address", value = JsonPrimitive(walletAddress)),
AbiArg(type = "address", value = JsonPrimitive("0xRecipient")),
AbiArg(type = "uint256", value = JsonPrimitive("42")),
),
)
println("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
- TypeScript
- Swift
- Kotlin
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')
let tx = try await oms.wallet.sendTransaction(
network: .polygon,
to: "0xRecipient",
value: "0"
)
print("Wallet transaction ID:", tx.txnId)
print("Onchain hash:", tx.txnHash ?? "pending")
import com.omsclient.kotlin_sdk.Network
import java.math.BigInteger
val tx = client.wallet.sendTransaction(
network = Network.POLYGON,
to = "0xRecipient",
value = BigInteger.ZERO,
)
println("Wallet transaction ID: ${tx.txnId}")
println("Onchain hash: ${tx.txnHash ?: "pending"}")