Skip to content

zone.useEncryptedDeposit

Hook for depositing tokens into a zone with an encrypted recipient and memo.

Requires viem >=2.48.0

Zone actions and hooks require viem >=2.48.0.

Usage

ts
import { Hooks } from 'wagmi/tempo'
import { parseUnits } from 'viem'

const encryptedDepositSync = Hooks.zone.useEncryptedDepositSync()

// Call `mutate` in response to user action (e.g. button click, form submission)
encryptedDepositSync.mutate({
  amount: parseUnits('10', 6),
  token: '0x20c0000000000000000000000000000000000001',
  zoneId: 7,
})

console.log(
  'Transaction hash:',
  encryptedDepositSync.data?.receipt.transactionHash,
)
// @log: Transaction hash: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
ts
import { createConfig, http } from 'wagmi'
import { tempo } from 'wagmi/chains'
import { tempoWallet } from 'wagmi/tempo'

export const config = createConfig({
  connectors: [tempoWallet()],
  chains: [tempo],
  multiInjectedProviderDiscovery: false,
  transports: {
    [tempo.id]: http(),
  },
})

Asynchronous Usage

The example above uses a *Sync variant of the action, that will wait for the transaction to be included before returning.

If you are optimizing for performance, you should use the non-sync zone.encryptedDeposit action and wait for inclusion manually:

ts
import { Hooks } from 'wagmi/tempo'
import { useWaitForTransactionReceipt } from 'wagmi'
import { parseUnits } from 'viem'

const encryptedDeposit = Hooks.zone.useEncryptedDeposit()
const { data: receipt } = useWaitForTransactionReceipt({
  hash: encryptedDeposit.data,
})

encryptedDeposit.mutate({
  amount: parseUnits('10', 6),
  token: '0x20c0000000000000000000000000000000000001',
  zoneId: 7,
})

console.log(receipt?.status)

Return Type

See TanStack Query mutation docs for more info hook return types.

data

See Wagmi Action zone.encryptedDeposit Return Type

mutate/mutateAsync

See Wagmi Action zone.encryptedDeposit Parameters

Parameters

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

mutation

See the TanStack Query mutation docs for more info hook parameters.

Action

Released under the MIT License.