Skip to main content

Module: actions

Enumerations​

Type Aliases​

GetRestakeGasFeeParams​

Ƭ GetRestakeGasFeeParams: Object

Type declaration​

NameType
clientClient
contractAddressAddress
indexnumber
stakeTimenumber
tokenAmountbigint
userAddressAddress

Defined in​

src/actions/sDysn/restake.ts:13


GetStakeGasFeeParams​

Ƭ GetStakeGasFeeParams: PrepareStakeParams & { client: Client ; contractAddress: Address ; userAddress: Address }

Defined in​

src/actions/sDysn/stake.ts:8


GetUnstakeGasParams​

Ƭ GetUnstakeGasParams: { client: Client ; contractAddress: Address ; userAddress: Address } & PrepareUnstakeParams

Defined in​

src/actions/sDysn/redeem.ts:8


PrepareRestakeParams​

Ƭ PrepareRestakeParams: Object

Type declaration​

NameType
indexnumber
stakeTimenumber
tokenAmountbigint

Defined in​

src/actions/sDysn/restake.ts:7


PrepareStakeParams​

Ƭ PrepareStakeParams: Object

Type declaration​

NameType
stakeTimenumber
toAddress
tokenAmountbigint

Defined in​

src/actions/sDysn/stake.ts:7


PrepareUnstakeParams​

Ƭ PrepareUnstakeParams: Object

Type declaration​

NameType
indexnumber
sDYSNAmountbigint
toAddress

Defined in​

src/actions/sDysn/redeem.ts:7

Functions​

buildReferralCode​

▸ buildReferralCode(referralCode): string

Parameters​

NameType
referralCodePick<IReferralCodeItem, "parentSig" | "onceKey" | "deadline">

Returns​

string

Defined in​

src/actions/agency/referralCode.ts:4


getParentNodeAddressByReferralCode​

▸ getParentNodeAddressByReferralCode(chainId, parentSig, onceKey, deadline, agencyContractAddress): Promise<{ onceAddress: Address ; parentAddress: Address }>

Parameters​

NameType
chainIdChainId
parentSigstring
onceKeystring
deadlinestring
agencyContractAddressstring

Returns​

Promise<{ onceAddress: Address ; parentAddress: Address }>

Defined in​

src/actions/agency/register.ts:143


getRestakeGasFee​

▸ getRestakeGasFee(«destructured»): Promise<bigint>

Parameters​

NameType
«destructured»GetRestakeGasFeeParams

Returns​

Promise<bigint>

Defined in​

src/actions/sDysn/restake.ts:22


getStakeGasFee​

▸ getStakeGasFee(«destructured»): Promise<bigint>

Parameters​

NameType
«destructured»GetStakeGasFeeParams

Returns​

Promise<bigint>

Defined in​

src/actions/sDysn/stake.ts:13


getStakeGasFeeWithRouter​

▸ getStakeGasFeeWithRouter(«destructured»): Promise<bigint>

Parameters​

NameType
«destructured»GetStakeGasFeeParams

Returns​

Promise<bigint>

Defined in​

src/actions/sDysn/stake.ts:38


getUnstakeGasFee​

▸ getUnstakeGasFee(«destructured»): Promise<bigint>

Parameters​

NameType
«destructured»GetUnstakeGasParams

Returns​

Promise<bigint>

Defined in​

src/actions/sDysn/redeem.ts:14


isReferral​

▸ isReferral(input): input is Object

Parameters​

NameType
inputfalse | EXPIRED_REFERRAL_CODE | INVALID_INPUT | { onceAddress: `0x${string}` ; parentAddress: `0x${string}` }

Returns​

input is Object

Defined in​

src/actions/agency/register.ts:75


parseReferralCode​

▸ parseReferralCode(referralCodeString): Object

Parameters​

NameType
referralCodeStringstring

Returns​

Object

NameType
deadlinenull | string
onceKeynull | string
parentSignull | string

Defined in​

src/actions/agency/referralCode.ts:14


