Get wallet address
- TypeScript
- React Native
- Swift
- Kotlin
const address = oms.wallet.walletAddress
if (!address) {
throw new Error('No active wallet session')
}
console.log('Wallet address:', address)
const address = await oms.wallet.getWalletAddress()
if (!address) {
throw new Error('No active wallet session')
}
console.log('Wallet address:', address)
guard let address = oms.wallet.walletAddress else {
throw NSError(domain: "App", code: 1, userInfo: [NSLocalizedDescriptionKey: "No active wallet session"])
}
print("Wallet address:", address)
val address = requireNotNull(client.wallet.walletAddress) {
"No wallet selected"
}
println("Wallet address: $address")
Read balances
- TypeScript
- React Native
- Swift
- Kotlin
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)
}
const walletAddress = await oms.wallet.getWalletAddress()
if (!walletAddress) {
throw new Error('No active wallet session')
}
const polygon = oms.supportedNetworks.find((network) => network.chainId === '137')
if (!polygon) {
throw new Error('Polygon network unavailable')
}
const result = await oms.indexer.getBalances({
walletAddress,
networks: [polygon],
})
for (const balance of result.nativeBalances) {
console.log(balance.symbol, balance.balance)
}
guard let walletAddress = oms.wallet.walletAddress else {
throw NSError(domain: "App", code: 1, userInfo: [NSLocalizedDescriptionKey: "No active wallet session"])
}
let result = try await oms.indexer.getBalances(
GetBalancesParams(
walletAddress: walletAddress,
networks: [.polygon]
)
)
for balance in result.nativeBalances {
print(balance.symbol ?? "", balance.balance ?? "0")
}
import com.omsclient.kotlin_sdk.Network
val walletAddress = requireNotNull(client.wallet.walletAddress) {
"No wallet selected"
}
val result = client.indexer.getBalances(
walletAddress = walletAddress,
networks = listOf(Network.POLYGON),
)
for (balance in result.nativeBalances) {
println("${balance.symbol}: ${balance.balance}")
}
Send a stablecoin payment (USDC)
- TypeScript
- React Native
- Swift
- Kotlin
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)
import { parseUnits } from '@0xsequence/oms-react-native-sdk'
const amount = parseUnits('10', 6)
const tx = await oms.wallet.callContract({
chainId: '137',
contractAddress: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',
method: 'transfer(address,uint256)',
args: [
{ type: 'address', value: '0x1111111111111111111111111111111111111111' },
{ type: 'uint256', value: 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("0x1111111111111111111111111111111111111111")),
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("0x1111111111111111111111111111111111111111")),
AbiArg(type = "uint256", value = JsonPrimitive(amount.toString())),
),
)
println("Transaction id: ${tx.txnId}")
println("Transaction hash: ${tx.txnHash}")
Send encoded calldata
- TypeScript
- React Native
- Swift
- Kotlin
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)
const tx = await oms.wallet.sendTransaction({
chainId: '137',
to: '0x3333333333333333333333333333333333333333',
value: '0',
data: '0x...',
})
console.log('Transaction:', tx.txnHash ?? tx.txnId)
let tx = try await oms.wallet.sendTransaction(
network: .polygon,
request: SendTransactionRequest(
to: "0x3333333333333333333333333333333333333333",
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 = "0x3333333333333333333333333333333333333333",
value = BigInteger.ZERO,
data = "0x...",
),
)
println("Transaction id: ${tx.txnId}")
println("Transaction hash: ${tx.txnHash}")
Call a contract
- TypeScript
- React Native
- Swift
- Kotlin
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)
import { parseUnits } from '@0xsequence/oms-react-native-sdk'
const tx = await oms.wallet.callContract({
chainId: '137',
contractAddress: '0x3333333333333333333333333333333333333333',
method: 'transfer(address,uint256)',
args: [
{ type: 'address', value: '0x1111111111111111111111111111111111111111' },
{ type: 'uint256', value: parseUnits('10', 6) },
],
})
console.log('Transaction:', tx.txnHash ?? tx.txnId)
let tx = try await oms.wallet.callContract(
network: .polygon,
contract: "0x3333333333333333333333333333333333333333",
method: "transfer(address,uint256)",
args: [
AbiArg(type: "address", value: .string("0x1111111111111111111111111111111111111111")),
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 = "0x3333333333333333333333333333333333333333",
method = "transfer(address,uint256)",
args = listOf(
AbiArg(type = "address", value = JsonPrimitive("0x1111111111111111111111111111111111111111")),
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
- React Native
- 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)
const signature = await oms.wallet.signMessage(
'137',
'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
- React Native
- Swift
- Kotlin
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)
const walletAddress = await oms.wallet.getWalletAddress()
if (!walletAddress) {
throw new Error('No active wallet session')
}
const tx = await oms.wallet.callContract({
chainId: '137',
contractAddress: '0x4444444444444444444444444444444444444444',
method: 'safeTransferFrom(address,address,uint256)',
args: [
{ type: 'address', value: walletAddress },
{ type: 'address', value: '0x1111111111111111111111111111111111111111' },
{ type: 'uint256', value: '42' },
],
})
console.log('NFT transfer:', tx.txnHash ?? tx.txnId)
guard let walletAddress = oms.wallet.walletAddress else {
throw NSError(domain: "App", code: 1, userInfo: [NSLocalizedDescriptionKey: "No active wallet session"])
}
let tx = try await oms.wallet.callContract(
network: .polygon,
contract: "0x4444444444444444444444444444444444444444",
method: "safeTransferFrom(address,address,uint256)",
args: [
AbiArg(type: "address", value: .string(walletAddress)),
AbiArg(type: "address", value: .string("0x1111111111111111111111111111111111111111")),
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 = "0x4444444444444444444444444444444444444444",
method = "safeTransferFrom(address,address,uint256)",
args = listOf(
AbiArg(type = "address", value = JsonPrimitive(walletAddress)),
AbiArg(type = "address", value = JsonPrimitive("0x1111111111111111111111111111111111111111")),
AbiArg(type = "uint256", value = JsonPrimitive("42")),
),
)
println("NFT transfer: ${tx.txnHash ?: tx.txnId}")
Transaction receipts
- TypeScript
- React Native
- Swift
- Kotlin
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')
const tx = await oms.wallet.sendTransaction({
chainId: '137',
to: '0x1111111111111111111111111111111111111111',
value: '0',
})
console.log('Wallet transaction ID:', tx.txnId)
console.log('Onchain hash:', tx.txnHash ?? 'pending')
let tx = try await oms.wallet.sendTransaction(
network: .polygon,
to: "0x1111111111111111111111111111111111111111",
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 = "0x1111111111111111111111111111111111111111",
value = BigInteger.ZERO,
)
println("Wallet transaction ID: ${tx.txnId}")
println("Onchain hash: ${tx.txnHash ?: "pending"}")