Module: actions
Enumerations
Type Aliases
GetRestakeGasFeeParams
Ƭ GetRestakeGasFeeParams: Object
Type declaration
Name | Type |
---|---|
client | Client |
contractAddress | Address |
index | number |
stakeTime | number |
tokenAmount | bigint |
userAddress | Address |
Defined in
src/actions/sDysn/restake.ts:13
GetStakeGasFeeParams
Ƭ GetStakeGasFeeParams: PrepareStakeParams
& { client
: Client
; contractAddress
: Address
; userAddress
: Address
}
Defined in
GetUnstakeGasParams
Ƭ GetUnstakeGasParams: { client
: Client
; contractAddress
: Address
; userAddress
: Address
} & PrepareUnstakeParams
Defined in
PrepareRestakeParams
Ƭ PrepareRestakeParams: Object
Type declaration
Name | Type |
---|---|
index | number |
stakeTime | number |
tokenAmount | bigint |
Defined in
src/actions/sDysn/restake.ts:7
PrepareStakeParams
Ƭ PrepareStakeParams: Object
Type declaration
Name | Type |
---|---|
stakeTime | number |
to | Address |
tokenAmount | bigint |
Defined in
PrepareUnstakeParams
Ƭ PrepareUnstakeParams: Object
Type declaration
Name | Type |
---|---|
index | number |
sDYSNAmount | bigint |
to | Address |
Defined in
Functions
buildReferralCode
▸ buildReferralCode(referralCode
): string
Parameters
Name | Type |
---|---|
referralCode | Pick <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
Name | Type |
---|---|
chainId | ChainId |
parentSig | string |
onceKey | string |
deadline | string |
agencyContractAddress | string |
Returns
Promise
<{ onceAddress
: Address
; parentAddress
: Address
}>
Defined in
src/actions/agency/register.ts:143
getRestakeGasFee
▸ getRestakeGasFee(«destructured»
): Promise
<bigint
>
Parameters
Name | Type |
---|---|
«destructured» | GetRestakeGasFeeParams |
Returns
Promise
<bigint
>
Defined in
src/actions/sDysn/restake.ts:22
getStakeGasFee
▸ getStakeGasFee(«destructured»
): Promise
<bigint
>
Parameters
Name | Type |
---|---|
«destructured» | GetStakeGasFeeParams |
Returns
Promise
<bigint
>
Defined in
getStakeGasFeeWithRouter
▸ getStakeGasFeeWithRouter(«destructured»
): Promise
<bigint
>
Parameters
Name | Type |
---|---|
«destructured» | GetStakeGasFeeParams |
Returns
Promise
<bigint
>
Defined in
getUnstakeGasFee
▸ getUnstakeGasFee(«destructured»
): Promise
<bigint
>
Parameters
Name | Type |
---|---|
«destructured» | GetUnstakeGasParams |
Returns
Promise
<bigint
>
Defined in
src/actions/sDysn/redeem.ts:14
isReferral
▸ isReferral(input
): input is Object
Parameters
Name | Type |
---|---|
input | false | 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
Name | Type |
---|---|
referralCodeString | string |
Returns
Object
Name | Type |
---|---|
deadline | null | string |
onceKey | null | string |
parentSig | null | 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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.amount | bigint | - |
args.token | `0x${string}` | - |
args.week | bigint | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.allowance | bigint | - |
args.spenderAddress | `0x${string}` | - |
Returns
Object
Name | Type | Description |
---|---|---|
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' }] | - |
args | readonly [`0x${string}`, bigint ] | Arguments to pass contract method |
enabled | boolean | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.token | `0x${string}` | - |
args.week | bigint | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.tokenList | `0x${string}`[] | - |
args.weekMatrix | bigint [][] | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.token | `0x${string}` | - |
args.weeks | bigint [] | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | ISwapParams | - |
Returns
Omit
<ContractFunctionConfig
, "address"
> & { value?
: bigint
}
Defined in
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.tokenAmount | bigint | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.addressTo | `0x${string}` | - |
args.tokenAmount | bigint | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.addressTo | `0x${string}` | - |
args.gaugeAddress | `0x${string}` | - |
args.tokenAmount | bigint | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | IDepositParams | - |
Returns
Omit
<ContractFunctionConfig
, "address"
> & { value?
: bigint
}
Defined in
src/actions/dualInvestment/investmentDeposit.ts:7
prepareNoteWithdraw
▸ prepareNoteWithdraw(client
, args
): Omit
<ContractFunctionConfig
, "address"
> & { value?
: bigint
}
Parameters
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.addressTo | `0x${string}` | - |
args.isNativePool | boolean | - |
args.noteIndex | number | - |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
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
Name | Type |
---|---|
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.chainId | ChainId | - |
args.contractAddress | `0x${string}` | - |
args.deadline | number | - |
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
Name | Type |
---|---|
«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
Name | Type |
---|---|
operator | `0x${string}` |
approved | boolean |
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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) |
args | Object | - |
args.approved | boolean | - |
args.deadline | bigint | - |
args.nonce | bigint | - |
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
Name | Type |
---|---|
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
Name | Type | Description |
---|---|---|
client | Object | - |
client.account | undefined | Account | The 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? | Object | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | Chain 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.key | string | A key for the client. |
client.name | string | A name for the client. |
client.pollingInterval | number | Frequency (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.request | EIP1193RequestFn <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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport |
client.type | string | The type of client. |
client.uid | string | A 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
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
Name | Type |
---|---|
«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
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
Name | Type |
---|---|
«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
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
Name | Type |
---|---|
«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
Name | Type | Default value | Description |
---|---|---|---|
client | Object | undefined | - |
client.account | undefined | Account | undefined | The Account of the Client. |
client.addChain | (args : AddChainParameters ) => Promise <void > | undefined | 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? | Object | undefined | Flags for batch settings. |
client.batch.multicall? | boolean | { batchSize? : number ; wait? : number } | undefined | Toggle to enable eth_call multicall aggregation. |
client.cacheTime | number | undefined | Time (in ms) that cached data will remain in memory. |
client.chain | undefined | Chain | undefined | Chain for the client. |
client.deployContract | <TAbi, TChainOverride>(args : DeployContractParameters <TAbi , undefined | Chain , undefined | Account , TChainOverride >) => Promise <`0x${string}`> | undefined | 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 >> | undefined | - |
client.getAddresses | () => Promise <GetAddressesReturnType > | undefined | 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 > | undefined | 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 > | undefined | 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.key | string | undefined | A key for the client. |
client.name | string | undefined | A name for the client. |
client.pollingInterval | number | undefined | Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. |
client.prepareTransactionRequest | <TChainOverride>(args : PrepareTransactionRequestParameters <undefined | Chain , undefined | Account , TChainOverride >) => Promise <PrepareTransactionRequestReturnType > | undefined | 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.request | EIP1193RequestFn <WalletRpcSchema > | undefined | Request function wrapped with friendly error handling |
client.requestAddresses | () => Promise <RequestAddressesReturnType > | undefined | 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 > | undefined | 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}`> | undefined | 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}`> | undefined | 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}`> | undefined | 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}`> | undefined | 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}`> | undefined | 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 > | undefined | 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.transport | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | undefined | The RPC transport |
client.type | string | undefined | The type of client. |
client.uid | string | undefined | A unique ID for the client. |
client.watchAsset | (args : WatchAssetParams ) => Promise <boolean > | undefined | 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}`> | undefined | 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) |
chainId | ChainId | undefined | - |
agencyAddress | `0x${string}` | undefined | - |
deadline | number | undefined | - |
isUsedContractWallet | boolean | false | - |
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
Name | Type |
---|---|
token | string |
chainId | ChainId |
agencyContractAddress | `0x${string}` |
Returns
Promise
<false
| EXPIRED_REFERRAL_CODE
| INVALID_INPUT
| { onceAddress
: `0x${string}` ; parentAddress
: `0x${string}` }>