prepareAddBribeReward​

▸ prepareAddBribeReward(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "token" = 'token'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "week" = 'week'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; name: "addReward" = 'addReward'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.amountbigint-
args.token`0x${string}`-
args.weekbigint-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "token" = 'token'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "week" = 'week'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; name: "addReward" = 'addReward'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/bribe/addBribeReward.ts:6


prepareApproveToken​

▸ prepareApproveToken(client, args): Object

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.allowancebigint-
args.spenderAddress`0x${string}`-

Returns​

Object

NameTypeDescription
abi[{ constant: false = false; inputs: readonly [{ name: "_spender" = '_spender'; type: "address" = 'address' }, { name: "_value" = '_value'; type: "uint256" = 'uint256' }] ; name: "approve" = 'approve'; outputs: readonly [{ name: "" = ''; type: "bool" = 'bool' }] ; payable: false = false; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }]-
argsreadonly [`0x${string}`, bigint]Arguments to pass contract method
enabledboolean-
functionName"approve"-

Defined in​

src/actions/tokens/approveToken.ts:6


prepareClaimBribe​

▸ prepareClaimBribe(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "token" = 'token'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "week" = 'week'; type: "uint256" = 'uint256' }] ; name: "claimReward" = 'claimReward'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.token`0x${string}`-
args.weekbigint-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "token" = 'token'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "week" = 'week'; type: "uint256" = 'uint256' }] ; name: "claimReward" = 'claimReward'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/bribe/claimBribe.ts:44


prepareClaimBribeMatrix​

▸ prepareClaimBribeMatrix(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address[]" = 'address[]'; name: "token" = 'token'; type: "address[]" = 'address[]' }, { internalType: "uint256[][]" = 'uint256[][]'; name: "week" = 'week'; type: "uint256[][]" = 'uint256[][]' }] ; name: "claimRewardsMultipleTokens" = 'claimRewardsMultipleTokens'; outputs: readonly [{ internalType: "uint256[]" = 'uint256[]'; name: "amount" = 'amount'; type: "uint256[]" = 'uint256[]' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.tokenList`0x${string}`[]-
args.weekMatrixbigint[][]-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address[]" = 'address[]'; name: "token" = 'token'; type: "address[]" = 'address[]' }, { internalType: "uint256[][]" = 'uint256[][]'; name: "week" = 'week'; type: "uint256[][]" = 'uint256[][]' }] ; name: "claimRewardsMultipleTokens" = 'claimRewardsMultipleTokens'; outputs: readonly [{ internalType: "uint256[]" = 'uint256[]'; name: "amount" = 'amount'; type: "uint256[]" = 'uint256[]' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/bribe/claimBribe.ts:6


prepareClaimBribeWeeks​

▸ prepareClaimBribeWeeks(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "token" = 'token'; type: "address" = 'address' }, { internalType: "uint256[]" = 'uint256[]'; name: "week" = 'week'; type: "uint256[]" = 'uint256[]' }] ; name: "claimRewards" = 'claimRewards'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.token`0x${string}`-
args.weeksbigint[]-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "token" = 'token'; type: "address" = 'address' }, { internalType: "uint256[]" = 'uint256[]'; name: "week" = 'week'; type: "uint256[]" = 'uint256[]' }] ; name: "claimRewards" = 'claimRewards'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/bribe/claimBribe.ts:25


prepareDexSwap​

▸ prepareDexSwap(client, args): Omit<ContractFunctionConfig, "address"> & { value?: bigint }

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsISwapParams-

Returns​

Omit<ContractFunctionConfig, "address"> & { value?: bigint }

Defined in​

src/actions/dex/dexSwap.ts:7


prepareGaugeApplyWithdraw​

