viem
Version:
6,202 lines • 188 kB
text/typescript
import type { Address } from 'abitype'
import type { Account } from '../accounts/types.js'
import { bindActionDecorators, type Client } from '../clients/createClient.js'
import type { Transport } from '../clients/transports/createTransport.js'
import type { Chain } from '../types/chain.js'
import * as accessKeyActions from './actions/accessKey.js'
import * as ammActions from './actions/amm.js'
import * as channelActions from './actions/channel.js'
import * as dexActions from './actions/dex.js'
import * as earnActions from './actions/earn.js'
import * as faucetActions from './actions/faucet.js'
import * as feeActions from './actions/fee.js'
import * as multisigActions from './actions/multisig.js'
import * as nonceActions from './actions/nonce.js'
import * as policyActions from './actions/policy.js'
import * as receivePolicyActions from './actions/receivePolicy.js'
import * as rewardActions from './actions/reward.js'
import * as simulateActions from './actions/simulate.js'
import * as tokenActions from './actions/token.js'
import * as validatorActions from './actions/validator.js'
import * as virtualAddressActions from './actions/virtualAddress.js'
import * as zoneActions from './actions/zone.js'
type DecoratorBase<
chain extends Chain | undefined = Chain | undefined,
account extends Account | undefined = Account | undefined,
> = {
accessKey: {
/**
* Authorizes an access key by signing a key authorization and sending a transaction.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions, Account } from 'viem/tempo'
* import { generatePrivateKey } from 'viem/accounts'
*
* const account = Account.from({ privateKey: '0x...' })
* const client = createClient({
* account,
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const accessKey = Account.fromP256(generatePrivateKey(), {
* access: account,
* })
*
* const hash = await client.accessKey.authorize({
* accessKey,
* expiry: Math.floor((Date.now() + 30_000) / 1000),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
authorize: (
parameters: accessKeyActions.authorize.Parameters<chain, account>,
) => Promise<accessKeyActions.authorize.ReturnValue>
/**
* Authorizes an access key and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions, Account } from 'viem/tempo'
* import { generatePrivateKey } from 'viem/accounts'
*
* const account = Account.from({ privateKey: '0x...' })
* const client = createClient({
* account,
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const accessKey = Account.fromP256(generatePrivateKey(), {
* access: account,
* })
*
* const { receipt, ...result } = await client.accessKey.authorizeSync({
* accessKey,
* expiry: Math.floor((Date.now() + 30_000) / 1000),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
authorizeSync: (
parameters: accessKeyActions.authorizeSync.Parameters<chain, account>,
) => Promise<accessKeyActions.authorizeSync.ReturnValue>
/**
* Burns a key-authorization witness, invalidating any authorization bound
* to it before it is submitted onchain.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.accessKey.burnWitness({
* witness: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
burnWitness: (
parameters: accessKeyActions.burnWitness.Parameters<chain, account>,
) => Promise<accessKeyActions.burnWitness.ReturnValue>
/**
* Burns a key-authorization witness and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.accessKey.burnWitnessSync({
* witness: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
burnWitnessSync: (
parameters: accessKeyActions.burnWitnessSync.Parameters<chain, account>,
) => Promise<accessKeyActions.burnWitnessSync.ReturnValue>
/**
* Gets access key information.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const key = await client.accessKey.getMetadata({
* account: '0x...',
* accessKey: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The key information.
*/
getMetadata: (
parameters: accessKeyActions.getMetadata.Parameters<account>,
) => Promise<accessKeyActions.getMetadata.ReturnValue>
/**
* Gets the remaining spending limit for a key-token pair.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { remaining, periodEnd } = await client.accessKey.getRemainingLimit({
* account: '0x...',
* accessKey: '0x...',
* token: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The remaining spending amount and period end timestamp.
*/
getRemainingLimit: (
parameters: accessKeyActions.getRemainingLimit.Parameters<account>,
) => Promise<accessKeyActions.getRemainingLimit.ReturnValue>
/**
* Checks whether an access key is an admin key for an account.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const isAdmin = await client.accessKey.isAdmin({
* account: '0x...',
* accessKey: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns Whether the access key is an admin key.
*/
isAdmin: (
parameters: accessKeyActions.isAdmin.Parameters<account>,
) => Promise<accessKeyActions.isAdmin.ReturnValue>
/**
* Checks whether a key-authorization witness has been burned for an account.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const isBurned = await client.accessKey.isWitnessBurned({
* account: '0x...',
* witness: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns Whether the witness has been burned.
*/
isWitnessBurned: (
parameters: accessKeyActions.isWitnessBurned.Parameters<account>,
) => Promise<accessKeyActions.isWitnessBurned.ReturnValue>
/**
* Revokes an authorized access key.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.accessKey.revoke({
* accessKey: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
revoke: (
parameters: accessKeyActions.revoke.Parameters<chain, account>,
) => Promise<accessKeyActions.revoke.ReturnValue>
/**
* Revokes an authorized access key and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.accessKey.revokeSync({
* accessKey: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
revokeSync: (
parameters: accessKeyActions.revokeSync.Parameters<chain, account>,
) => Promise<accessKeyActions.revokeSync.ReturnValue>
/**
* Signs a key authorization or adds one coordinated multisig approval.
*
* @example
* ```ts
* const pending = await client.accessKey.signAuthorization({
* accessKey,
* account: multisig,
* owner: owner_1,
* })
* const success = await client.accessKey.signAuthorization({
* hash: pending.hash,
* owner: owner_2,
* })
* ```
*
* @param parameters - Authorization fields, or a stored operation hash.
* @returns A signed key authorization with multisig operation metadata when coordinated.
*/
signAuthorization: {
(
parameters: accessKeyActions.signAuthorization.CoordinatedParameters,
): Promise<accessKeyActions.signAuthorization.CoordinatedReturnValue>
(
parameters: accessKeyActions.signAuthorization.LocalParameters<account>,
): Promise<accessKeyActions.signAuthorization.ReturnValue>
}
/**
* Updates the spending limit for a specific token on an authorized access key.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.accessKey.updateLimit({
* accessKey: '0x...',
* token: '0x...',
* limit: 1000000000000000000n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
updateLimit: (
parameters: accessKeyActions.updateLimit.Parameters<chain, account>,
) => Promise<accessKeyActions.updateLimit.ReturnValue>
/**
* Updates the spending limit and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.accessKey.updateLimitSync({
* accessKey: '0x...',
* token: '0x...',
* limit: 1000000000000000000n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
updateLimitSync: (
parameters: accessKeyActions.updateLimitSync.Parameters<chain, account>,
) => Promise<accessKeyActions.updateLimitSync.ReturnValue>
/**
* Watches for admin key authorization events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.accessKey.watchAdminAuthorized({
* onAuthorized: (args, log) => {
* console.log('Admin key authorized:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchAdminAuthorized: (
parameters: accessKeyActions.watchAdminAuthorized.Parameters,
) => ReturnType<typeof accessKeyActions.watchAdminAuthorized>
/**
* Watches for key-authorization witness events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.accessKey.watchWitness({
* onWitness: (args, log) => {
* console.log('Witness used:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchWitness: (
parameters: accessKeyActions.watchWitness.Parameters,
) => ReturnType<typeof accessKeyActions.watchWitness>
/**
* Watches for key-authorization witness burned events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.accessKey.watchWitnessBurned({
* onBurned: (args, log) => {
* console.log('Witness burned:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchWitnessBurned: (
parameters: accessKeyActions.watchWitnessBurned.Parameters,
) => ReturnType<typeof accessKeyActions.watchWitnessBurned>
}
amm: {
/**
* Gets the reserves for a liquidity pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c...001' }),
* transport: http(),
* }).extend(tempoActions())
*
* const pool = await client.amm.getPool({
* userToken: '0x...',
* validatorToken: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The pool reserves.
*/
getPool: (
parameters: ammActions.getPool.Parameters,
) => Promise<ammActions.getPool.ReturnValue>
/**
* Gets the LP token balance for an account in a specific pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const poolId = await client.amm.getPoolId({
* userToken: '0x...',
* validatorToken: '0x...',
* })
*
* const balance = await client.amm.getLiquidityBalance({
* poolId,
* address: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The LP token balance.
*/
getLiquidityBalance: (
parameters: ammActions.getLiquidityBalance.Parameters,
) => Promise<ammActions.getLiquidityBalance.ReturnValue>
/**
* Removes liquidity from a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.amm.burn({
* userToken: '0x...',
* validatorToken: '0x...',
* liquidity: 50n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
burn: (
parameters: ammActions.burn.Parameters<chain, account>,
) => Promise<ammActions.burn.ReturnValue>
/**
* Removes liquidity from a pool and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.amm.burnSync({
* userToken: '0x...',
* validatorToken: '0x...',
* liquidity: 50n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
burnSync: (
parameters: ammActions.burnSync.Parameters<chain, account>,
) => Promise<ammActions.burnSync.ReturnValue>
/**
* Adds liquidity to a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.amm.mint({
* userTokenAddress: '0x...',
* validatorTokenAddress: '0x...',
* validatorTokenAmount: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
mint: (
parameters: ammActions.mint.Parameters<chain, account>,
) => Promise<ammActions.mint.ReturnValue>
/**
* Adds liquidity to a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.amm.mintSync({
* userTokenAddress: '0x...',
* validatorTokenAddress: '0x...',
* validatorTokenAmount: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
mintSync: (
parameters: ammActions.mintSync.Parameters<chain, account>,
) => Promise<ammActions.mintSync.ReturnValue>
/**
* Swaps tokens during a rebalance operation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.amm.rebalanceSwap({
* userToken: '0x...',
* validatorToken: '0x...',
* amountOut: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
rebalanceSwap: (
parameters: ammActions.rebalanceSwap.Parameters<chain, account>,
) => Promise<ammActions.rebalanceSwap.ReturnValue>
/**
* Swaps tokens during a rebalance operation and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.amm.rebalanceSwapSync({
* userToken: '0x...',
* validatorToken: '0x...',
* amountOut: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
rebalanceSwapSync: (
parameters: ammActions.rebalanceSwapSync.Parameters<chain, account>,
) => Promise<ammActions.rebalanceSwapSync.ReturnValue>
/**
* Watches for burn (liquidity removal) events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.amm.watchBurn({
* onBurn: (args, log) => {
* console.log('Liquidity removed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBurn: (parameters: ammActions.watchBurn.Parameters) => () => void
/**
* Watches for liquidity mint events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.amm.watchMint({
* onMint: (args, log) => {
* console.log('Liquidity added:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchMint: (parameters: ammActions.watchMint.Parameters) => () => void
/**
* Watches for rebalance swap events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.amm.watchRebalanceSwap({
* onRebalanceSwap: (args, log) => {
* console.log('Rebalance swap:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchRebalanceSwap: (
parameters: ammActions.watchRebalanceSwap.Parameters,
) => () => void
}
channel: {
/**
* Closes a TIP-20 channel reserve channel from the payee or operator side.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const hash = await client.channel.close({
* captureAmount: parseUnits('40', 6),
* cumulativeAmount: parseUnits('80', 6),
* channel,
* signature: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
close: (
parameters: channelActions.close.Parameters<chain, account>,
) => Promise<channelActions.close.ReturnValue>
/**
* Closes a TIP-20 channel reserve channel and waits for the transaction receipt.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const result = await client.channel.closeSync({
* captureAmount: parseUnits('40', 6),
* cumulativeAmount: parseUnits('80', 6),
* channel,
* signature: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
closeSync: (
parameters: channelActions.closeSync.Parameters<chain, account>,
) => Promise<channelActions.closeSync.ReturnValue>
/**
* Gets TIP-20 channel reserve state for a channel ID or channel.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c...001' }),
* transport: http(),
* }).extend(tempoActions())
*
* const state = await client.channel.getStates({
* channel: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns Channel state for a single channel, or channel states for multiple channels.
*/
getStates: <
const channel extends
| channelActions.getStates.Channel
| readonly channelActions.getStates.Channel[],
>(
parameters: channelActions.getStates.Parameters<channel>,
) => Promise<channelActions.getStates.ReturnValue<channel>>
/**
* Opens and funds a TIP-20 channel reserve channel.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const hash = await client.channel.open({
* deposit: parseUnits('100', 6),
* payee: '0x...',
* token: 1n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
open: (
parameters: channelActions.open.Parameters<chain, account>,
) => Promise<channelActions.open.ReturnValue>
/**
* Opens and funds a TIP-20 channel reserve channel and waits for the transaction receipt.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const result = await client.channel.openSync({
* deposit: parseUnits('100', 6),
* payee: '0x...',
* token: 1n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
openSync: (
parameters: channelActions.openSync.Parameters<chain, account>,
) => Promise<channelActions.openSync.ReturnValue>
/**
* Starts the payer close timer for a TIP-20 channel reserve channel.
*
* @example
* ```ts
* const hash = await client.channel.requestClose({
* channel,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
requestClose: (
parameters: channelActions.requestClose.Parameters<chain, account>,
) => Promise<channelActions.requestClose.ReturnValue>
/**
* Starts the payer close timer and waits for the transaction receipt.
*
* @example
* ```ts
* const result = await client.channel.requestCloseSync({
* channel,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
requestCloseSync: (
parameters: channelActions.requestCloseSync.Parameters<chain, account>,
) => Promise<channelActions.requestCloseSync.ReturnValue>
/**
* Settles a TIP-20 channel reserve voucher.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const hash = await client.channel.settle({
* cumulativeAmount: parseUnits('40', 6),
* channel,
* signature: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
settle: (
parameters: channelActions.settle.Parameters<chain, account>,
) => Promise<channelActions.settle.ReturnValue>
/**
* Settles a TIP-20 channel reserve voucher and waits for the transaction receipt.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const result = await client.channel.settleSync({
* cumulativeAmount: parseUnits('40', 6),
* channel,
* signature: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
settleSync: (
parameters: channelActions.settleSync.Parameters<chain, account>,
) => Promise<channelActions.settleSync.ReturnValue>
/**
* Signs a TIP-20 channel reserve voucher.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const signature = await client.channel.signVoucher({
* channel,
* cumulativeAmount: parseUnits('40', 6),
* })
* ```
*
* @param parameters - Parameters.
* @returns The voucher signature.
*/
signVoucher: (
parameters: channelActions.signVoucher.Parameters<account>,
) => Promise<channelActions.signVoucher.ReturnValue>
/**
* Adds deposit to a TIP-20 channel reserve channel.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const hash = await client.channel.topUp({
* additionalDeposit: parseUnits('50', 6),
* channel,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
topUp: (
parameters: channelActions.topUp.Parameters<chain, account>,
) => Promise<channelActions.topUp.ReturnValue>
/**
* Adds deposit to a TIP-20 channel reserve channel and waits for the transaction receipt.
*
* @example
* ```ts
* import { parseUnits } from 'viem'
*
* const result = await client.channel.topUpSync({
* additionalDeposit: parseUnits('50', 6),
* channel,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
topUpSync: (
parameters: channelActions.topUpSync.Parameters<chain, account>,
) => Promise<channelActions.topUpSync.ReturnValue>
/**
* Withdraws payer funds after the close grace period elapses.
*
* @example
* ```ts
* const hash = await client.channel.withdraw({
* channel,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
withdraw: (
parameters: channelActions.withdraw.Parameters<chain, account>,
) => Promise<channelActions.withdraw.ReturnValue>
/**
* Withdraws payer funds and waits for the transaction receipt.
*
* @example
* ```ts
* const result = await client.channel.withdrawSync({
* channel,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
withdrawSync: (
parameters: channelActions.withdrawSync.Parameters<chain, account>,
) => Promise<channelActions.withdrawSync.ReturnValue>
}
dex: {
/**
* Buys a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.buy({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountOut: 100n,
* maxAmountIn: 105n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
buy: (
parameters: dexActions.buy.Parameters<chain, account>,
) => Promise<dexActions.buy.ReturnValue>
/**
* Buys a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.buySync({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountOut: 100n,
* maxAmountIn: 105n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
buySync: (
parameters: dexActions.buySync.Parameters<chain, account>,
) => Promise<dexActions.buySync.ReturnValue>
/**
* Cancels an order from the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.cancel({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
cancel: (
parameters: dexActions.cancel.Parameters<chain, account>,
) => Promise<dexActions.cancel.ReturnValue>
/**
* Cancels an order from the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.cancelSync({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
cancelSync: (
parameters: dexActions.cancelSync.Parameters<chain, account>,
) => Promise<dexActions.cancelSync.ReturnValue>
/**
* Cancels a stale order from the orderbook.
*
* A stale order is one where the maker has been blacklisted by a TIP-403 policy.
* Anyone can cancel stale orders.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.cancelStale({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
cancelStale: (
parameters: dexActions.cancelStale.Parameters<chain, account>,
) => Promise<dexActions.cancelStale.ReturnValue>
/**
* Cancels a stale order from the orderbook and waits for confirmation.
*
* A stale order is one where the maker has been blacklisted by a TIP-403 policy.
* Anyone can cancel stale orders.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.cancelStaleSync({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
cancelStaleSync: (
parameters: dexActions.cancelStaleSync.Parameters<chain, account>,
) => Promise<dexActions.cancelStaleSync.ReturnValue>
/**
* Creates a new trading pair on the DEX.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.createPair({
* base: '0x20c...11',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
createPair: (
parameters: dexActions.createPair.Parameters<chain, account>,
) => Promise<dexActions.createPair.ReturnValue>
/**
* Creates a new trading pair on the DEX.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.createPairSync({
* base: '0x20c...11',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
createPairSync: (
parameters: dexActions.createPairSync.Parameters<chain, account>,
) => Promise<dexActions.createPairSync.ReturnValue>
/**
* Gets a user's token balance on the DEX.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const balance = await client.dex.getBalance({
* account: '0x...',
* token: '0x20c...11',
* })
* ```
*
* @param parameters - Parameters.
* @returns The user's token balance on the DEX.
*/
getBalance: (
parameters: dexActions.getBalance.Parameters<account>,
) => Promise<dexActions.getBalance.ReturnValue>
/**
* Gets the quote for buying a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const amountIn = await client.dex.getBuyQuote({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountOut: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The amount of tokenIn needed to buy the specified amountOut.
*/
getBuyQuote: (
parameters: dexActions.getBuyQuote.Parameters,
) => Promise<dexActions.getBuyQuote.ReturnValue>
/**
* Gets an order's details from the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const order = await client.dex.getOrder({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The order details.
*/
getOrder: (
parameters: dexActions.getOrder.Parameters,
) => Promise<dexActions.getOrder.ReturnValue>
/**
* Gets the price level information at a specific tick.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions, Tick } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const level = await client.dex.getTickLevel({
* base: '0x20c...11',
* tick: Tick.fromPrice('1.001'),
* isBid: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The price level information.
*/
getTickLevel: (
parameters: dexActions.getTickLevel.Parameters,
) => Promise<dexActions.getTickLevel.ReturnValue>
/**
* Gets the quote for selling a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const amountOut = await client.dex.getSellQuote({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountIn: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The amount of tokenOut received for selling the specified amountIn.
*/
getSellQuote: (
parameters: dexActions.getSellQuote.Parameters,
) => Promise<dexActions.getSellQuote.ReturnValue>
/**
* Places a limit order on the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions, Tick } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.place({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
place: (
parameters: dexActions.place.Parameters<chain, account>,
) => Promise<dexActions.place.ReturnValue>
/**
* Places a limit order on the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions, Tick } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.placeSync({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
placeSync: (
parameters: dexActions.placeSync.Parameters<chain, account>,
) => Promise<dexActions.placeSync.ReturnValue>
/**
* Places a flip order that automatically flips when filled.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions, Tick } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.placeFlip({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* flipTick: Tick.fromPrice('1.01'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
placeFlip: (
parameters: dexActions.placeFlip.Parameters<chain, account>,
) => Promise<dexActions.placeFlip.ReturnValue>
/**
* Places a flip order that automatically flips when filled.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions, Tick } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.placeFlipSync({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* flipTick: Tick.fromPrice('1.01'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
placeFlipSync: (
parameters: dexActions.placeFlipSync.Parameters<chain, account>,
) => Promise<dexActions.placeFlipSync.ReturnValue>
/**
* Sells a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.sell({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountIn: 100n,
* minAmountOut: 95n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
sell: (
parameters: dexActions.sell.Parameters<chain, account>,
) => Promise<dexActions.sell.ReturnValue>
/**
* Sells a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.sellSync({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountIn: 100n,
* minAmountOut: 95n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
sellSync: (
parameters: dexActions.sellSync.Parameters<chain, account>,
) => Promise<dexActions.sellSync.ReturnValue>
/**
* Withdraws tokens from the DEX to the caller's wallet.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.withdraw({
* token: '0x20c...11',
* amount: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
withdraw: (
parameters: dexActions.withdraw.Parameters<chain, account>,
) => Promise<dexActions.withdraw.ReturnValue>
/**
* Withdraws tokens from the DEX to the caller's wallet.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.withdrawSync({
* token: '0x20c...11',
* amount: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
withdrawSync: (
parameters: dexActions.withdrawSync.Parameters<chain, account>,
) => Promise<dexActions.withdrawSync.ReturnValue>
/**
* Watches for flip order placed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchFlipOrderPlaced({
* onFlipOrderPlaced: (args, log) => {
* console.log('Flip order placed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchFlipOrderPlaced: (
parameters: dexActions.watchFlipOrderPlaced.Parameters,
) => () => void
/**
* Watches for order cancelled events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchOrderCancelled({
* onOrderCancelled: (args, log) => {
* console.log('Order cancelled:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchOrderCancelled: (
parameters: dexActions.watchOrderCancelled.Parameters,
) => () => void
/**
* Watches for order filled events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchOrderFilled({
* onOrderFilled: (args, log) => {
* console.log('Order filled:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchOrderFilled: (
parameters: dexActions.watchOrderFilled.Parameters,
) => () => void
/**
* Watches for order placed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchOrderPlaced({
* onOrderPlaced: (args, log) => {
* console.log('Order placed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchOrderPlaced: (
parameters: dexActions.watchOrderPlaced.Parameters,
) => () => void
}
earn: {
/** Deploys a deterministic ERC-4626 engine. */
createErc4626Engine: (
parameters: earnActions.createErc4626Engine.Parameters<chain, account>,
) => Promise<earnActions.createErc4626Engine.ReturnValue>
/** Deploys a deterministic ERC-4626 engine and waits for confirmation. */
createErc4626EngineSync: (
parameters: earnActions.createErc4626EngineSync.Parameters<
chain,
account
>,
) => Promise<earnActions.createErc4626EngineSync.ReturnValue>
/** Deploys the EarnShare, EarnVault, and EarnFees contracts. */
createStack: (
parameters: earnActions.createStack.Parameters<chain, account>,
) => Promise<earnActions.createStack.ReturnValue>
/** Deploys an Earn stack and waits for confirmation. */
createStackSync: (
parameters: earnActions.createStackSync.Parameters<chain, account>,
) => Promise<earnActions.createStackSync.ReturnValue>
/** Binds an engine to its EarnVault. */
bindEngine: (
parameters: earnActions.bindEngine.Parameters<chain, account>,
) => Promise<earnActions.bindEngine.ReturnValue>
/** Binds an engine and waits for confirmation. */
bindEngineSync: (
parameters: earnActions.bindEngineSync.Parameters<chain, account>,
) => Promise<earnActions.bindEngineSync.ReturnValue>
/** Deploys and binds a complete, resumable ERC-4626 Earn stack. */
deployErc4626StackSync: (
parameters: earnActions.deployErc4626StackSync.Parameters<chain, account>,
) => Promise<earnActions.deployErc4626StackSync.ReturnValue>
/**
* Creates and attaches an admission-only TIP-403 policy to an Earn share
* token. Existing holders remain able to send shares while
* recipients and mint recipients must belong to the same whitelist.
*
* @example
* ```ts
* const { policy } = await client.earn.configureExitSafePolicy({
* accessAdministrator: '0x...',
* initialMembers: ['0x...', '0x...'],
* shareToken: '0x...',
* })
* ```
*
* @param parameters - Share token, administrator, and initial members.
* @returns The configured policy IDs and transaction receipts.
*/
configureExitSafePolicy: (
parameters: earnActions.configureExitSafePolicy.Parameters<account>,
) => Promise<earnActions.configureExitSafePolicy.ReturnValue>
/**
* Deposits assets into a vault and mints Earn shares to `recipient`. The
* transaction includes the required asset approval.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.earn.deposit({
* assetAmount: 100_000_000n,
* shareAmountMin: 99_400_000n,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
deposit: (
parameters: earnActions.deposit.Parameters<chain, account>,
) => Promise<earnActions.deposit.ReturnValue>
/**
* Deposits venue shares into a vault and mints Earn shares to
* `recipient`. The transaction includes the required venue share approval.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.earn.depositShares({
* earnShareAmountMin: 499_000_000n,
* vault: '0x...',
* venueShareAmount: 500_000_000n,
* venueShareToken: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
depositShares: (
parameters: earnActions.depositShares.Parameters<chain, account>,
) => Promise<earnActions.depositShares.ReturnValue>
/**
* Deposits venue shares and returns the confirmed receipt and event data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const { earnShareAmount } = await client.earn.depositSharesSync({
* earnShareAmountMin: 499_000_000n,
* vault: '0x...',
* venueShareAmount: 500_000_000n,
* venueShareToken: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
depositSharesSync: (
parameters: earnActions.depositSharesSync.Parameters<chain, account>,
) => Promise<earnActions.depositSharesSync.ReturnValue>
/**
* Deposits assets and returns the confirmed receipt and event data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const { shareAmount } = await client.earn.depositSync({
* assetAmount: 100_000_000n,
* shareAmountMin: 99_400_000n,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
depositSync: (
parameters: earnActions.depositSync.Parameters<chain, account>,
) => Promise<earnActions.depositSync.ReturnValue>
/**
* Withdraws assets from a Zone and deposits them into a vault on the
* parent chain.
*
* @example
* ```ts
* const prepared = await parentClient.earn.privateDeposit.prepare({
* assetAmount: 100_000_000n,
* assetToken: '0x...',
* gateway: '0x...',
* recipient: '0x...',
* shareAmountMin: 99_500_000n,
* tempoRefundRecipient: '0x...',
* vault: '0x...',
* vaultAssetAmountMin: 99_000_000n,
* zoneId: 7,
* })
* const hash = await zoneClient.earn.privateDeposit(prepared)
* ```
*
* @param parameters - Prepared deposit and transaction parameters.
* @returns The transaction hash.
*/
privateDeposit: (
parameters: earnActions.privateDeposit.Parameters<chain, account>,
) => Promise<earnActions.privateDeposit.ReturnValue>
/**
* Requests a private Zone deposit and waits for the Zone transaction
* receipt.
*
* @example
* ```ts
* const { receipt, senderTag } =
* await zoneClient.earn.privateDepositSync(prepared)
* ```
*
* @param parameters - Prepared deposit and transaction parameters.
* @returns The Zone transaction receipt and parent-chain withdrawal sender tag.
*/
privateDepositSync: (
parameters: earnActions.privateDepositSync.Parameters<chain, account>,
) => Promise<earnActions.privateDepositSync.ReturnValue>
/**
* Gets the vault's active fee configuration, pending fees, and fee baselines.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const feeState = await client.earn.getFeeState({
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The active fee configuration, pending fees, and baselines.
*/
getFeeState: (
parameters: earnActions.getFeeState.Parameters,
) => Promise<earnActions.getFeeState.ReturnValue>
/**
* Gets an account's asset and Earn share balances, allowances, and
* current share value. The value includes fees.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const position = await client.earn.getPosition({
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The asset and Earn share balances, allowances, and value.
*/
getPosition: (
parameters: earnActions.getPosition.Parameters<account>,
) => Promise<earnActions.getPosition.ReturnValue>
/**
* Gets the vault's addresses, configuration, accounting state, and
* supported actions. Throws `GetVaultEngineChangedError` if its engine
* changes mid-read.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const vault = await client.earn.getVault({
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The vault state and metadata.
*/
getVault: (
parameters: earnActions.getVault.Parameters,
) => Promise<earnActions.getVault.ReturnValue>
/**
* Gets the asset output for an exact Earn share input, including fees.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const assetAmount = await client.earn.getRedeemQuote({
* shareAmount: 100_000_000n,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The asset output, including fees.
*/
getRedeemQuote: (
parameters: earnActions.getRedeemQuote.Parameters,
) => Promise<earnActions.getRedeemQuote.ReturnValue>
/**
* Gets the Earn shares required for an exact asset output, including
* fees and ceiling rounding.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const shareAmount = await client.earn.getWithdrawQuote({
* assetAmount: 250_000_000n,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The required Earn share input, ceiling-rounded.
*/
getWithdrawQuote: (
parameters: earnActions.getWithdrawQuote.Parameters,
) => Promise<earnActions.getWithdrawQuote.ReturnValue>
/**
* Redeems Earn shares for assets sent to `recipient`. The transaction
* includes the required Earn share approval.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.earn.redeem({
* shareAmount: 100_000_000n,
* slippageBps: 50,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
redeem: (
parameters: earnActions.redeem.Parameters<chain, account>,
) => Promise<earnActions.redeem.ReturnValue>
/**
* Redeems Earn shares and returns the confirmed receipt and event data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const { assetAmount } = await client.earn.redeemSync({
* assetAmountMin: 99_500_000n,
* shareAmount: 100_000_000n,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
redeemSync: (
parameters: earnActions.redeemSync.Parameters<chain, account>,
) => Promise<earnActions.redeemSync.ReturnValue>
/**
* Withdraws Earn shares from a Zone and redeems them on the parent chain.
*
* @example
* ```ts
* const prepared = await parentClient.earn.privateRedeem.prepare({
* gateway: '0x...',
* recipient: '0x...',
* shareAmount: 100_000_000n,
* slippageBps: 50,
* tempoRefundRecipient: '0x...',
* vault: '0x...',
* zoneId: 7,
* })
* const hash = await zoneClient.earn.privateRedeem(prepared)
* ```
*
* @param parameters - Prepared redemption and transaction parameters.
* @returns The transaction hash.
*/
privateRedeem: (
parameters: earnActions.privateRedeem.Parameters<chain, account>,
) => Promise<earnActions.privateRedeem.ReturnValue>
/**
* Requests a private Zone redemption and waits for the Zone transaction
* receipt.
*
* @example
* ```ts
* const { receipt, senderTag } =
* await zoneClient.earn.privateRedeemSync(prepared)
* ```
*
* @param parameters - Prepared redemption and transaction parameters.
* @returns The Zone transaction receipt and parent-chain withdrawal sender tag.
*/
privateRedeemSync: (
parameters: earnActions.privateRedeemSync.Parameters<chain, account>,
) => Promise<earnActions.privateRedeemSync.ReturnValue>
/**
* Waits for a Zone gateway deposit to complete on the parent chain.
*
* @example
* ```ts
* const result = await parentClient.earn.waitForPrivateDeposit({
* actionId: prepared.actionId,
* fromBlock: prepared.fromBlock,
* gateway: '0x...',
* vault: '0x...',
* })
* ```
*
* @param parameters - Correlation and polling parameters.
* @returns The completed gateway deposit.
*/
waitForPrivateDeposit: (
parameters: earnActions.waitForPrivateDeposit.Parameters,
) => Promise<earnActions.waitForPrivateDeposit.ReturnType>
/**
* Waits for a Zone gateway redemption to complete on the parent chain.
*
* @example
* ```ts
* const result = await parentClient.earn.waitForPrivateRedeem({
* actionId: prepared.actionId,
* fromBlock: prepared.fromBlock,
* gateway: '0x...',
* vault: '0x...',
* })
* ```
*
* @param parameters - Correlation and polling parameters.
* @returns The completed gateway redemption.
*/
waitForPrivateRedeem: (
parameters: earnActions.waitForPrivateRedeem.Parameters,
) => Promise<earnActions.waitForPrivateRedeem.ReturnType>
/**
* Verifies that an Earn share token uses the expected exit-safe
* TIP-403 policy and that every required member can receive transfers and
* mints.
*
* @example
* ```ts
* await client.earn.validateExitSafePolicy({
* accessAdministrator: '0x...',
* policy,
* requiredMembers: ['0x...', '0x...'],
* shareToken: '0x...',
* })
* ```
*
* @param parameters - Expected policy, administrator, and required members.
* @returns Nothing when the policy is valid.
*/
validateExitSafePolicy: (
parameters: earnActions.validateExitSafePolicy.Parameters,
) => Promise<earnActions.validateExitSafePolicy.ReturnValue>
/**
* Withdraws an exact asset amount to `recipient`, up to the specified
* Earn share limit. The transaction includes the required Earn share
* approval; use `redeem` for a full exit.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.earn.withdrawExact({
* assetAmount: 40_000_000n,
* slippageBps: 50,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
withdrawExact: (
parameters: earnActions.withdrawExact.Parameters<chain, account>,
) => Promise<earnActions.withdrawExact.ReturnValue>
/**
* Withdraws an exact asset amount and returns the confirmed receipt and event data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const { shareAmount } = await client.earn.withdrawExactSync({
* assetAmount: 40_000_000n,
* shareAmountMax: 40_200_000n,
* vault: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
withdrawExactSync: (
parameters: earnActions.withdrawExactSync.Parameters<chain, account>,
) => Promise<earnActions.withdrawExactSync.ReturnValue>
}
faucet: {
/**
* Funds an account with an initial amount of set token(s)
* on Tempo's testnet.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hashes = await client.faucet.fund({
* account: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hashes.
*/
fund: (
parameters: faucetActions.fund.Parameters,
) => Promise<faucetActions.fund.ReturnValue>
/**
* Funds an account with an initial amount of set token(s)
* on Tempo's testnet. Waits for the transactions to be included
* on a block before returning a response.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const receipts = await client.faucet.fundSync({
* account: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipts.
*/
fundSync: (
parameters: faucetActions.fundSync.Parameters,
) => Promise<faucetActions.fundSync.ReturnValue>
}
multisig: {
/**
* Gets the current cached config for a multisig account.
*
* @param parameters - Parameters.
* @returns The config, or `null` when it is unknown.
*/
getConfig: (
parameters: multisigActions.getConfig.Parameters,
) => Promise<multisigActions.getConfig.ReturnValue>
/** Gets the current configuration commitment for a multisig account. */
getConfigCommitment: (
parameters: multisigActions.getConfigCommitment.Parameters,
) => Promise<multisigActions.getConfigCommitment.ReturnValue>
/**
* Gets a coordinated multisig operation by its hash.
*
* @param parameters - Parameters.
* @returns The operation, or `null` when it is unknown.
*/
getOperation: (
parameters: multisigActions.getOperation.Parameters,
) => Promise<multisigActions.getOperation.ReturnValue>
/**
* Replaces the current configuration for a native multisig account.
*
* @param parameters - New configuration and transaction parameters.
* @returns The transaction hash.
*/
updateConfig: (
parameters: multisigActions.updateConfig.Parameters<chain, account>,
) => Promise<multisigActions.updateConfig.ReturnValue>
/**
* Replaces a native multisig configuration and waits for confirmation.
*
* @param parameters - New configuration and transaction parameters.
* @returns The update event and transaction receipt.
*/
updateConfigSync: (
parameters: multisigActions.updateConfigSync.Parameters<chain, account>,
) => Promise<multisigActions.updateConfigSync.ReturnValue>
}
nonce: {
/**
* Gets the nonce for an account and nonce key.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const nonce = await client.nonce.getNonce({
* account: '0x...',
* nonceKey: 1n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The nonce value.
*/
getNonce: (
parameters: nonceActions.getNonce.Parameters,
) => Promise<nonceActions.getNonce.ReturnValue>
/**
* Watches for nonce incremented events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.nonce.watchNonceIncremented({
* onNonceIncremented: (args, log) => {
* console.log('Nonce incremented:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchNonceIncremented: (
parameters: nonceActions.watchNonceIncremented.Parameters,
) => () => void
}
fee: {
/**
* Validates that a token can be used as a Tempo fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { address } = await client.fee.validateToken({
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The fee token address, ID, and metadata.
*/
validateToken: (
parameters: feeActions.validateToken.Parameters,
) => Promise<feeActions.validateToken.ReturnValue>
/**
* Gets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { address, id } = await client.token.getUserToken()
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
getUserToken: (
...parameters: account extends Account
? [feeActions.getUserToken.Parameters<account>] | []
: [feeActions.getUserToken.Parameters<account>]
) => Promise<feeActions.getUserToken.ReturnValue>
/**
* Sets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.setUserToken({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setUserToken: (
parameters: feeActions.setUserToken.Parameters<chain, account>,
) => Promise<feeActions.setUserToken.ReturnValue>
/**
* Sets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.fee.setUserTokenSync({
* token: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setUserTokenSync: (
parameters: feeActions.setUserTokenSync.Parameters<chain, account>,
) => Promise<feeActions.setUserTokenSync.ReturnValue>
/**
* Watches for user token set events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchSetUserToken({
* onUserTokenSet: (args, log) => {
* console.log('User token set:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchSetUserToken: (
parameters: feeActions.watchSetUserToken.Parameters,
) => () => void
}
policy: {
/**
* Creates a new policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.create({
* admin: '0x...',
* type: 'whitelist',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
create: (
parameters: policyActions.create.Parameters<chain, account>,
) => Promise<policyActions.create.ReturnValue>
/**
* Creates a new policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.createSync({
* admin: '0x...',
* type: 'whitelist',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
createSync: (
parameters: policyActions.createSync.Parameters<chain, account>,
) => Promise<policyActions.createSync.ReturnValue>
/**
* Sets the admin for a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.setAdmin({
* policyId: 2n,
* admin: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setAdmin: (
parameters: policyActions.setAdmin.Parameters<chain, account>,
) => Promise<policyActions.setAdmin.ReturnValue>
/**
* Sets the admin for a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.setAdminSync({
* policyId: 2n,
* admin: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setAdminSync: (
parameters: policyActions.setAdminSync.Parameters<chain, account>,
) => Promise<policyActions.setAdminSync.ReturnValue>
/**
* Modifies a policy whitelist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.modifyWhitelist({
* policyId: 2n,
* address: '0x...',
* allowed: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
modifyWhitelist: (
parameters: policyActions.modifyWhitelist.Parameters<chain, account>,
) => Promise<policyActions.modifyWhitelist.ReturnValue>
/**
* Modifies a policy whitelist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.modifyWhitelistSync({
* policyId: 2n,
* address: '0x...',
* allowed: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
modifyWhitelistSync: (
parameters: policyActions.modifyWhitelistSync.Parameters<chain, account>,
) => Promise<policyActions.modifyWhitelistSync.ReturnValue>
/**
* Modifies a policy blacklist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.modifyBlacklist({
* policyId: 2n,
* address: '0x...',
* restricted: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
modifyBlacklist: (
parameters: policyActions.modifyBlacklist.Parameters<chain, account>,
) => Promise<policyActions.modifyBlacklist.ReturnValue>
/**
* Modifies a policy blacklist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.modifyBlacklistSync({
* policyId: 2n,
* address: '0x...',
* restricted: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
modifyBlacklistSync: (
parameters: policyActions.modifyBlacklistSync.Parameters<chain, account>,
) => Promise<policyActions.modifyBlacklistSync.ReturnValue>
/**
* Gets policy data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const data = await client.policy.getData({
* policyId: 2n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The policy data.
*/
getData: (
parameters: policyActions.getData.Parameters,
) => Promise<policyActions.getData.ReturnValue>
/**
* Checks if a user is authorized by a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const authorized = await client.policy.isAuthorized({
* policyId: 2n,
* user: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns Whether the user is authorized.
*/
isAuthorized: (
parameters: policyActions.isAuthorized.Parameters,
) => Promise<policyActions.isAuthorized.ReturnValue>
/**
* Watches for policy creation events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchCreate({
* onPolicyCreated: (args, log) => {
* console.log('Policy created:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchCreate: (
parameters: policyActions.watchCreate.Parameters,
) => () => void
/**
* Watches for policy admin update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchAdminUpdated({
* onAdminUpdated: (args, log) => {
* console.log('Policy admin updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchAdminUpdated: (
parameters: policyActions.watchAdminUpdated.Parameters,
) => () => void
/**
* Watches for whitelist update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchWhitelistUpdated({
* onWhitelistUpdated: (args, log) => {
* console.log('Whitelist updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchWhitelistUpdated: (
parameters: policyActions.watchWhitelistUpdated.Parameters,
) => () => void
/**
* Watches for blacklist update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchBlacklistUpdated({
* onBlacklistUpdated: (args, log) => {
* console.log('Blacklist updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBlacklistUpdated: (
parameters: policyActions.watchBlacklistUpdated.Parameters,
) => () => void
}
receivePolicy: {
/**
* Burns the funds backing a blocked receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.receivePolicy.burn({ receipt: '0x...' })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
burn: (
parameters: receivePolicyActions.burn.Parameters<chain, account>,
) => Promise<receivePolicyActions.burn.ReturnValue>
/**
* Burns the funds backing a blocked receipt and waits for the receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.receivePolicy.burnSync({
* receipt: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
burnSync: (
parameters: receivePolicyActions.burnSync.Parameters<chain, account>,
) => Promise<receivePolicyActions.burnSync.ReturnValue>
/**
* Claims blocked funds for a receipt, releasing them to a destination.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.receivePolicy.claim({
* to: '0x...',
* receipt: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
claim: (
parameters: receivePolicyActions.claim.Parameters<chain, account>,
) => Promise<receivePolicyActions.claim.ReturnValue>
/**
* Claims blocked funds for a receipt and waits for the receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.receivePolicy.claimSync({
* to: '0x...',
* receipt: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
claimSync: (
parameters: receivePolicyActions.claimSync.Parameters<chain, account>,
) => Promise<receivePolicyActions.claimSync.ReturnValue>
/**
* Gets the receive policy configured for an account.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const policy = await client.receivePolicy.get({ account: '0x...' })
* ```
*
* @param parameters - Parameters.
* @returns The receive policy.
*/
get: (
parameters: receivePolicyActions.get.Parameters<account>,
) => Promise<receivePolicyActions.get.ReturnValue>
/**
* Gets the blocked balance for an encoded receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const amount = await client.receivePolicy.getBlockedBalance({
* receipt: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The blocked amount for the receipt.
*/
getBlockedBalance: (
parameters: receivePolicyActions.getBlockedBalance.Parameters,
) => Promise<receivePolicyActions.getBlockedBalance.ReturnValue>
/**
* Sets the receive policy for the calling account.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.receivePolicy.set({
* senderPolicyId: 'allow-all',
* tokenPolicyId: 'allow-all',
* claimer: 'self',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
set: (
parameters: receivePolicyActions.set.Parameters<chain, account>,
) => Promise<receivePolicyActions.set.ReturnValue>
/**
* Sets the receive policy for the calling account and waits for the receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.receivePolicy.setSync({
* senderPolicyId: 'allow-all',
* tokenPolicyId: 'allow-all',
* claimer: 'self',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setSync: (
parameters: receivePolicyActions.setSync.Parameters<chain, account>,
) => Promise<receivePolicyActions.setSync.ReturnValue>
/**
* Checks whether a transfer or mint to a receiver is allowed by the
* receiver's receive policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { authorized, blockedReason } = await client.receivePolicy.validate({
* token: '0x...',
* sender: '0x...',
* receiver: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns Whether the transfer is authorized and, if not, why.
*/
validate: (
parameters: receivePolicyActions.validate.Parameters,
) => Promise<receivePolicyActions.validate.ReturnValue>
/**
* Watches for blocked transfer events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.receivePolicy.watchBlocked({
* onBlocked: (args, log) => {
* console.log('Transfer blocked:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBlocked: (
parameters: receivePolicyActions.watchBlocked.Parameters,
) => () => void
/**
* Watches for receipt burned events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.receivePolicy.watchBurned({
* onBurned: (args, log) => {
* console.log('Receipt burned:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBurned: (
parameters: receivePolicyActions.watchBurned.Parameters,
) => () => void
/**
* Watches for receipt claimed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.receivePolicy.watchClaimed({
* onClaimed: (args, log) => {
* console.log('Receipt claimed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchClaimed: (
parameters: receivePolicyActions.watchClaimed.Parameters,
) => () => void
/**
* Watches for receive policy update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.receivePolicy.watchUpdated({
* onUpdated: (args, log) => {
* console.log('Receive policy updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchUpdated: (
parameters: receivePolicyActions.watchUpdated.Parameters,
) => () => void
}
reward: {
/**
* Claims accumulated rewards for a recipient.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.reward.claim({
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
claim: (
parameters: rewardActions.claim.Parameters<chain, account>,
) => Promise<rewardActions.claim.ReturnValue>
/**
* Claims accumulated rewards for a recipient and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.reward.claimSync({
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The amount claimed and transaction receipt.
*/
claimSync: (
parameters: rewardActions.claimSync.Parameters<chain, account>,
) => Promise<rewardActions.claimSync.ReturnValue>
/**
* Distributes rewards to opted-in token holders.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.reward.distribute({
* amount: 100000000000000000000n,
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
distribute: (
parameters: rewardActions.distribute.Parameters<chain, account>,
) => Promise<rewardActions.distribute.ReturnValue>
/**
* Distributes rewards to opted-in token holders and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { funder, amount, receipt } = await client.reward.distributeSync({
* amount: 100000000000000000000n,
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The funder, amount, and transaction receipt.
*/
distributeSync: (
parameters: rewardActions.distributeSync.Parameters<chain, account>,
) => Promise<rewardActions.distributeSync.ReturnValue>
/**
* Gets the reward information for a specific account.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const info = await client.reward.getUserRewardInfo({
* token: '0x20c0000000000000000000000000000000000001',
* account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* })
* ```
*
* @param parameters - Parameters.
* @returns The user's reward information (recipient, rewardPerToken, rewardBalance).
*/
getUserRewardInfo: (
parameters: rewardActions.getUserRewardInfo.Parameters,
) => Promise<rewardActions.getUserRewardInfo.ReturnValue>
/**
* Sets or changes the reward recipient for a token holder.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.reward.setRecipient({
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setRecipient: (
parameters: rewardActions.setRecipient.Parameters<chain, account>,
) => Promise<rewardActions.setRecipient.ReturnValue>
/**
* Sets or changes the reward recipient for a token holder and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.reward.setRecipientSync({
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setRecipientSync: (
parameters: rewardActions.setRecipientSync.Parameters<chain, account>,
) => Promise<rewardActions.setRecipientSync.ReturnValue>
/**
* Watches for reward distributed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.reward.watchRewardDistributed({
* token: '0x20c0000000000000000000000000000000000001',
* onRewardDistributed: (args, log) => {
* console.log('Reward distributed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchRewardDistributed: (
parameters: rewardActions.watchRewardDistributed.Parameters,
) => () => void
/**
* Watches for reward recipient set events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.reward.watchRewardRecipientSet({
* token: '0x20c0000000000000000000000000000000000001',
* onRewardRecipientSet: (args, log) => {
* console.log('Reward recipient set:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchRewardRecipientSet: (
parameters: rewardActions.watchRewardRecipientSet.Parameters,
) => () => void
}
simulate: {
/**
* Simulates a set of calls on block(s) via `tempo_simulateV1`.
*
* @example
* ```ts
* import { createClient, http, parseUnits } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions, tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: '0x...',
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { blocks, tokenMetadata } = await client.simulate.simulateBlocks({
* blocks: [{
* calls: [
* Actions.token.transfer.call({
* token: '0x20c0...01',
* to: '0x...',
* amount: parseUnits('100', 6),
* }),
* ],
* }],
* traceTransfers: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns Simulated blocks and token metadata.
*/
simulateBlocks: <const calls extends readonly unknown[]>(
parameters: simulateActions.simulateBlocks.Parameters<calls>,
) => Promise<simulateActions.simulateBlocks.ReturnType<calls>>
/**
* Simulates execution of a batch of calls via `tempo_simulateV1`.
*
* @example
* ```ts
* import { createClient, http, parseUnits } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions, Addresses, tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: '0x...',
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { results, tokenMetadata } = await client.simulate.simulateCalls({
* calls: [
* Actions.token.approve.call({
* token: '0x20c0...01',
* spender: Addresses.stablecoinDex,
* amount: parseUnits('100', 6),
* }),
* Actions.dex.buy.call({
* tokenIn: '0x20c0...01',
* tokenOut: '0x20c0...02',
* amountOut: parseUnits('10', 6),
* maxAmountIn: parseUnits('100', 6),
* }),
* Actions.token.transfer.call({
* token: '0x20c0...02',
* to: '0x...',
* amount: parseUnits('10', 6),
* }),
* ],
* traceTransfers: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns Results, block, and token metadata.
*/
simulateCalls: <
const calls extends readonly unknown[],
account extends Account | Address | undefined = undefined,
>(
parameters: simulateActions.simulateCalls.Parameters<calls, account>,
) => Promise<simulateActions.simulateCalls.ReturnType<calls>>
}
token: {
/**
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.approve({
* spender: '0x...',
* amount: 100n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
approve: (
parameters: tokenActions.approve.Parameters<chain, account>,
) => Promise<tokenActions.approve.ReturnValue>
/**
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.approveSync({
* spender: '0x...',
* amount: 100n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
approveSync: (
parameters: tokenActions.approveSync.Parameters<chain, account>,
) => Promise<tokenActions.approveSync.ReturnValue>
/**
* Burns TIP20 tokens from a blocked address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.burnBlocked({
* from: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
burnBlocked: (
parameters: tokenActions.burnBlocked.Parameters<chain, account>,
) => Promise<tokenActions.burnBlocked.ReturnValue>
/**
* Burns TIP20 tokens from a blocked address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.burnBlockedSync({
* from: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
burnBlockedSync: (
parameters: tokenActions.burnBlockedSync.Parameters<chain, account>,
) => Promise<tokenActions.burnBlockedSync.ReturnValue>
/**
* Burns TIP20 tokens from the caller's balance.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.burn({
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
burn: (
parameters: tokenActions.burn.Parameters<chain, account>,
) => Promise<tokenActions.burn.ReturnValue>
/**
* Burns TIP20 tokens from the caller's balance.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.burnSync({
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
burnSync: (
parameters: tokenActions.burnSync.Parameters<chain, account>,
) => Promise<tokenActions.burnSync.ReturnValue>
/**
* Changes the transfer policy ID for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.changeTransferPolicy({
* token: '0x...',
* policyId: 1n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
changeTransferPolicy: (
parameters: tokenActions.changeTransferPolicy.Parameters<chain, account>,
) => Promise<tokenActions.changeTransferPolicy.ReturnValue>
/**
* Changes the transfer policy ID for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.changeTransferPolicySync({
* token: '0x...',
* policyId: 1n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
changeTransferPolicySync: (
parameters: tokenActions.changeTransferPolicySync.Parameters<
chain,
account
>,
) => Promise<tokenActions.changeTransferPolicySync.ReturnValue>
/**
* Creates a new TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { hash, id, address } = await client.token.create({
* name: 'My Token',
* symbol: 'MTK',
* currency: 'USD',
* logoURI: 'https://example.com/token.svg',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
create: (
parameters: tokenActions.create.Parameters<chain, account>,
) => Promise<tokenActions.create.ReturnValue>
/**
* Creates a new TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.createSync({
* name: 'My Token',
* symbol: 'MTK',
* currency: 'USD',
* logoURI: 'https://example.com/token.svg',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
createSync: (
parameters: tokenActions.createSync.Parameters<chain, account>,
) => Promise<tokenActions.createSync.ReturnValue>
/**
* Gets TIP20 token allowance.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const allowance = await client.token.getAllowance({
* account: '0x...',
* spender: '0x...',
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The token allowance, in base units and human-readable form.
*/
getAllowance: (
parameters: tokenActions.getAllowance.Parameters,
) => Promise<tokenActions.getAllowance.ReturnValue>
/**
* Gets TIP20 token balance for an address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const balance = await client.token.getBalance({
* account: '0x...',
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The token balance, in base units and human-readable form.
*/
getBalance: (
parameters: tokenActions.getBalance.Parameters<account>,
) => Promise<tokenActions.getBalance.ReturnValue>
/**
* Gets TIP20 token metadata including name, symbol, logo URI, currency, decimals, and total supply.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const metadata = await client.token.getMetadata({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The token metadata.
*/
getMetadata: (
parameters: tokenActions.getMetadata.Parameters,
) => Promise<tokenActions.getMetadata.ReturnValue>
/**
* Gets the total supply of a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const totalSupply = await client.token.getTotalSupply({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The token total supply, in base units and human-readable form.
*/
getTotalSupply: (
parameters: tokenActions.getTotalSupply.Parameters,
) => Promise<tokenActions.getTotalSupply.ReturnValue>
/**
* Gets the admin role for a specific role in a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const adminRole = await client.token.getRoleAdmin({
* role: 'issuer',
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The admin role hash.
*/
getRoleAdmin: (
parameters: tokenActions.getRoleAdmin.Parameters,
) => Promise<tokenActions.getRoleAdmin.ReturnValue>
/**
* Checks if an account has a specific role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hasRole = await client.token.hasRole({
* token: '0x...',
* role: 'issuer',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns Whether the account has the role.
*/
hasRole: (
parameters: tokenActions.hasRole.Parameters<account>,
) => Promise<tokenActions.hasRole.ReturnValue>
/**
* Grants a role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.grantRoles({
* token: '0x...',
* to: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
grantRoles: (
parameters: tokenActions.grantRoles.Parameters<chain, account>,
) => Promise<tokenActions.grantRoles.ReturnValue>
/**
* Grants a role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.grantRolesSync({
* token: '0x...',
* to: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
grantRolesSync: (
parameters: tokenActions.grantRolesSync.Parameters<chain, account>,
) => Promise<tokenActions.grantRolesSync.ReturnValue>
/**
* Mints TIP20 tokens to an address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.mint({
* to: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
mint: (
parameters: tokenActions.mint.Parameters<chain, account>,
) => Promise<tokenActions.mint.ReturnValue>
/**
* Mints TIP20 tokens to an address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.mintSync({
* to: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
mintSync: (
parameters: tokenActions.mintSync.Parameters<chain, account>,
) => Promise<tokenActions.mintSync.ReturnValue>
/**
* Pauses a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.pause({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
pause: (
parameters: tokenActions.pause.Parameters<chain, account>,
) => Promise<tokenActions.pause.ReturnValue>
/**
* Pauses a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.pauseSync({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
pauseSync: (
parameters: tokenActions.pauseSync.Parameters<chain, account>,
) => Promise<tokenActions.pauseSync.ReturnValue>
/**
* Renounces a role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.renounceRoles({
* token: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
renounceRoles: (
parameters: tokenActions.renounceRoles.Parameters<chain, account>,
) => Promise<tokenActions.renounceRoles.ReturnValue>
/**
* Renounces a role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.renounceRolesSync({
* token: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
renounceRolesSync: (
parameters: tokenActions.renounceRolesSync.Parameters<chain, account>,
) => Promise<tokenActions.renounceRolesSync.ReturnValue>
/**
* Revokes a role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.revokeRoles({
* token: '0x...',
* from: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
revokeRoles: (
parameters: tokenActions.revokeRoles.Parameters<chain, account>,
) => Promise<tokenActions.revokeRoles.ReturnValue>
/**
* Revokes a role for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.revokeRolesSync({
* token: '0x...',
* from: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
revokeRolesSync: (
parameters: tokenActions.revokeRolesSync.Parameters<chain, account>,
) => Promise<tokenActions.revokeRolesSync.ReturnValue>
/**
* Sets the supply cap for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.setSupplyCap({
* token: '0x...',
* supplyCap: 1000000n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setSupplyCap: (
parameters: tokenActions.setSupplyCap.Parameters<chain, account>,
) => Promise<tokenActions.setSupplyCap.ReturnValue>
/**
* Sets the supply cap for a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.setSupplyCapSync({
* token: '0x...',
* supplyCap: 1000000n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setSupplyCapSync: (
parameters: tokenActions.setSupplyCapSync.Parameters<chain, account>,
) => Promise<tokenActions.setSupplyCapSync.ReturnValue>
/**
* Sets the admin role for a specific role in a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.setRoleAdmin({
* token: '0x...',
* role: 'issuer',
* adminRole: 'admin',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setRoleAdmin: (
parameters: tokenActions.setRoleAdmin.Parameters<chain, account>,
) => Promise<tokenActions.setRoleAdmin.ReturnValue>
/**
* Sets the admin role for a specific role in a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.setRoleAdminSync({
* token: '0x...',
* role: 'issuer',
* adminRole: 'admin',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setRoleAdminSync: (
parameters: tokenActions.setRoleAdminSync.Parameters<chain, account>,
) => Promise<tokenActions.setRoleAdminSync.ReturnValue>
/**
* Transfers TIP20 tokens to another address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.transfer({
* to: '0x...',
* amount: 100n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
transfer: (
parameters: tokenActions.transfer.Parameters<chain, account>,
) => Promise<tokenActions.transfer.ReturnValue>
/**
* Transfers TIP20 tokens to another address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.transferSync({
* to: '0x...',
* amount: 100n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
transferSync: (
parameters: tokenActions.transferSync.Parameters<chain, account>,
) => Promise<tokenActions.transferSync.ReturnValue>
/**
* Unpauses a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.unpause({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
unpause: (
parameters: tokenActions.unpause.Parameters<chain, account>,
) => Promise<tokenActions.unpause.ReturnValue>
/**
* Unpauses a TIP20 token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.token.unpauseSync({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
unpauseSync: (
parameters: tokenActions.unpauseSync.Parameters<chain, account>,
) => Promise<tokenActions.unpauseSync.ReturnValue>
/**
* Watches for TIP20 token approval events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchApprove({
* onApproval: (args, log) => {
* console.log('Approval:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchApprove: (
parameters: tokenActions.watchApprove.Parameters,
) => () => void
/**
* Watches for TIP20 token burn events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchBurn({
* onBurn: (args, log) => {
* console.log('Burn:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBurn: (parameters: tokenActions.watchBurn.Parameters) => () => void
/**
* Watches for new TIP20 tokens created.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchCreate({
* onTokenCreated: (args, log) => {
* console.log('Token created:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchCreate: (parameters: tokenActions.watchCreate.Parameters) => () => void
/**
* Watches for TIP20 token mint events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchMint({
* onMint: (args, log) => {
* console.log('Mint:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchMint: (parameters: tokenActions.watchMint.Parameters) => () => void
/**
* Watches for TIP20 token role admin updates.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchAdminRole({
* onRoleAdminUpdated: (args, log) => {
* console.log('Role admin updated:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchAdminRole: (
parameters: tokenActions.watchAdminRole.Parameters,
) => () => void
/**
* Watches for TIP20 token role membership updates.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchRole({
* onRoleUpdated: (args, log) => {
* console.log('Role updated:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchRole: (parameters: tokenActions.watchRole.Parameters) => () => void
/**
* Watches for TIP20 token transfer events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchTransfer({
* onTransfer: (args, log) => {
* console.log('Transfer:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchTransfer: (
parameters: tokenActions.watchTransfer.Parameters,
) => () => void
}
validator: {
/**
* Adds a new validator (owner only).
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.validator.add({
* newValidatorAddress: '0x...',
* publicKey: '0x...',
* active: true,
* inboundAddress: '192.168.1.1:8080',
* outboundAddress: '192.168.1.1:8080',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
add: (
parameters: validatorActions.add.Parameters<chain, account>,
) => Promise<validatorActions.add.ReturnValue>
/**
* Adds a new validator (owner only) and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt } = await client.validator.addSync({
* newValidatorAddress: '0x...',
* publicKey: '0x...',
* active: true,
* inboundAddress: '192.168.1.1:8080',
* outboundAddress: '192.168.1.1:8080',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
addSync: (
parameters: validatorActions.addSync.Parameters<chain, account>,
) => Promise<validatorActions.addSync.ReturnValue>
/**
* Changes the owner of the validator config precompile.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.validator.changeOwner({
* newOwner: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
changeOwner: (
parameters: validatorActions.changeOwner.Parameters<chain, account>,
) => Promise<validatorActions.changeOwner.ReturnValue>
/**
* Changes the owner of the validator config precompile and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt } = await client.validator.changeOwnerSync({
* newOwner: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
changeOwnerSync: (
parameters: validatorActions.changeOwnerSync.Parameters<chain, account>,
) => Promise<validatorActions.changeOwnerSync.ReturnValue>
/**
* Changes validator active status (owner only).
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.validator.changeStatus({
* validator: '0x...',
* active: false,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
changeStatus: (
parameters: validatorActions.changeStatus.Parameters<chain, account>,
) => Promise<validatorActions.changeStatus.ReturnValue>
/**
* Changes validator active status and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt } = await client.validator.changeStatusSync({
* validator: '0x...',
* active: false,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
changeStatusSync: (
parameters: validatorActions.changeStatusSync.Parameters<chain, account>,
) => Promise<validatorActions.changeStatusSync.ReturnValue>
/**
* Gets validator information by address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const validator = await client.validator.get({
* validator: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The validator information.
*/
get: (
parameters: validatorActions.get.Parameters,
) => Promise<validatorActions.get.ReturnValue>
/**
* Gets validator address by index.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const validatorAddress = await client.validator.getByIndex({
* index: 0n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The validator address at the given index.
*/
getByIndex: (
parameters: validatorActions.getByIndex.Parameters,
) => Promise<validatorActions.getByIndex.ReturnValue>
/**
* Gets the total number of validators.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const count = await client.validator.getCount()
* ```
*
* @param parameters - Parameters.
* @returns The total number of validators.
*/
getCount: (
parameters?: validatorActions.getCount.Parameters,
) => Promise<validatorActions.getCount.ReturnValue>
/**
* Gets the next epoch for a full DKG ceremony.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const epoch = await client.validator.getNextFullDkgCeremony()
* ```
*
* @param parameters - Parameters.
* @returns The epoch number for the next full DKG ceremony.
*/
getNextFullDkgCeremony: (
parameters?: validatorActions.getNextFullDkgCeremony.Parameters,
) => Promise<validatorActions.getNextFullDkgCeremony.ReturnValue>
/**
* Gets the contract owner.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const owner = await client.validator.getOwner()
* ```
*
* @param parameters - Parameters.
* @returns The owner address.
*/
getOwner: (
parameters?: validatorActions.getOwner.Parameters,
) => Promise<validatorActions.getOwner.ReturnValue>
/**
* Gets the complete set of validators.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const validators = await client.validator.list()
* ```
*
* @param parameters - Parameters.
* @returns Array of all validators with their information.
*/
list: (
parameters?: validatorActions.list.Parameters,
) => Promise<validatorActions.list.ReturnValue>
/**
* Sets the next epoch for a full DKG ceremony.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.validator.setNextFullDkgCeremony({
* epoch: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setNextFullDkgCeremony: (
parameters: validatorActions.setNextFullDkgCeremony.Parameters<
chain,
account
>,
) => Promise<validatorActions.setNextFullDkgCeremony.ReturnValue>
/**
* Sets the next epoch for a full DKG ceremony and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt } = await client.validator.setNextFullDkgCeremonySync({
* epoch: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
setNextFullDkgCeremonySync: (
parameters: validatorActions.setNextFullDkgCeremonySync.Parameters<
chain,
account
>,
) => Promise<validatorActions.setNextFullDkgCeremonySync.ReturnValue>
/**
* Updates validator information (only callable by the validator themselves).
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.validator.update({
* newValidatorAddress: '0x...',
* publicKey: '0x...',
* inboundAddress: '192.168.1.1:8080',
* outboundAddress: '192.168.1.1:8080',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
update: (
parameters: validatorActions.update.Parameters<chain, account>,
) => Promise<validatorActions.update.ReturnValue>
/**
* Updates validator information and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt } = await client.validator.updateSync({
* newValidatorAddress: '0x...',
* publicKey: '0x...',
* inboundAddress: '192.168.1.1:8080',
* outboundAddress: '192.168.1.1:8080',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
updateSync: (
parameters: validatorActions.updateSync.Parameters<chain, account>,
) => Promise<validatorActions.updateSync.ReturnValue>
}
virtualAddress: {
/**
* Gets the registered master address for a given master ID.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const master = await client.virtualAddress.getMasterAddress({
* masterId: '0x58e21090',
* })
* ```
*
* @param parameters - Parameters.
* @returns The master address, or null if unregistered.
*/
getMasterAddress: (
parameters: virtualAddressActions.getMasterAddress.Parameters,
) => Promise<virtualAddressActions.getMasterAddress.ReturnValue>
/**
* Registers the caller as a virtual address master.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.virtualAddress.registerMaster({
* salt: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
registerMaster: (
parameters: virtualAddressActions.registerMaster.Parameters<
chain,
account
>,
) => Promise<virtualAddressActions.registerMaster.ReturnValue>
/**
* Registers the caller as a virtual address master and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, masterId, masterAddress } =
* await client.virtualAddress.registerMasterSync({
* salt: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
registerMasterSync: (
parameters: virtualAddressActions.registerMasterSync.Parameters<
chain,
account
>,
) => Promise<virtualAddressActions.registerMasterSync.ReturnValue>
/**
* Resolves an address to its effective recipient.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo,
* transport: http(),
* }).extend(tempoActions())
*
* const recipient = await client.virtualAddress.resolve({
* address: '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
* })
* ```
*
* @param parameters - Parameters.
* @returns The resolved address, or null if virtual and unregistered.
*/
resolve: (
parameters: virtualAddressActions.resolve.Parameters,
) => Promise<virtualAddressActions.resolve.ReturnValue>
}
zone: {
/**
* Deposits tokens into a zone.
* Batches approve and deposit into a single transaction.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.zone.deposit({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
deposit: (
parameters: zoneActions.deposit.Parameters<chain, account>,
) => Promise<zoneActions.deposit.ReturnValue>
/**
* Deposits tokens into a zone and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { tempoActions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt } = await client.zone.depositSync({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
depositSync: (
parameters: zoneActions.depositSync.Parameters<chain, account>,
) => Promise<zoneActions.depositSync.ReturnValue>
/**
* Deposits tokens into a zone with encrypted recipient and memo.
*
* @example
* ```ts
* const hash = await client.zone.encryptedDeposit({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
encryptedDeposit: (
parameters: zoneActions.encryptedDeposit.Parameters<chain, account>,
) => Promise<zoneActions.encryptedDeposit.ReturnValue>
/**
* Deposits tokens into a zone with encrypted recipient and memo and
* waits for the transaction receipt.
*
* @example
* ```ts
* const { receipt } = await client.zone.encryptedDepositSync({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
encryptedDepositSync: (
parameters: zoneActions.encryptedDepositSync.Parameters<chain, account>,
) => Promise<zoneActions.encryptedDepositSync.ReturnValue>
/**
* Gets the active sequencer encryption key for a zone.
*
* @example
* ```ts
* const { keyIndex, publicKey } = await client.zone.getEncryptionKey({
* zoneId: 7,
* })
* ```
*
* @param parameters - Parameters.
* @returns The active encryption key and its zero-based index.
*/
getEncryptionKey: (
parameters: zoneActions.getEncryptionKey.Parameters,
) => Promise<zoneActions.getEncryptionKey.ReturnValue>
/**
* Gets metadata and configuration for a zone portal.
*
* @example
* ```ts
* const info = await client.zone.getPortalInfo({
* zoneId: 7,
* })
* ```
*
* @param parameters - Parameters.
* @returns The portal metadata and configuration.
*/
getPortalInfo: (
parameters: zoneActions.getPortalInfo.Parameters,
) => Promise<zoneActions.getPortalInfo.ReturnValue>
/**
* Returns the authenticated account address and authorization token expiry.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, tempoActions, Zone } from 'viem/tempo'
*
* const client = createClient({
* chain: Zone.a,
* transport: http(),
* }).extend(tempoActions())
*
* const info = await client.zone.getAuthorizationTokenInfo()
* ```
*
* @returns The account address and token expiry.
*/
getAuthorizationTokenInfo: () => Promise<zoneActions.getAuthorizationTokenInfo.ReturnType>
/**
* Returns the withdrawal fee for a given gas limit.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, tempoActions, Zone } from 'viem/tempo'
*
* const client = createClient({
* chain: Zone.a,
* transport: http(),
* }).extend(tempoActions())
*
* const fee = await client.zone.getWithdrawalFee()
* ```
*
* @param parameters - Parameters.
* @returns The withdrawal fee.
*/
getWithdrawalFee: (
parameters?: zoneActions.getWithdrawalFee.Parameters,
) => Promise<zoneActions.getWithdrawalFee.ReturnType>
/**
* Returns the current zone metadata.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, tempoActions, Zone } from 'viem/tempo'
*
* const client = createClient({
* chain: Zone.a,
* transport: http(),
* }).extend(tempoActions())
*
* const info = await client.zone.getZoneInfo()
* ```
*
* @returns The zone metadata.
*/
getZoneInfo: () => Promise<zoneActions.getZoneInfo.ReturnType>
/**
* Waits for a zone to import a Tempo block.
*
* @param parameters - Tempo block number and polling options.
* @returns Zone metadata after the block has been imported.
*/
waitForTempoBlock: (
parameters: zoneActions.waitForTempoBlock.Parameters,
) => Promise<zoneActions.waitForTempoBlock.ReturnType>
/**
* Requests a withdrawal from a zone to the parent Tempo chain.
* Batches approve and withdrawal into a single transaction.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, tempoActions, Zone } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: Zone.a,
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.zone.requestWithdrawal({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
requestWithdrawal: ((
parameters: zoneActions.requestWithdrawal.Parameters<chain, account>,
) => Promise<zoneActions.requestWithdrawal.ReturnValue>) & {
prepare: (
parameters: zoneActions.requestWithdrawal.prepare.Parameters<
chain,
account,
undefined,
undefined
>,
) => Promise<
zoneActions.requestWithdrawal.prepare.ReturnType<
chain,
account,
undefined,
undefined
>
>
}
/**
* Requests a withdrawal and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, tempoActions, Zone } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: Zone.a,
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, senderTag } = await client.zone.requestWithdrawalSync({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and sender tag for the parent-chain withdrawal event.
*/
requestWithdrawalSync: (
parameters: zoneActions.requestWithdrawalSync.Parameters<chain, account>,
) => Promise<zoneActions.requestWithdrawalSync.ReturnValue>
/**
* Requests a verifiable withdrawal from a zone.
*
* @example
* ```ts
* const hash = await client.zone.requestVerifiableWithdrawal({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* revealTo: '0x02abc...def',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
requestVerifiableWithdrawal: (
parameters: zoneActions.requestVerifiableWithdrawal.Parameters<
chain,
account
>,
) => Promise<zoneActions.requestVerifiableWithdrawal.ReturnValue>
/**
* Requests a verifiable withdrawal and waits for the transaction receipt.
*
* @example
* ```ts
* const { receipt } = await client.zone.requestVerifiableWithdrawalSync({
* token: '0x20c0...0001',
* amount: 1_000_000n,
* revealTo: '0x02abc...def',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
requestVerifiableWithdrawalSync: (
parameters: zoneActions.requestVerifiableWithdrawalSync.Parameters<
chain,
account
>,
) => Promise<zoneActions.requestVerifiableWithdrawalSync.ReturnValue>
/**
* Signs and stores a zone authorization token.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, tempoActions, Zone } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: Zone.a,
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.zone.signAuthorizationToken()
* ```
*
* @param parameters - Parameters.
* @returns The authentication object and serialized token.
*/
signAuthorizationToken: (
parameters?: zoneActions.signAuthorizationToken.Parameters<account>,
) => Promise<zoneActions.signAuthorizationToken.ReturnType>
}
}
type BoundHelper<helper> = helper extends (
...parameters: infer parameters
) => infer returnType
? parameters extends [Client<any, any, any>, infer args, ...unknown[]]
? (args: args) => returnType
: parameters extends [Client<any, any, any>]
? () => returnType
: parameters extends [infer args, ...unknown[]]
? (args: args) => returnType
: () => returnType
: never
type BoundActionHelpers<action> = (action extends { call: infer helper }
? { call: BoundHelper<helper> }
: {}) &
(action extends { calls: infer helper }
? { calls: BoundHelper<helper> }
: {}) &
(action extends { callWithPeriod: infer helper }
? { callWithPeriod: BoundHelper<helper> }
: {}) &
(action extends { estimateGas: infer helper }
? { estimateGas: BoundHelper<helper> }
: {}) &
(action extends { prepare: infer helper }
? { prepare: BoundHelper<helper> }
: {}) &
(action extends { prepareRecipient: infer helper }
? { prepareRecipient: BoundHelper<helper> }
: {}) &
(action extends { predict: infer helper }
? { predict: BoundHelper<helper> }
: {}) &
(action extends { simulate: infer helper }
? { simulate: BoundHelper<helper> }
: {}) &
// `extractEvent(s)` helpers are client-less and copied through unwrapped by
// `bindActionDecorators`, so their full signatures are preserved.
(action extends { extractEvent: infer helper }
? { extractEvent: helper }
: {}) &
(action extends { extractEvents: infer helper }
? { extractEvents: helper }
: {})
type BoundAction<action> = action extends (
...parameters: infer parameters
) => infer returnType
? (parameters extends [Client<any, any, any>, infer args, ...unknown[]]
? (args: args) => returnType
: parameters extends [Client<any, any, any>]
? () => returnType
: never) &
BoundActionHelpers<action>
: never
type DecorateNamespace<namespace, actions> = {
[key in keyof namespace]: key extends keyof actions
? namespace[key] & BoundActionHelpers<actions[key]>
: namespace[key]
} & {
[key in Exclude<keyof actions, keyof namespace> as actions[key] extends (
...parameters: any
) => any
? key
: never]: BoundAction<actions[key]>
}
export type Decorator<
chain extends Chain | undefined = Chain | undefined,
account extends Account | undefined = Account | undefined,
> = {
accessKey: DecorateNamespace<
DecoratorBase<chain, account>['accessKey'],
typeof accessKeyActions
>
amm: DecorateNamespace<
DecoratorBase<chain, account>['amm'],
typeof ammActions
>
channel: DecorateNamespace<
DecoratorBase<chain, account>['channel'],
typeof channelActions
>
dex: DecorateNamespace<
DecoratorBase<chain, account>['dex'],
typeof dexActions
>
earn: DecorateNamespace<
DecoratorBase<chain, account>['earn'],
typeof earnActions
>
faucet: DecorateNamespace<
DecoratorBase<chain, account>['faucet'],
typeof faucetActions
>
multisig: DecorateNamespace<
DecoratorBase<chain, account>['multisig'],
typeof multisigActions
>
nonce: DecorateNamespace<
DecoratorBase<chain, account>['nonce'],
typeof nonceActions
>
fee: DecorateNamespace<
DecoratorBase<chain, account>['fee'],
typeof feeActions
>
policy: DecorateNamespace<
DecoratorBase<chain, account>['policy'],
typeof policyActions
>
receivePolicy: DecorateNamespace<
DecoratorBase<chain, account>['receivePolicy'],
typeof receivePolicyActions
>
reward: DecorateNamespace<
DecoratorBase<chain, account>['reward'],
typeof rewardActions
>
simulate: DecorateNamespace<
DecoratorBase<chain, account>['simulate'],
typeof simulateActions
>
token: DecorateNamespace<
DecoratorBase<chain, account>['token'],
typeof tokenActions
>
validator: DecorateNamespace<
DecoratorBase<chain, account>['validator'],
typeof validatorActions
>
virtualAddress: DecorateNamespace<
DecoratorBase<chain, account>['virtualAddress'],
typeof virtualAddressActions
>
zone: DecorateNamespace<
DecoratorBase<chain, account>['zone'],
typeof zoneActions
>
}
function bindActions<actions extends Record<string, unknown>>(
client: Client<Transport, Chain | undefined, Account | undefined>,
actions: actions,
keys: readonly (keyof actions)[],
) {
const bound: Record<string, unknown> = {}
for (const key of keys)
bound[key as string] = bindActionDecorators(client, actions[key])
return bound
}
export function decorator() {
return <
transport extends Transport,
chain extends Chain | undefined,
account extends Account | undefined,
>(
client: Client<transport, chain, account>,
): Decorator<chain, account> => {
return {
accessKey: bindActions(client, accessKeyActions, [
'authorize',
'authorizeSync',
'burnWitness',
'burnWitnessSync',
'getMetadata',
'getRemainingLimit',
'isAdmin',
'isWitnessBurned',
'prepareAuthorization',
'revoke',
'revokeSync',
'signAuthorization',
'updateLimit',
'updateLimitSync',
'verifyHash',
'watchAdminAuthorized',
'watchWitness',
'watchWitnessBurned',
]),
amm: bindActions(client, ammActions, [
'getPool',
'getLiquidityBalance',
'burn',
'burnSync',
'mint',
'mintSync',
'rebalanceSwap',
'rebalanceSwapSync',
'watchBurn',
'watchMint',
'watchRebalanceSwap',
]),
channel: bindActions(client, channelActions, [
'close',
'closeSync',
'getStates',
'open',
'openSync',
'requestClose',
'requestCloseSync',
'settle',
'settleSync',
'signVoucher',
'topUp',
'topUpSync',
'withdraw',
'withdrawSync',
]),
dex: bindActions(client, dexActions, [
'buy',
'buySync',
'cancel',
'cancelSync',
'cancelStale',
'cancelStaleSync',
'createPair',
'createPairSync',
'getBalance',
'getBuyQuote',
'getOrder',
'getOrderbook',
'getTickLevel',
'getSellQuote',
'place',
'placeSync',
'placeFlip',
'placeFlipSync',
'sell',
'sellSync',
'withdraw',
'withdrawSync',
'watchFlipOrderPlaced',
'watchOrderCancelled',
'watchOrderFilled',
'watchOrderPlaced',
]),
earn: bindActions(client, earnActions, [
'bindEngine',
'bindEngineSync',
'configureExitSafePolicy',
'createErc4626Engine',
'createErc4626EngineSync',
'createStack',
'createStackSync',
'deposit',
'depositSync',
'depositShares',
'depositSharesSync',
'deployErc4626StackSync',
'privateDeposit',
'privateDepositSync',
'getFeeState',
'getPosition',
'getRedeemQuote',
'getVault',
'getWithdrawQuote',
'redeem',
'redeemSync',
'privateRedeem',
'privateRedeemSync',
'waitForPrivateDeposit',
'waitForPrivateRedeem',
'validateExitSafePolicy',
'withdrawExact',
'withdrawExactSync',
]),
faucet: bindActions(client, faucetActions, ['fund', 'fundSync']),
multisig: bindActions(client, multisigActions, [
'getConfig',
'getConfigCommitment',
'getOperation',
'updateConfig',
'updateConfigSync',
]),
nonce: bindActions(client, nonceActions, [
'getNonce',
'watchNonceIncremented',
]),
fee: bindActions(client, feeActions, [
'validateToken',
'getUserToken',
'setUserToken',
'setUserTokenSync',
'getValidatorToken',
'setValidatorToken',
'setValidatorTokenSync',
'watchSetUserToken',
'watchSetValidatorToken',
]),
policy: bindActions(client, policyActions, [
'create',
'createSync',
'setAdmin',
'setAdminSync',
'modifyWhitelist',
'modifyWhitelistSync',
'modifyBlacklist',
'modifyBlacklistSync',
'getData',
'isAuthorized',
'watchCreate',
'watchAdminUpdated',
'watchWhitelistUpdated',
'watchBlacklistUpdated',
]),
receivePolicy: bindActions(client, receivePolicyActions, [
'burn',
'burnSync',
'claim',
'claimSync',
'get',
'getBlockedBalance',
'set',
'setSync',
'validate',
'watchBlocked',
'watchBurned',
'watchClaimed',
'watchUpdated',
]),
reward: bindActions(client, rewardActions, [
'claim',
'claimSync',
'distribute',
'distributeSync',
'getGlobalRewardPerToken',
'getPendingRewards',
'getUserRewardInfo',
'setRecipient',
'setRecipientSync',
'watchRewardDistributed',
'watchRewardRecipientSet',
]),
simulate: bindActions(client, simulateActions, [
'simulateBlocks',
'simulateCalls',
]),
token: bindActions(client, tokenActions, [
'approve',
'approveSync',
'burnBlocked',
'burnBlockedSync',
'burn',
'burnSync',
'changeTransferPolicy',
'changeTransferPolicySync',
'create',
'createSync',
'getAllowance',
'getBalance',
'getMetadata',
'getTotalSupply',
'getRoleAdmin',
'hasRole',
'grantRoles',
'grantRolesSync',
'mint',
'mintSync',
'pause',
'pauseSync',
'renounceRoles',
'renounceRolesSync',
'revokeRoles',
'revokeRolesSync',
'setSupplyCap',
'setSupplyCapSync',
'setRoleAdmin',
'setRoleAdminSync',
'transfer',
'transferSync',
'unpause',
'unpauseSync',
'prepareUpdateQuoteToken',
'prepareUpdateQuoteTokenSync',
'updateQuoteToken',
'updateQuoteTokenSync',
'watchApprove',
'watchBurn',
'watchCreate',
'watchMint',
'watchAdminRole',
'watchRole',
'watchTransfer',
'watchUpdateQuoteToken',
]),
validator: bindActions(client, validatorActions, [
'add',
'addSync',
'changeOwner',
'changeOwnerSync',
'changeStatus',
'changeStatusSync',
'get',
'getByIndex',
'getCount',
'getNextFullDkgCeremony',
'getOwner',
'list',
'setNextFullDkgCeremony',
'setNextFullDkgCeremonySync',
'update',
'updateSync',
]),
virtualAddress: bindActions(client, virtualAddressActions, [
'getMasterAddress',
'registerMaster',
'registerMasterSync',
'resolve',
]),
zone: bindActions(client, zoneActions, [
'deposit',
'depositSync',
'encryptedDeposit',
'encryptedDepositSync',
'getAuthorizationTokenInfo',
'getEncryptionKey',
'getPortalInfo',
'getWithdrawalFee',
'getZoneInfo',
'requestWithdrawal',
'requestWithdrawalSync',
'requestVerifiableWithdrawal',
'requestVerifiableWithdrawalSync',
'signAuthorizationToken',
'waitForTempoBlock',
]),
} as Decorator<chain, account>
}
}