@across-protocol/app-sdk / AcrossClient
Entrypoint for the Across Integrator SDK
logger:
LoggerT
packages/sdk/src/client.ts:143
get
isTenderlyEnabled():boolean
boolean
packages/sdk/src/client.ts:153
executeQuote(
params
):Promise
<void
>
Execute a quote by:
- Approving the SpokePool contract if necessary
- Depositing the input token on the origin chain
- Waiting for the deposit to be filled on the destination chain
See executeQuote for more details.
• params: Omit
<ExecuteQuoteParams
, "logger"
| "integratorId"
| "originClient"
| "destinationClient"
>
See ExecuteQuoteParams.
Promise
<void
>
The deposit ID and receipts for the deposit and fill transactions.
const quote = await client.getQuote({ route, inputAmount });
const { depositId } = await client.executeQuote({ deposit: quote.deposit });
packages/sdk/src/client.ts:244
getAvailableRoutes(
params
):Promise
<GetAvailableRoutesReturnType
>
Get the available routes for a given set of parameters. See getAvailableRoutes.
• params: Omit
<GetAvailableRoutesParams
, "logger"
| "apiUrl"
>
Promise
<GetAvailableRoutesReturnType
>
See GetAvailableRoutesReturnType.
packages/sdk/src/client.ts:320
getDeposit(
params
):Promise
<Deposit
>
Get a deposit by its deposit tx hash or deposit id + spoke pool address. See getDeposit.
• params: Omit
<GetDepositParams
, "destinationChainClient"
| "indexerUrl"
| "originChainClient"
>
See GetDepositParams.
Promise
<Deposit
>
See Deposit.
packages/sdk/src/client.ts:531
getFillByDepositTx(
params
):Promise
<FillStatus
>
Get a fill after a deposit has been made. See getFillByDepositTx.
• params: Omit
<GetFillByDepositTxParams
, "logger"
| "destinationChainClient"
| "indexerUrl"
| "originChainClient"
>
Promise
<FillStatus
>
See FillStatus.
packages/sdk/src/client.ts:499
getLimits(
params
):Promise
<GetLimitsReturnType
>
Get the deposit limits for a given route. See getLimits.
• params: Omit
<GetLimitsParams
, "logger"
| "apiUrl"
>
See GetLimitsParams.
Promise
<GetLimitsReturnType
>
See GetLimitsReturnType.
packages/sdk/src/client.ts:374
getPublicClient(
chainId
):object
Internal
• chainId: number
object
account:
undefined
The Account of the Client.
optional
batch:object
Flags for batch settings.
optional
multicall:boolean
|object
Toggle to enable eth_call
multicall aggregation.
cacheTime:
number
Time (in ms) that cached data will remain in memory.
call: (
parameters
) =>Promise
<CallReturnType
>
Executes a new message call immediately without submitting a transaction to the network.
- Docs: https://viem.sh/docs/actions/public/call
- JSON-RPC Methods:
eth_call
• parameters: CallParameters
<Chain
>
Promise
<CallReturnType
>
The call data. CallReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const data = await client.call({
account: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
data: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
to: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
});
optional
ccipRead:false
|object
CCIP Read configuration.
chain:
Chain
Chain for the client.
createBlockFilter: () =>
Promise
<object
>
Creates a Filter to listen for new block hashes that can be used with getFilterChanges
.
- Docs: https://viem.sh/docs/actions/public/createBlockFilter
- JSON-RPC Methods:
eth_newBlockFilter
Promise
<object
>
Filter. CreateBlockFilterReturnType
id: `0x${string}`
request:
EIP1193RequestFn
<readonly [object
,object
,object
]>
type:
"block"
import { createPublicClient, createBlockFilter, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await createBlockFilter(client);
// { id: "0x345a6572337856574a76364e457a4366", type: 'block' }
createContractEventFilter: <
abi
,eventName
,args
,strict
,fromBlock
,toBlock
>(args
) =>Promise
<CreateContractEventFilterReturnType
<abi
,eventName
,args
,strict
,fromBlock
,toBlock
>>
Creates a Filter to retrieve event logs that can be used with getFilterChanges
or getFilterLogs
.
• abi extends Abi
| readonly unknown
[]
• eventName extends undefined
| string
• args extends undefined
| Record
<string
, unknown
> | readonly unknown
[]
• strict extends undefined
| boolean
= undefined
• fromBlock extends undefined
| bigint
| BlockTag
= undefined
• toBlock extends undefined
| bigint
| BlockTag
= undefined
• args: CreateContractEventFilterParameters
<abi
, eventName
, args
, strict
, fromBlock
, toBlock
>
CreateContractEventFilterParameters
Promise
<CreateContractEventFilterReturnType
<abi
, eventName
, args
, strict
, fromBlock
, toBlock
>>
Filter
. CreateContractEventFilterReturnType
import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createContractEventFilter({
abi: parseAbi(["event Transfer(address indexed, address indexed, uint256)"]),
});
createEventFilter: <
abiEvent
,abiEvents
,strict
,fromBlock
,toBlock
,_EventName
,_Args
>(args
?) =>Promise
<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>
Creates a Filter
to listen for new events that can be used with getFilterChanges
.
- Docs: https://viem.sh/docs/actions/public/createEventFilter
- JSON-RPC Methods:
eth_newFilter
• abiEvent extends undefined
| AbiEvent
= undefined
• abiEvents extends undefined
| readonly unknown
[] | readonly AbiEvent
[] = abiEvent
extends AbiEvent
? [abiEvent
<abiEvent
>] : undefined
• strict extends undefined
| boolean
= undefined
• fromBlock extends undefined
| bigint
| BlockTag
= undefined
• toBlock extends undefined
| bigint
| BlockTag
= undefined
• _EventName extends undefined
| string
= MaybeAbiEventName
<abiEvent
>
• _Args extends undefined
| Record
<string
, unknown
> | readonly unknown
[] = undefined
• args?: CreateEventFilterParameters
<abiEvent
, abiEvents
, strict
, fromBlock
, toBlock
, _EventName
, _Args
>
CreateEventFilterParameters
Promise
<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>
Filter
. CreateEventFilterReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createEventFilter({
address: "0xfba3912ca04dd458c843e2ee08967fc04f3579c2",
});
createPendingTransactionFilter: () =>
Promise
<object
>
Creates a Filter to listen for new pending transaction hashes that can be used with getFilterChanges
.
- Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter
- JSON-RPC Methods:
eth_newPendingTransactionFilter
Promise
<object
>
Filter
. CreateBlockFilterReturnType
id: `0x${string}`
request:
EIP1193RequestFn
<readonly [object
,object
,object
]>
type:
"transaction"
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createPendingTransactionFilter();
// { id: "0x345a6572337856574a76364e457a4366", type: 'transaction' }
estimateContractGas: <
chain
,abi
,functionName
,args
>(args
) =>Promise
<bigint
>
Estimates the gas required to successfully execute a contract write function call.
• chain extends undefined
| Chain
• abi extends Abi
| readonly unknown
[]
• functionName extends string
• args extends unknown
• args: EstimateContractGasParameters
<abi
, functionName
, args
, chain
>
EstimateContractGasParameters
Promise
<bigint
>
The gas estimate (in wei). EstimateContractGasReturnType
Internally, uses a Public Client to call the estimateGas
action with ABI-encoded data
.
import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const gas = await client.estimateContractGas({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi: parseAbi(["function mint() public"]),
functionName: "mint",
account: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
});
estimateFeesPerGas: <
chainOverride
,type
>(args
?) =>Promise
<EstimateFeesPerGasReturnType
<type
>>
Returns an estimate for the fees per gas for a transaction to be included in the next block.
• chainOverride extends undefined
| Chain
= undefined
• type extends FeeValuesType
= "eip1559"
• args?: EstimateFeesPerGasParameters
<Chain
, chainOverride
, type
>
Promise
<EstimateFeesPerGasReturnType
<type
>>
An estimate (in wei) for the fees per gas. EstimateFeesPerGasReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const maxPriorityFeePerGas = await client.estimateFeesPerGas();
// { maxFeePerGas: ..., maxPriorityFeePerGas: ... }
estimateGas: (
args
) =>Promise
<bigint
>
Estimates the gas necessary to complete a transaction without submitting it to the network.
- Docs: https://viem.sh/docs/actions/public/estimateGas
- JSON-RPC Methods:
eth_estimateGas
• args: EstimateGasParameters
<Chain
>
EstimateGasParameters
Promise
<bigint
>
The gas estimate (in wei). EstimateGasReturnType
import { createPublicClient, http, parseEther } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const gasEstimate = await client.estimateGas({
account: "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
to: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
value: parseEther("1"),
});
estimateMaxPriorityFeePerGas: <
chainOverride
>(args
?) =>Promise
<bigint
>
Returns an estimate for the max priority fee per gas (in wei) for a transaction to be included in the next block.
• chainOverride extends undefined
| Chain
= undefined
• args?
• args.chain?: null
| chainOverride
Promise
<bigint
>
An estimate (in wei) for the max priority fee per gas. EstimateMaxPriorityFeePerGasReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas();
// 10000000n
extend: <
client
>(fn
) =>Client
<Transport
,Chain
,undefined
,PublicRpcSchema
, { [K in string | number | symbol]: client[K] } &PublicActions
<Transport
,Chain
>>
• client extends object
& ExactPartial
<ExtendableProtectedActions
<Transport
, Chain
, undefined
>>
• fn
Client
<Transport
, Chain
, undefined
, PublicRpcSchema
, { [K in string | number | symbol]: client[K] } & PublicActions
<Transport
, Chain
>>
getBalance: (
args
) =>Promise
<bigint
>
Returns the balance of an address in wei.
- Docs: https://viem.sh/docs/actions/public/getBalance
- JSON-RPC Methods:
eth_getBalance
• args: GetBalanceParameters
GetBalanceParameters
Promise
<bigint
>
The balance of the address in wei. GetBalanceReturnType
You can convert the balance to ether units with formatEther
.
const balance = await getBalance(client, {
address: "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
blockTag: "safe",
});
const balanceAsEther = formatEther(balance);
// "6.942"
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const balance = await client.getBalance({
address: "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
});
// 10000000000000000000000n (wei)
getBlobBaseFee: () =>
Promise
<bigint
>
Returns the base fee per blob gas in wei.
- Docs: https://viem.sh/docs/actions/public/getBlobBaseFee
- JSON-RPC Methods:
eth_blobBaseFee
Promise
<bigint
>
The blob base fee (in wei). GetBlobBaseFeeReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { getBlobBaseFee } from "viem/public";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const blobBaseFee = await client.getBlobBaseFee();
getBlock: <
includeTransactions
,blockTag
>(args
?) =>Promise
<object
>
Returns information about a block at a block number, hash, or tag.
- Docs: https://viem.sh/docs/actions/public/getBlock
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks/fetching-blocks
- JSON-RPC Methods:
- Calls
eth_getBlockByNumber
forblockNumber
&blockTag
. - Calls
eth_getBlockByHash
forblockHash
.
- Calls
• includeTransactions extends boolean
= false
• blockTag extends BlockTag
= "latest"
• args?: GetBlockParameters
<includeTransactions
, blockTag
>
GetBlockParameters
Promise
<object
>
Information about the block. GetBlockReturnType
baseFeePerGas:
null
|bigint
Base fee per gas
blobGasUsed:
bigint
Total used blob gas by all transactions in this block
difficulty:
bigint
Difficulty for this block
excessBlobGas:
bigint
Excess blob gas
extraData: `0x${string}`
"Extra data" field of this block
gasLimit:
bigint
Maximum gas allowed in this block
gasUsed:
bigint
Total used gas by all transactions in this block
hash:
blockTag
extends"pending"
?null
: `0x${string}`
Block hash or null
if pending
logsBloom:
blockTag
extends"pending"
?null
: `0x${string}`
Logs bloom filter or null
if pending
miner: `0x${string}`
Address that received this block’s mining rewards
mixHash: `0x${string}`
Unique identifier for the block.
nonce:
blockTag
extends"pending"
?null
: `0x${string}`
Proof-of-work hash or null
if pending
number:
blockTag
extends"pending"
?null
:bigint
Block number or null
if pending
parentHash: `0x${string}`
Parent block hash
receiptsRoot: `0x${string}`
Root of the this block’s receipts trie
sealFields: `0x${string}`[]
sha3Uncles: `0x${string}`
SHA3 of the uncles data in this block
size:
bigint
Size of this block in bytes
stateRoot: `0x${string}`
Root of this block’s final state trie
timestamp:
bigint
Unix timestamp of when this block was collated
totalDifficulty:
null
|bigint
Total difficulty of the chain until this block
transactions:
includeTransactions
extendstrue
? (object
|object
|object
|object
|object
)[] : `0x${string}`[]
transactionsRoot: `0x${string}`
Root of this block’s transaction trie
uncles: `0x${string}`[]
List of uncle hashes
optional
withdrawals:Withdrawal
[]
List of withdrawal objects
optional
withdrawalsRoot: `0x${string}`
Root of the this block’s withdrawals trie
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const block = await client.getBlock();
getBlockNumber: (
args
?) =>Promise
<bigint
>
Returns the number of the most recent block seen.
- Docs: https://viem.sh/docs/actions/public/getBlockNumber
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks/fetching-blocks
- JSON-RPC Methods:
eth_blockNumber
• args?: GetBlockNumberParameters
GetBlockNumberParameters
Promise
<bigint
>
The number of the block. GetBlockNumberReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const blockNumber = await client.getBlockNumber();
// 69420n
getBlockTransactionCount: (
args
?) =>Promise
<number
>
Returns the number of Transactions at a block number, hash, or tag.
- Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount
- JSON-RPC Methods:
- Calls
eth_getBlockTransactionCountByNumber
forblockNumber
&blockTag
. - Calls
eth_getBlockTransactionCountByHash
forblockHash
.
- Calls
• args?: GetBlockTransactionCountParameters
GetBlockTransactionCountParameters
Promise
<number
>
The block transaction count. GetBlockTransactionCountReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const count = await client.getBlockTransactionCount();
getBytecode: (
args
) =>Promise
<GetCodeReturnType
>
• args: GetCodeParameters
Promise
<GetCodeReturnType
>
Use getCode
instead.
getChainId: () =>
Promise
<number
>
Returns the chain ID associated with the current network.
- Docs: https://viem.sh/docs/actions/public/getChainId
- JSON-RPC Methods:
eth_chainId
Promise
<number
>
The current chain ID. GetChainIdReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const chainId = await client.getChainId();
// 1
getCode: (
args
) =>Promise
<GetCodeReturnType
>
Retrieves the bytecode at an address.
- Docs: https://viem.sh/docs/contract/getCode
- JSON-RPC Methods:
eth_getCode
• args: GetCodeParameters
GetBytecodeParameters
Promise
<GetCodeReturnType
>
The contract's bytecode. GetBytecodeReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const code = await client.getCode({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
});
getContractEvents: <
abi
,eventName
,strict
,fromBlock
,toBlock
>(args
) =>Promise
<GetContractEventsReturnType
<abi
,eventName
,strict
,fromBlock
,toBlock
>>
Returns a list of event logs emitted by a contract.
- Docs: https://viem.sh/docs/actions/public/getContractEvents
- JSON-RPC Methods:
eth_getLogs
• abi extends Abi
| readonly unknown
[]
• eventName extends undefined
| string
= undefined
• strict extends undefined
| boolean
= undefined
• fromBlock extends undefined
| bigint
| BlockTag
= undefined
• toBlock extends undefined
| bigint
| BlockTag
= undefined
• args: GetContractEventsParameters
<abi
, eventName
, strict
, fromBlock
, toBlock
>
Promise
<GetContractEventsReturnType
<abi
, eventName
, strict
, fromBlock
, toBlock
>>
A list of event logs. GetContractEventsReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { wagmiAbi } from "./abi";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const logs = await client.getContractEvents(client, {
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi: wagmiAbi,
eventName: "Transfer",
});
getEip712Domain: (
args
) =>Promise
<GetEip712DomainReturnType
>
Reads the EIP-712 domain from a contract, based on the ERC-5267 specification.
• args: GetEip712DomainParameters
Promise
<GetEip712DomainReturnType
>
The EIP-712 domain, fields, and extensions. GetEip712DomainReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const domain = await client.getEip712Domain({
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
});
// {
// domain: {
// name: 'ExampleContract',
// version: '1',
// chainId: 1,
// verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
// },
// fields: '0x0f',
// extensions: [],
// }
getEnsAddress: (
args
) =>Promise
<GetEnsAddressReturnType
>
Gets address for ENS name.
- Docs: https://viem.sh/docs/ens/actions/getEnsAddress
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
• args
GetEnsAddressParameters
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.coinType?: number
ENSIP-9 compliant coinType used to resolve addresses for other chains
• args.gatewayUrls?: string
[]
Universal Resolver gateway URLs to use for resolving CCIP-read requests.
• args.name: string
Name to get the address for.
• args.strict?: boolean
Whether or not to throw errors propagated from the ENS Universal Resolver Contract.
• args.universalResolverAddress?: `0x${string}`
Address of ENS Universal Resolver Contract.
Promise
<GetEnsAddressReturnType
>
Address for ENS name or null
if not found. GetEnsAddressReturnType
Calls resolve(bytes, bytes)
on ENS Universal Resolver Contract.
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress
. You can use the built-in normalize
function for this.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { normalize } from "viem/ens";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const ensAddress = await client.getEnsAddress({
name: normalize("wevm.eth"),
});
// '0xd2135CfB216b74109775236E36d4b433F1DF507B'
getEnsAvatar: (
args
) =>Promise
<GetEnsAvatarReturnType
>
Gets the avatar of an ENS name.
- Docs: https://viem.sh/docs/ens/actions/getEnsAvatar
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
• args
GetEnsAvatarParameters
• args.assetGatewayUrls?: AssetGatewayUrls
Gateway urls to resolve IPFS and/or Arweave assets.
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.gatewayUrls?: string
[]
Universal Resolver gateway URLs to use for resolving CCIP-read requests.
• args.name: string
ENS name to get Text for.
• args.strict?: boolean
Whether or not to throw errors propagated from the ENS Universal Resolver Contract.
• args.universalResolverAddress?: `0x${string}`
Address of ENS Universal Resolver Contract.
Promise
<GetEnsAvatarReturnType
>
Avatar URI or null
if not found. GetEnsAvatarReturnType
Calls getEnsText
with key
set to 'avatar'
.
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress
. You can use the built-in normalize
function for this.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { normalize } from "viem/ens";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const ensAvatar = await client.getEnsAvatar({
name: normalize("wevm.eth"),
});
// 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'
getEnsName: (
args
) =>Promise
<GetEnsNameReturnType
>
Gets primary name for specified address.
- Docs: https://viem.sh/docs/ens/actions/getEnsName
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
• args
GetEnsNameParameters
• args.address: `0x${string}`
Address to get ENS name for.
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.gatewayUrls?: string
[]
Universal Resolver gateway URLs to use for resolving CCIP-read requests.
• args.strict?: boolean
Whether or not to throw errors propagated from the ENS Universal Resolver Contract.
• args.universalResolverAddress?: `0x${string}`
Address of ENS Universal Resolver Contract.
Promise
<GetEnsNameReturnType
>
Name or null
if not found. GetEnsNameReturnType
Calls reverse(bytes)
on ENS Universal Resolver Contract to "reverse resolve" the address to the primary ENS name.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const ensName = await client.getEnsName({
address: "0xd2135CfB216b74109775236E36d4b433F1DF507B",
});
// 'wevm.eth'
getEnsResolver: (
args
) =>Promise
<`0x${string}`>
Gets resolver for ENS name.
- Docs: https://viem.sh/docs/ens/actions/getEnsResolver
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
• args
GetEnsResolverParameters
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.name: string
Name to get the address for.
• args.universalResolverAddress?: `0x${string}`
Address of ENS Universal Resolver Contract.
Promise
<`0x${string}`>
Address for ENS resolver. GetEnsResolverReturnType
Calls findResolver(bytes)
on ENS Universal Resolver Contract to retrieve the resolver of an ENS name.
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress
. You can use the built-in normalize
function for this.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { normalize } from "viem/ens";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const resolverAddress = await client.getEnsResolver({
name: normalize("wevm.eth"),
});
// '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
getEnsText: (
args
) =>Promise
<GetEnsTextReturnType
>
Gets a text record for specified ENS name.
- Docs: https://viem.sh/docs/ens/actions/getEnsResolver
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
• args
GetEnsTextParameters
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.gatewayUrls?: string
[]
Universal Resolver gateway URLs to use for resolving CCIP-read requests.
• args.key: string
Text record to retrieve.
• args.name: string
ENS name to get Text for.
• args.strict?: boolean
Whether or not to throw errors propagated from the ENS Universal Resolver Contract.
• args.universalResolverAddress?: `0x${string}`
Address of ENS Universal Resolver Contract.
Promise
<GetEnsTextReturnType
>
Address for ENS resolver. GetEnsTextReturnType
Calls resolve(bytes, bytes)
on ENS Universal Resolver Contract.
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress
. You can use the built-in normalize
function for this.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { normalize } from "viem/ens";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const twitterRecord = await client.getEnsText({
name: normalize("wevm.eth"),
key: "com.twitter",
});
// 'wevm_dev'
getFeeHistory: (
args
) =>Promise
<GetFeeHistoryReturnType
>
Returns a collection of historical gas information.
- Docs: https://viem.sh/docs/actions/public/getFeeHistory
- JSON-RPC Methods:
eth_feeHistory
• args: GetFeeHistoryParameters
GetFeeHistoryParameters
Promise
<GetFeeHistoryReturnType
>
The gas estimate (in wei). GetFeeHistoryReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const feeHistory = await client.getFeeHistory({
blockCount: 4,
rewardPercentiles: [25, 75],
});
getFilterChanges: <
filterType
,abi
,eventName
,strict
,fromBlock
,toBlock
>(args
) =>Promise
<GetFilterChangesReturnType
<filterType
,abi
,eventName
,strict
,fromBlock
,toBlock
>>
Returns a list of logs or hashes based on a Filter since the last time it was called.
- Docs: https://viem.sh/docs/actions/public/getFilterChanges
- JSON-RPC Methods:
eth_getFilterChanges
• filterType extends FilterType
• abi extends undefined
| Abi
| readonly unknown
[]
• eventName extends undefined
| string
• strict extends undefined
| boolean
= undefined
• fromBlock extends undefined
| bigint
| BlockTag
= undefined
• toBlock extends undefined
| bigint
| BlockTag
= undefined
• args: GetFilterChangesParameters
<filterType
, abi
, eventName
, strict
, fromBlock
, toBlock
>
GetFilterChangesParameters
Promise
<GetFilterChangesReturnType
<filterType
, abi
, eventName
, strict
, fromBlock
, toBlock
>>
Logs or hashes. GetFilterChangesReturnType
A Filter can be created from the following actions:
Depending on the type of filter, the return value will be different:
- If the filter was created with
createContractEventFilter
orcreateEventFilter
, it returns a list of logs. - If the filter was created with
createPendingTransactionFilter
, it returns a list of transaction hashes. - If the filter was created with
createBlockFilter
, it returns a list of block hashes.
// Blocks
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createBlockFilter();
const hashes = await client.getFilterChanges({ filter });
// Contract Events
import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createContractEventFilter({
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
abi: parseAbi(["event Transfer(address indexed, address indexed, uint256)"]),
eventName: "Transfer",
});
const logs = await client.getFilterChanges({ filter });
// Raw Events
import { createPublicClient, http, parseAbiItem } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createEventFilter({
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
event: parseAbiItem(
"event Transfer(address indexed, address indexed, uint256)",
),
});
const logs = await client.getFilterChanges({ filter });
// Transactions
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createPendingTransactionFilter();
const hashes = await client.getFilterChanges({ filter });
getFilterLogs: <
abi
,eventName
,strict
,fromBlock
,toBlock
>(args
) =>Promise
<GetFilterLogsReturnType
<abi
,eventName
,strict
,fromBlock
,toBlock
>>
Returns a list of event logs since the filter was created.
- Docs: https://viem.sh/docs/actions/public/getFilterLogs
- JSON-RPC Methods:
eth_getFilterLogs
• abi extends undefined
| Abi
| readonly unknown
[]
• eventName extends undefined
| string
• strict extends undefined
| boolean
= undefined
• fromBlock extends undefined
| bigint
| BlockTag
= undefined
• toBlock extends undefined
| bigint
| BlockTag
= undefined
• args: GetFilterLogsParameters
<abi
, eventName
, strict
, fromBlock
, toBlock
>
GetFilterLogsParameters
Promise
<GetFilterLogsReturnType
<abi
, eventName
, strict
, fromBlock
, toBlock
>>
A list of event logs. GetFilterLogsReturnType
getFilterLogs
is only compatible with event filters.
import { createPublicClient, http, parseAbiItem } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const filter = await client.createEventFilter({
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
event: parseAbiItem(
"event Transfer(address indexed, address indexed, uint256)",
),
});
const logs = await client.getFilterLogs({ filter });
getGasPrice: () =>
Promise
<bigint
>
Returns the current price of gas (in wei).
- Docs: https://viem.sh/docs/actions/public/getGasPrice
- JSON-RPC Methods:
eth_gasPrice
Promise
<bigint
>
The gas price (in wei). GetGasPriceReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const gasPrice = await client.getGasPrice();
getLogs: <
abiEvent
,abiEvents
,strict
,fromBlock
,toBlock
>(args
?) =>Promise
<GetLogsReturnType
<abiEvent
,abiEvents
,strict
,fromBlock
,toBlock
>>
Returns a list of event logs matching the provided parameters.
- Docs: https://viem.sh/docs/actions/public/getLogs
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/filters-and-logs/event-logs
- JSON-RPC Methods:
eth_getLogs
• abiEvent extends undefined
| AbiEvent
= undefined
• abiEvents extends undefined
| readonly unknown
[] | readonly AbiEvent
[] = abiEvent
extends AbiEvent
? [abiEvent
<abiEvent
>] : undefined
• strict extends undefined
| boolean
= undefined
• fromBlock extends undefined
| bigint
| BlockTag
= undefined
• toBlock extends undefined
| bigint
| BlockTag
= undefined
• args?: GetLogsParameters
<abiEvent
, abiEvents
, strict
, fromBlock
, toBlock
>
GetLogsParameters
Promise
<GetLogsReturnType
<abiEvent
, abiEvents
, strict
, fromBlock
, toBlock
>>
A list of event logs. GetLogsReturnType
import { createPublicClient, http, parseAbiItem } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const logs = await client.getLogs();
getProof: (
args
) =>Promise
<GetProofReturnType
>
Returns the account and storage values of the specified account including the Merkle-proof.
- Docs: https://viem.sh/docs/actions/public/getProof
- JSON-RPC Methods:
- Calls
eth_getProof
- Calls
• args: GetProofParameters
Promise
<GetProofReturnType
>
Proof data. GetProofReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const block = await client.getProof({
address: "0x...",
storageKeys: ["0x..."],
});
getStorageAt: (
args
) =>Promise
<GetStorageAtReturnType
>
Returns the value from a storage slot at a given address.
- Docs: https://viem.sh/docs/contract/getStorageAt
- JSON-RPC Methods:
eth_getStorageAt
• args: GetStorageAtParameters
GetStorageAtParameters
Promise
<GetStorageAtReturnType
>
The value of the storage slot. GetStorageAtReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { getStorageAt } from "viem/contract";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const code = await client.getStorageAt({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
slot: toHex(0),
});
getTransaction: <
blockTag
>(args
) =>Promise
<object
|object
|object
|object
|object
>
Returns information about a Transaction given a hash or block identifier.
- Docs: https://viem.sh/docs/actions/public/getTransaction
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions/fetching-transactions
- JSON-RPC Methods:
eth_getTransactionByHash
• blockTag extends BlockTag
= "latest"
• args: GetTransactionParameters
<blockTag
>
GetTransactionParameters
Promise
<object
| object
| object
| object
| object
>
The transaction information. GetTransactionReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const transaction = await client.getTransaction({
hash: "0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d",
});
getTransactionConfirmations: (
args
) =>Promise
<bigint
>
Returns the number of blocks passed (confirmations) since the transaction was processed on a block.
- Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions/fetching-transactions
- JSON-RPC Methods:
eth_getTransactionConfirmations
• args: GetTransactionConfirmationsParameters
<Chain
>
GetTransactionConfirmationsParameters
Promise
<bigint
>
The number of blocks passed since the transaction was processed. If confirmations is 0, then the Transaction has not been confirmed & processed yet. GetTransactionConfirmationsReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const confirmations = await client.getTransactionConfirmations({
hash: "0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d",
});
getTransactionCount: (
args
) =>Promise
<number
>
Returns the number of Transactions an Account has broadcast / sent.
- Docs: https://viem.sh/docs/actions/public/getTransactionCount
- JSON-RPC Methods:
eth_getTransactionCount
• args: GetTransactionCountParameters
GetTransactionCountParameters
Promise
<number
>
The number of transactions an account has sent. GetTransactionCountReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const transactionCount = await client.getTransactionCount({
address: "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
});
getTransactionReceipt: (
args
) =>Promise
<TransactionReceipt
>
Returns the Transaction Receipt given a Transaction hash.
- Docs: https://viem.sh/docs/actions/public/getTransactionReceipt
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions/fetching-transactions
- JSON-RPC Methods:
eth_getTransactionReceipt
• args: GetTransactionReceiptParameters
GetTransactionReceiptParameters
Promise
<TransactionReceipt
>
The transaction receipt. GetTransactionReceiptReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const transactionReceipt = await client.getTransactionReceipt({
hash: "0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d",
});
key:
string
A key for the client.
multicall: <
contracts
,allowFailure
>(args
) =>Promise
<MulticallReturnType
<contracts
,allowFailure
>>
Similar to readContract
, but batches up multiple functions on a contract in a single RPC call via the multicall3
contract.
• contracts extends readonly unknown
[]
• allowFailure extends boolean
= true
• args: MulticallParameters
<contracts
, allowFailure
>
MulticallParameters
Promise
<MulticallReturnType
<contracts
, allowFailure
>>
An array of results with accompanying status. MulticallReturnType
import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const abi = parseAbi([
"function balanceOf(address) view returns (uint256)",
"function totalSupply() view returns (uint256)",
]);
const result = await client.multicall({
contracts: [
{
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi,
functionName: "balanceOf",
args: ["0xA0Cf798816D4b9b9866b5330EEa46a18382f251e"],
},
{
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi,
functionName: "totalSupply",
},
],
});
// [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
name:
string
A name for the client.
pollingInterval:
number
Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
prepareTransactionRequest: <
request
,chainOverride
,accountOverride
>(args
) =>Promise
<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & Object, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "gas" | "nonce" | "blobVersionedHashes" | "fees" | "chainId">> & (unknown extends request["kzg"] ? Object : Pick<request, "kzg">))[K] }>
Prepares a transaction request for signing.
• request extends Omit
<object
, "from"
> | Omit
<object
, "from"
> | Omit
<object
, "from"
> | Omit
<object
, "from"
> | Omit
<object
, "from"
> & object
& object
• chainOverride extends undefined
| Chain
= undefined
• accountOverride extends undefined
| `0x${string}` | Account
= undefined
• args: PrepareTransactionRequestParameters
<Chain
, undefined
| Account
, chainOverride
, accountOverride
, request
>
PrepareTransactionRequestParameters
Promise
<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & Object, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "gas" | "nonce" | "blobVersionedHashes" | "fees" | "chainId">> & (unknown extends request["kzg"] ? Object : Pick<request, "kzg">))[K] }>
The transaction request. PrepareTransactionRequestReturnType
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,
});
// 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,
});
readContract: <
abi
,functionName
,args
>(args
) =>Promise
<ReadContractReturnType
<abi
,functionName
,args
>>
Calls a read-only function on a contract, and returns the response.
- Docs: https://viem.sh/docs/contract/readContract
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts/reading-contracts
• abi extends Abi
| readonly unknown
[]
• functionName extends string
• args extends unknown
• args: ReadContractParameters
<abi
, functionName
, args
>
ReadContractParameters
Promise
<ReadContractReturnType
<abi
, functionName
, args
>>
The response from the contract. Type is inferred. ReadContractReturnType
A "read-only" function (constant function) on a Solidity contract is denoted by a view
or pure
keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas.
Internally, uses a Public Client to call the call
action with ABI-encoded data
.
import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
import { readContract } from "viem/contract";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const result = await client.readContract({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi: parseAbi(["function balanceOf(address) view returns (uint256)"]),
functionName: "balanceOf",
args: ["0xA0Cf798816D4b9b9866b5330EEa46a18382f251e"],
});
// 424122n
request:
EIP1193RequestFn
<PublicRpcSchema
>
Request function wrapped with friendly error handling
sendRawTransaction: (
args
) =>Promise
<`0x${string}`>
Sends a signed transaction to the network
- Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction
- JSON-RPC Method:
eth_sendRawTransaction
• args: SendRawTransactionParameters
Promise
<`0x${string}`>
The transaction hash. SendRawTransactionReturnType
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",
});
simulateContract: <
abi
,functionName
,args
,chainOverride
,accountOverride
>(args
) =>Promise
<SimulateContractReturnType
<abi
,functionName
,args
,Chain
,undefined
|Account
,chainOverride
,accountOverride
>>
Simulates/validates a contract interaction. This is useful for retrieving return data and revert reasons of contract write functions.
- Docs: https://viem.sh/docs/contract/simulateContract
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts/writing-to-contracts
• abi extends Abi
| readonly unknown
[]
• functionName extends string
• args extends unknown
• chainOverride extends undefined
| Chain
• accountOverride extends undefined
| `0x${string}` | Account
= undefined
• args: SimulateContractParameters
<abi
, functionName
, args
, Chain
, chainOverride
, accountOverride
>
SimulateContractParameters
Promise
<SimulateContractReturnType
<abi
, functionName
, args
, Chain
, undefined
| Account
, chainOverride
, accountOverride
>>
The simulation result and write request. SimulateContractReturnType
This function does not require gas to execute and does not change the state of the blockchain. It is almost identical to readContract
, but also supports contract write functions.
Internally, uses a Public Client to call the call
action with ABI-encoded data
.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const result = await client.simulateContract({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi: parseAbi(["function mint(uint32) view returns (uint32)"]),
functionName: "mint",
args: ["69420"],
account: "0xA0Cf798816D4b9b9866b5330EEa46a18382f251e",
});
transport:
TransportConfig
<string
,EIP1193RequestFn
> &Record
<string
,any
>
The RPC transport
type:
string
The type of client.
uid:
string
A unique ID for the client.
uninstallFilter: (
args
) =>Promise
<boolean
>
Destroys a Filter that was created from one of the following Actions:
-
JSON-RPC Methods:
eth_uninstallFilter
• args: UninstallFilterParameters
UninstallFilterParameters
Promise
<boolean
>
A boolean indicating if the Filter was successfully uninstalled. UninstallFilterReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { createPendingTransactionFilter, uninstallFilter } from "viem/public";
const filter = await client.createPendingTransactionFilter();
const uninstalled = await client.uninstallFilter({ filter });
// true
verifyMessage: (
args
) =>Promise
<boolean
>
Verify that a message was signed by the provided address.
Compatible with Smart Contract Accounts & Externally Owned Accounts via ERC-6492.
• args
• args.address: `0x${string}`
The address that signed the original message.
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.factory?: `0x${string}`
• args.factoryData?: `0x${string}`
• args.message: SignableMessage
The message to be verified.
• args.signature: `0x${string}` | Uint8Array
| Signature
The signature that was generated by signing the message with the address's private key.
Promise
<boolean
>
Whether or not the signature is valid. VerifyMessageReturnType
verifySiweMessage: (
args
) =>Promise
<boolean
>
Verifies EIP-4361 formatted message was signed.
Compatible with Smart Contract Accounts & Externally Owned Accounts via ERC-6492.
• args
• args.address?: `0x${string}`
Ethereum address to check against.
• args.blockNumber?: bigint
The balance of the account at a block number.
• args.blockTag?: BlockTag
The balance of the account at a block tag.
Default
"latest";
• args.domain?: string
RFC 3986 authority to check against.
• args.message: string
EIP-4361 formatted message.
• args.nonce?: string
Random string to check against.
• args.scheme?: string
RFC 3986 URI scheme to check against.
• args.signature: `0x${string}`
Signature to check against.
• args.time?: Date
Current time to check optional expirationTime
and notBefore
fields.
Default
new Date();
Promise
<boolean
>
Whether or not the signature is valid. VerifySiweMessageReturnType
verifyTypedData: (
args
) =>Promise
<boolean
>
Verify that typed data was signed by the provided address.
• args: VerifyTypedDataParameters
Promise
<boolean
>
Whether or not the signature is valid. VerifyTypedDataReturnType
waitForTransactionReceipt: (
args
) =>Promise
<TransactionReceipt
>
Waits for the Transaction to be included on a Block (one confirmation), and then returns the Transaction Receipt. If the Transaction reverts, then the action will throw an error.
- Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions/sending-transactions
- JSON-RPC Methods:
- Polls
eth_getTransactionReceipt
on each block until it has been processed. - If a Transaction has been replaced:
- Calls
eth_getBlockByNumber
and extracts the transactions - Checks if one of the Transactions is a replacement
- If so, calls
eth_getTransactionReceipt
.
- Calls
- Polls
• args: WaitForTransactionReceiptParameters
<Chain
>
WaitForTransactionReceiptParameters
Promise
<TransactionReceipt
>
The transaction receipt. WaitForTransactionReceiptReturnType
The waitForTransactionReceipt
action additionally supports Replacement detection (e.g. sped up Transactions).
Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel). Transactions are replaced when they are sent from the same nonce.
There are 3 types of Transaction Replacement reasons:
repriced
: The gas price has been modified (e.g. differentmaxFeePerGas
)cancelled
: The Transaction has been cancelled (e.g.value === 0n
)replaced
: The Transaction has been replaced (e.g. differentvalue
ordata
)
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const transactionReceipt = await client.waitForTransactionReceipt({
hash: "0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d",
});
watchBlockNumber: (
args
) =>WatchBlockNumberReturnType
Watches and returns incoming block numbers.
- Docs: https://viem.sh/docs/actions/public/watchBlockNumber
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks/watching-blocks
- JSON-RPC Methods:
- When
poll: true
, callseth_blockNumber
on a polling interval. - When
poll: false
& WebSocket Transport, uses a WebSocket subscription viaeth_subscribe
and the"newHeads"
event.
- When
• args: WatchBlockNumberParameters
WatchBlockNumberParameters
WatchBlockNumberReturnType
A function that can be invoked to stop watching for new block numbers. WatchBlockNumberReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const unwatch = await client.watchBlockNumber({
onBlockNumber: (blockNumber) => console.log(blockNumber),
});
watchBlocks: <
includeTransactions
,blockTag
>(args
) =>WatchBlocksReturnType
Watches and returns information for incoming blocks.
- Docs: https://viem.sh/docs/actions/public/watchBlocks
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks/watching-blocks
- JSON-RPC Methods:
- When
poll: true
, callseth_getBlockByNumber
on a polling interval. - When
poll: false
& WebSocket Transport, uses a WebSocket subscription viaeth_subscribe
and the"newHeads"
event.
- When
• includeTransactions extends boolean
= false
• blockTag extends BlockTag
= "latest"
• args: WatchBlocksParameters
<Transport
, Chain
, includeTransactions
, blockTag
>
WatchBlocksParameters
WatchBlocksReturnType
A function that can be invoked to stop watching for new block numbers. WatchBlocksReturnType
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const unwatch = await client.watchBlocks({
onBlock: (block) => console.log(block),
});
watchContractEvent: <
abi
,eventName
,strict
>(args
) =>WatchContractEventReturnType
Watches and returns emitted contract event logs.
• abi extends Abi
| readonly unknown
[]
• eventName extends string
• strict extends undefined
| boolean
= undefined
• args: WatchContractEventParameters
<abi
, eventName
, strict
, Transport
>
WatchContractEventParameters
WatchContractEventReturnType
A function that can be invoked to stop watching for new event logs. WatchContractEventReturnType
This Action will batch up all the event logs found within the pollingInterval
, and invoke them via onLogs
.
watchContractEvent
will attempt to create an Event Filter and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. eth_newFilter
), then watchContractEvent
will fall back to using getLogs
instead.
import { createPublicClient, http, parseAbi } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const unwatch = client.watchContractEvent({
address: "0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2",
abi: parseAbi([
"event Transfer(address indexed from, address indexed to, uint256 value)",
]),
eventName: "Transfer",
args: { from: "0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b" },
onLogs: (logs) => console.log(logs),
});
watchEvent: <
abiEvent
,abiEvents
,strict
>(args
) =>WatchEventReturnType
Watches and returns emitted Event Logs.
- Docs: https://viem.sh/docs/actions/public/watchEvent
- JSON-RPC Methods:
- RPC Provider supports
eth_newFilter
:- Calls
eth_newFilter
to create a filter (called on initialize). - On a polling interval, it will call
eth_getFilterChanges
.
- Calls
- RPC Provider does not support
eth_newFilter
:- Calls
eth_getLogs
for each block between the polling interval.
- Calls
- RPC Provider supports
• abiEvent extends undefined
| AbiEvent
= undefined
• abiEvents extends undefined
| readonly unknown
[] | readonly AbiEvent
[] = abiEvent
extends AbiEvent
? [abiEvent
<abiEvent
>] : undefined
• strict extends undefined
| boolean
= undefined
• args: WatchEventParameters
<abiEvent
, abiEvents
, strict
, Transport
>
WatchEventParameters
WatchEventReturnType
A function that can be invoked to stop watching for new Event Logs. WatchEventReturnType
This Action will batch up all the Event Logs found within the pollingInterval
, and invoke them via onLogs
.
watchEvent
will attempt to create an Event Filter and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. eth_newFilter
), then watchEvent
will fall back to using getLogs
instead.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const unwatch = client.watchEvent({
onLogs: (logs) => console.log(logs),
});
watchPendingTransactions: (
args
) =>WatchPendingTransactionsReturnType
Watches and returns pending transaction hashes.
- Docs: https://viem.sh/docs/actions/public/watchPendingTransactions
- JSON-RPC Methods:
- When
poll: true
- Calls
eth_newPendingTransactionFilter
to initialize the filter. - Calls
eth_getFilterChanges
on a polling interval.
- Calls
- When
poll: false
& WebSocket Transport, uses a WebSocket subscription viaeth_subscribe
and the"newPendingTransactions"
event.
- When
• args: WatchPendingTransactionsParameters
<Transport
>
WatchPendingTransactionsParameters
WatchPendingTransactionsReturnType
A function that can be invoked to stop watching for new pending transaction hashes. WatchPendingTransactionsReturnType
This Action will batch up all the pending transactions found within the pollingInterval
, and invoke them via onTransactions
.
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
const unwatch = await client.watchPendingTransactions({
onTransactions: (hashes) => console.log(hashes),
});
packages/sdk/src/client.ts:218
getQuote(
params
):Promise
<Quote
>
Get a quote for a given set of parameters. See getQuote.
• params: Omit
<GetQuoteParams
, "logger"
| "apiUrl"
>
See GetQuoteParams.
Promise
<Quote
>
See Quote.
packages/sdk/src/client.ts:412
getSuggestedFees(
params
):Promise
<GetSuggestedFeesReturnType
>
Get the suggested fees for a given route. See getSuggestedFees.
• params: Omit
<GetSuggestedFeesParams
, "logger"
| "apiUrl"
>
Promise
<GetSuggestedFeesReturnType
>
See GetSuggestedFeesReturnType.
packages/sdk/src/client.ts:335
getSupportedChains(
params
):Promise
<ChainsQueryResponse
>
• params: Omit
<GetSupportedChainsParams
, "logger"
| "apiUrl"
>
Promise
<ChainsQueryResponse
>
packages/sdk/src/client.ts:549
simulateDepositTx(
params
):Promise
<SimulateContractReturnType
>
• params: Omit
<SimulateDepositTxParams
, "logger"
| "publicClient"
| "integratorId"
>
Promise
<SimulateContractReturnType
>
packages/sdk/src/client.ts:443
simulateTxOnTenderly(
params
):Promise
<object
>
• params: Omit
<TenderlySimulateTxParams
, "accessKey"
| "accountSlug"
| "enableShare"
| "projectSlug"
>
Promise
<object
>
simulationId:
string
simulationUrl:
string
=url
packages/sdk/src/client.ts:559
update(
params
):void
• params: Pick
<AcrossClientOptions
, "walletClient"
>
void
packages/sdk/src/client.ts:211
waitForDepositTx(
params
):Promise
<DepositStatus
>
• params: Omit
<WaitForDepositTxParams
, "publicClient"
>
Promise
<DepositStatus
>
packages/sdk/src/client.ts:487
waitForFillTx(
params
):Promise
<FillStatus
>
• params: Omit
<WaitForFillTxParams
, "destinationChainClient"
>
Promise
<FillStatus
>
packages/sdk/src/client.ts:515
static
create(options
):AcrossClient
Create a new AcrossClient
instance as a singleton.
• options: AcrossClientOptions
See AcrossClientOptions.
A new AcrossClient
instance if it doesn't exist, otherwise the existing
instance.
packages/sdk/src/client.ts:190
static
getInstance():AcrossClient
Get the existing AcrossClient
singleton instance.
The existing AcrossClient
instance.
If the instance is not initialized.