▸ prepareGaugeApplyWithdraw(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; name: "applyWithdrawal" = 'applyWithdrawal'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.tokenAmountbigint-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; name: "applyWithdrawal" = 'applyWithdrawal'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/gauge/gaugeApplyWithdraw.ts:6


prepareGaugeDeposit​

▸ prepareGaugeDeposit(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }] ; name: "deposit" = 'deposit'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.addressTo`0x${string}`-
args.tokenAmountbigint-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }] ; name: "deposit" = 'deposit'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/gauge/gaugeDeposit.ts:7


prepareGaugeDepositWithRouter​

▸ prepareGaugeDepositWithRouter(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "gauge" = 'gauge'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }] ; name: "depositToGauge" = 'depositToGauge'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.addressTo`0x${string}`-
args.gaugeAddress`0x${string}`-
args.tokenAmountbigint-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "gauge" = 'gauge'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }] ; name: "depositToGauge" = 'depositToGauge'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/gauge/gaugeDeposit.ts:25


prepareGaugeWithdraw​

▸ prepareGaugeWithdraw(client): PrepareFunctionParamsReturnType<{ inputs: readonly [] = []; name: "withdraw" = 'withdraw'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [] = []; name: "withdraw" = 'withdraw'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/gauge/gaugeWithdraw.ts:6


prepareInvestmentDeposit​

▸ prepareInvestmentDeposit(client, args): Omit<ContractFunctionConfig, "address"> & { value?: bigint }

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsIDepositParams-

Returns​

Omit<ContractFunctionConfig, "address"> & { value?: bigint }

Defined in​

src/actions/dualInvestment/investmentDeposit.ts:7


prepareNoteWithdraw​

▸ prepareNoteWithdraw(client, args): Omit<ContractFunctionConfig, "address"> & { value?: bigint }

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.addressTo`0x${string}`-
args.isNativePoolboolean-
args.noteIndexnumber-
args.pairAddress`0x${string}`-

Returns​

Omit<ContractFunctionConfig, "address"> & { value?: bigint }

Defined in​

src/actions/dualInvestment/noteWithdraw.ts:104


prepareNoteWithdrawForAll​

▸ prepareNoteWithdrawForAll(client, args): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address[]" = 'address[]'; name: "pairs" = 'pairs'; type: "address[]" = 'address[]' }, { internalType: "uint256[]" = 'uint256[]'; name: "indexes" = 'indexes'; type: "uint256[]" = 'uint256[]' }, { internalType: "address[]" = 'address[]'; name: "tos" = 'tos'; type: "address[]" = 'address[]' }] ; name: "withdrawMultiPositions" = 'withdrawMultiPositions'; outputs: readonly [{ internalType: "uint256[]" = 'uint256[]'; name: "token0Amounts" = 'token0Amounts'; type: "uint256[]" = 'uint256[]' }, { internalType: "uint256[]" = 'uint256[]'; name: "token1Amounts" = 'token1Amounts'; type: "uint256[]" = 'uint256[]' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.pairs{ address: `0x${string}` ; addressTo: `0x${string}` ; noteIndex: bigint }[]-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address[]" = 'address[]'; name: "pairs" = 'pairs'; type: "address[]" = 'address[]' }, { internalType: "uint256[]" = 'uint256[]'; name: "indexes" = 'indexes'; type: "uint256[]" = 'uint256[]' }, { internalType: "address[]" = 'address[]'; name: "tos" = 'tos'; type: "address[]" = 'address[]' }] ; name: "withdrawMultiPositions" = 'withdrawMultiPositions'; outputs: readonly [{ internalType: "uint256[]" = 'uint256[]'; name: "token0Amounts" = 'token0Amounts'; type: "uint256[]" = 'uint256[]' }, { internalType: "uint256[]" = 'uint256[]'; name: "token1Amounts" = 'token1Amounts'; type: "uint256[]" = 'uint256[]' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/dualInvestment/noteWithdraw.ts:139


prepareOneTimeCodes​

▸ prepareOneTimeCodes(onceAddress, agencyAddress): { abi: [{ inputs: readonly [{ internalType: "address" = 'address'; name: "" = ''; type: "address" = 'address' }] ; name: "oneTimeCodes" = 'oneTimeCodes'; outputs: readonly [{ internalType: "bool" = 'bool'; name: "" = ''; type: "bool" = 'bool' }] ; stateMutability: "view" = 'view'; type: "function" = 'function' }] ; address: `0x${string}` = agencyAddress; args: readonly [`0x${string}`] ; functionName: "oneTimeCodes" }[]

Parameters​

NameType
onceAddress`0x${string}`[]
agencyAddress`0x${string}`

Returns​

{ abi: [{ inputs: readonly [{ internalType: "address" = 'address'; name: "" = ''; type: "address" = 'address' }] ; name: "oneTimeCodes" = 'oneTimeCodes'; outputs: readonly [{ internalType: "bool" = 'bool'; name: "" = ''; type: "bool" = 'bool' }] ; stateMutability: "view" = 'view'; type: "function" = 'function' }] ; address: `0x${string}` = agencyAddress; args: readonly [`0x${string}`] ; functionName: "oneTimeCodes" }[]

Defined in​

src/actions/agency/register.ts:29


prepareRegister​

▸ prepareRegister(client, args): Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "bytes" = 'bytes'; name: "parentSig" = 'parentSig'; type: "bytes" = 'bytes' }, { internalType: "bytes" = 'bytes'; name: "onceSig" = 'onceSig'; type: "bytes" = 'bytes' }, { internalType: "uint256" = 'uint256'; name: "deadline" = 'deadline'; type: "uint256" = 'uint256' }] ; name: "register" = 'register'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "id" = 'id'; type: "uint256" = 'uint256' }] ; stateMutability: "payable" = 'payable'; type: "function" = 'function' }>>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.chainIdChainId-
args.contractAddress`0x${string}`-
args.deadlinenumber-
args.onceKey`0x${string}`-
args.parentSig`0x${string}`-

