The user operation receipt. DebugUserOperationReturnType
DebugUserOperationParameters
Prepares a user operation with token paymaster configuration, including ERC20 token approval
This function handles:
A prepared user operation without signature (will be signed by the Smart Account when sent)
const userOp = await prepareTokenPaymasterUserOp(nexusClient, {
txs: [
{
to: recipientAddress,
value: 1n,
data: "0x"
}
],
feeTokenAddress: baseSepoliaUSDCAddress,
customApprovalAmount: usdcFeeAmount
})
Will throw an error if client account or paymaster context is not properly configured
Prepares a user operation
The user operation. PrepareUserOperationReturnType
const userOp = await prepareUserOperation({
calls: [{to: '0x...', value: 1n, data: '0x...'}]
})
PrepareUserOperationParameters
Prepares and sends a user operation with token paymaster
const hash = await sendTokenPaymasterUserOp(client, {
calls: [{
to: "0x...", // Contract address
data: "0x...", // Encoded function data
value: BigInt(0)
}],
feeTokenAddress: "0x...", // USDC/USDT/etc address
customApprovalAmount: BigInt(1000) // Optional: specific approval amount
})
A promise that resolves to the user operation hash Hash
The parameters for the token paymaster user operation
Creates, signs, and sends a new transaction to the network using a smart account. This function also allows you to sponsor this transaction if the sender is a smart account.
The transaction hash as a hexadecimal string.
If the account is not found.
import { sendTransaction } from '@biconomy/sdk'
const hash = await nexusClient.sendTransaction({calls: [{to: '0x...', value: parseEther('0.1'), data: '0x...'}]})
console.log(hash) // '0x...'
Parameters for sending the transaction or user operation.
Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
.
personal_sign
With the calculated signature, you can:
verifyMessage
to verify the signature,recoverMessageAddress
to recover the signing address from a signature.The signed message. SignMessageReturnType
import { createWalletClient, custom } from 'viem'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum),
})
const signature = await client.signMessage({
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
message: 'hello world',
})
// Account Hoisting
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
account: privateKeyToAccount('0x…'),
chain: mainnet,
transport: http(),
})
const signature = await client.signMessage({
message: 'hello world',
})
SignMessageParameters
Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
.
eth_signTypedData_v4
The signed data. SignTypedDataReturnType
import { createWalletClient, custom } from 'viem'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum),
})
const signature = await client.signTypedData({
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
domain: {
name: 'Ether Mail',
version: '1',
chainId: 1,
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
},
types: {
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' },
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person' },
{ name: 'contents', type: 'string' },
],
},
primaryType: 'Mail',
message: {
from: {
name: 'Cow',
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
},
to: {
name: 'Bob',
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
},
contents: 'Hello, Bob!',
},
})
// Account Hoisting
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
account: privateKeyToAccount('0x…'),
chain: mainnet,
transport: http(),
})
const signature = await client.signTypedData({
domain: {
name: 'Ether Mail',
version: '1',
chainId: 1,
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
},
types: {
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' },
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person' },
{ name: 'contents', type: 'string' },
],
},
primaryType: 'Mail',
message: {
from: {
name: 'Cow',
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
},
to: {
name: 'Bob',
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
},
contents: 'Hello, Bob!',
},
})
SignTypedDataParameters
Executes a write function on a contract. This function also allows you to sponsor this transaction if sender is a smartAccount
A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state.
Internally, uses a Wallet Client to call the sendTransaction
action with ABI-encoded data
.
Warning: The write
internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate
before you execute it.
A Transaction Hash. WriteContractReturnType
import { createWalletClient, custom, parseAbi } from 'viem'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum),
})
const hash = await client.writeContract({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
functionName: 'mint',
args: [69420],
})
// With Validation
import { createWalletClient, custom, parseAbi } from 'viem'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum),
})
const { request } = await client.simulateContract({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
functionName: 'mint',
args: [69420],
}
const hash = await client.writeContract(request)
WriteContractParameters
Sends a user operation to the network and waits for the receipt.