Returns​

Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "bytes" = 'bytes'; name: "parentSig" = 'parentSig'; type: "bytes" = 'bytes' }, { internalType: "bytes" = 'bytes'; name: "onceSig" = 'onceSig'; type: "bytes" = 'bytes' }, { internalType: "uint256" = 'uint256'; name: "deadline" = 'deadline'; type: "uint256" = 'uint256' }] ; name: "register" = 'register'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "id" = 'id'; type: "uint256" = 'uint256' }] ; stateMutability: "payable" = 'payable'; type: "function" = 'function' }>>

Defined in​

src/actions/agency/register.ts:42


prepareRestake​

▸ prepareRestake(«destructured»): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "uint256" = 'uint256'; name: "index" = 'index'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "lockDuration" = 'lockDuration'; type: "uint256" = 'uint256' }] ; name: "restake" = 'restake'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "sDysonAmountAdded" = 'sDysonAmountAdded'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameType
«destructured»PrepareRestakeParams

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "uint256" = 'uint256'; name: "index" = 'index'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "lockDuration" = 'lockDuration'; type: "uint256" = 'uint256' }] ; name: "restake" = 'restake'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "sDysonAmountAdded" = 'sDysonAmountAdded'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/sDysn/restake.ts:40


prepareSetApprovalForAll​

▸ prepareSetApprovalForAll(operator, approved): Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "operator" = 'operator'; type: "address" = 'address' }, { internalType: "bool" = 'bool'; name: "approved" = 'approved'; type: "bool" = 'bool' }] ; name: "setApprovalForAll" = 'setApprovalForAll'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>>

Parameters​

NameType
operator`0x${string}`
approvedboolean

Returns​

Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "operator" = 'operator'; type: "address" = 'address' }, { internalType: "bool" = 'bool'; name: "approved" = 'approved'; type: "bool" = 'bool' }] ; name: "setApprovalForAll" = 'setApprovalForAll'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>>

Description

This one use on Pair

Defined in​

src/actions/dualInvestment/noteWithdraw.ts:58


prepareSetApprovalForAllWithSig​

▸ prepareSetApprovalForAllWithSig(client, args): Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "pair" = 'pair'; type: "address" = 'address' }, { internalType: "bool" = 'bool'; name: "approved" = 'approved'; type: "bool" = 'bool' }, { internalType: "uint256" = 'uint256'; name: "deadline" = 'deadline'; type: "uint256" = 'uint256' }, { internalType: "bytes" = 'bytes'; name: "sig" = 'sig'; type: "bytes" = 'bytes' }] ; name: "setApprovalForAllWithSig" = 'setApprovalForAllWithSig'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
argsObject-
args.approvedboolean-
args.deadlinebigint-
args.noncebigint-
args.operator`0x${string}`-
args.owner`0x${string}`-
args.pairAddress`0x${string}`-

Returns​

Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "pair" = 'pair'; type: "address" = 'address' }, { internalType: "bool" = 'bool'; name: "approved" = 'approved'; type: "bool" = 'bool' }, { internalType: "uint256" = 'uint256'; name: "deadline" = 'deadline'; type: "uint256" = 'uint256' }, { internalType: "bytes" = 'bytes'; name: "sig" = 'sig'; type: "bytes" = 'bytes' }] ; name: "setApprovalForAllWithSig" = 'setApprovalForAllWithSig'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>>

Description

This one use on Router

Defined in​

src/actions/dualInvestment/noteWithdraw.ts:68


prepareSign​

▸ prepareSign(parentSig): Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "bytes32" = 'bytes32'; name: "digest" = 'digest'; type: "bytes32" = 'bytes32' }] ; name: "sign" = 'sign'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>>

Parameters​

NameType
parentSig`0x${string}`

Returns​

Promise<PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "bytes32" = 'bytes32'; name: "digest" = 'digest'; type: "bytes32" = 'bytes32' }] ; name: "sign" = 'sign'; outputs: readonly [] = []; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>>

Desc

This only used on contract wallet

Defined in​

src/actions/agency/generateReferral.ts:45


prepareSpSwap​

▸ prepareSpSwap(client, account): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "user" = 'user'; type: "address" = 'address' }] ; name: "swap" = 'swap'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amountOut" = 'amountOut'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameTypeDescription
clientObject-
client.accountundefined | AccountThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }Toggle to enable eth_call multicall aggregation.
client.cacheTimenumberTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>-
client.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringA key for the client.
client.namestringA name for the client.
client.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
client.typestringThe type of client.
client.uidstringA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
account`0x${string}`-

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "user" = 'user'; type: "address" = 'address' }] ; name: "swap" = 'swap'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amountOut" = 'amountOut'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/farm/swapSp.ts:6


prepareStake​

▸ prepareStake(«destructured»): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "lockDuration" = 'lockDuration'; type: "uint256" = 'uint256' }] ; name: "stake" = 'stake'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "sDysonAmount" = 'sDysonAmount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameType
«destructured»PrepareStakeParams

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "lockDuration" = 'lockDuration'; type: "uint256" = 'uint256' }] ; name: "stake" = 'stake'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "sDysonAmount" = 'sDysonAmount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/sDysn/stake.ts:32


prepareStakeWithRouter​

▸ prepareStakeWithRouter(«destructured»): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "lockDuration" = 'lockDuration'; type: "uint256" = 'uint256' }] ; name: "stakeDyson" = 'stakeDyson'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "sDYSONAmount" = 'sDYSONAmount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameType
«destructured»PrepareStakeParams

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "lockDuration" = 'lockDuration'; type: "uint256" = 'uint256' }] ; name: "stakeDyson" = 'stakeDyson'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "sDYSONAmount" = 'sDYSONAmount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/sDysn/stake.ts:56


prepareUnstake​

▸ prepareUnstake(«destructured»): PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "index" = 'index'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "sDysonAmount" = 'sDysonAmount'; type: "uint256" = 'uint256' }] ; name: "unstake" = 'unstake'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Parameters​

NameType
«destructured»PrepareUnstakeParams

Returns​

PrepareFunctionParamsReturnType<{ inputs: readonly [{ internalType: "address" = 'address'; name: "to" = 'to'; type: "address" = 'address' }, { internalType: "uint256" = 'uint256'; name: "index" = 'index'; type: "uint256" = 'uint256' }, { internalType: "uint256" = 'uint256'; name: "sDysonAmount" = 'sDysonAmount'; type: "uint256" = 'uint256' }] ; name: "unstake" = 'unstake'; outputs: readonly [{ internalType: "uint256" = 'uint256'; name: "amount" = 'amount'; type: "uint256" = 'uint256' }] ; stateMutability: "nonpayable" = 'nonpayable'; type: "function" = 'function' }>

Defined in​

src/actions/sDysn/redeem.ts:32


signReferral​

▸ signReferral(client, chainId, agencyAddress, deadline, isUsedContractWallet?): Promise<{ deadline: number ; onceAddress: `0x${string}` ; onceKey: `0x${string}` ; parentSig: `0x${string}` }>

Parameters​

NameTypeDefault valueDescription
clientObjectundefined-
client.accountundefined | AccountundefinedThe Account of the Client.
client.addChain(args: AddChainParameters) => Promise<void>undefinedAdds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
client.batch?ObjectundefinedFlags for batch settings.
client.batch.multicall?boolean | { batchSize?: number ; wait?: number }undefinedToggle to enable eth_call multicall aggregation.
client.cacheTimenumberundefinedTime (in ms) that cached data will remain in memory.
client.chainundefined | ChainundefinedChain for the client.
client.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>undefinedDeploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts 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 hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
client.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<undefined | Chain, undefined | Account>>undefined-
client.getAddresses() => Promise<GetAddressesReturnType>undefinedReturns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
client.getChainId() => Promise<number>undefinedReturns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
client.getPermissions() => Promise<GetPermissionsReturnType>undefinedGets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
client.keystringundefinedA key for the client.
client.namestringundefinedA name for the client.
client.pollingIntervalnumberundefinedFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>undefinedPrepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
client.requestEIP1193RequestFn<WalletRpcSchema>undefinedRequest function wrapped with friendly error handling
client.requestAddresses() => Promise<RequestAddressesReturnType>undefinedRequests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
client.requestPermissions(args: { eth_accounts: Record<string, any> }) => Promise<RequestPermissionsReturnType>undefinedRequests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
client.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>undefinedSends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
client.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>undefinedCreates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // 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 hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
client.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>undefinedCalculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts 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', }) Example ts // 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', })
client.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>undefinedSigns a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // 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: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
client.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>undefinedSigns typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts 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!', }, }) Example ts // 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!', }, })
client.switchChain(args: SwitchChainParameters) => Promise<void>undefinedSwitch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
client.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>undefinedThe RPC transport
client.typestringundefinedThe type of client.
client.uidstringundefinedA unique ID for the client.
client.watchAsset(args: WatchAssetParams) => Promise<boolean>undefinedAdds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
client.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>undefinedExecutes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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. Example ts 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], }) Example ts // 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)
chainIdChainIdundefined-
agencyAddress`0x${string}`undefined-
deadlinenumberundefined-
isUsedContractWalletbooleanfalse-

Returns​

Promise<{ deadline: number ; onceAddress: `0x${string}` ; onceKey: `0x${string}` ; parentSig: `0x${string}` }>

Defined in​

src/actions/agency/generateReferral.ts:8


validateReferral​

▸ validateReferral(token, chainId, agencyContractAddress): Promise<false | EXPIRED_REFERRAL_CODE | INVALID_INPUT | { onceAddress: `0x${string}` ; parentAddress: `0x${string}` }>

Parameters​

NameType
tokenstring
chainIdChainId
agencyContractAddress`0x${string}`

Returns​

Promise<false | EXPIRED_REFERRAL_CODE | INVALID_INPUT | { onceAddress: `0x${string}` ; parentAddress: `0x${string}` }>

Defined in​

src/actions/agency/register.ts:83