useDepositERC20 MUTATION

Hook for depositing ERC20 tokens into a DAO

import { useDepositERC20 } from '@daobox/use-aragon'

Usage

import { useDepositEth } from '@daobox/use-aragon'

function App() {
  const { mutate, depositStatus, TxHash } = useDepositEth({
    daoAddressOrEns: '0x13c6e4f17bbe606fed867a5cd6389a504724e805',
    tokenAddress: "0xd5a2f36a3dfa4c9edcee18fcda6e9e47cc93b8d3"
    amount: 420000000n,
    onAllowanceTransaction(txHash: string) {
      alert(`Transaction hash: ${txHash}`)
    },
    onDepositTransaction(txHash: string) {
      alert(`Transaction hash: ${txHash}`)
    },
  })

  return (
    <>
      <button onClick={() => mutate?.()}>"Deposit ANT Token"</button>
      <p>{depositStatus}</p>
      // this is the transaction hash of the deposit transaction
      <p>{txHash}</p>
    </>
  )
}

Required Parameters

  • Name
    daoAddressOrEns
    Type
    string
    Description

    The address or ENS name of the DAO to deposit ETH into.

  • Name
    tokenAddress
    Type
    string
    Description

    The address of the ERC20 token to deposit into the DAO.

  • Name
    amount
    Type
    bigint
    Description

    The amount of ETH to deposit into the DAO.

Return Data

data: DepositReturnData {
    allowance: bigint | null;
    updateAllowanceTxHash: string | null;
    depositTxHash: string | null;
    depositAmount: bigint | null;
}

Return Values

{
  data: DepositReturnData | null,
  DepositERC20Status: 'idle' | 'waitingForSigner' | 'checkingAllowance' | 'confirmingAllowanceUpdate' | 'confirmingDeposit' | 'success' | 'error',
  allowance: bigint | null,
  updateAllowanceTxHash: string | null,
  depositTxHash: string | null,
  depositAmount: bigint | null,
  isLoading: boolean,
  isSuccess: boolean,
  isError: boolean,
  error: Error | null,
  reset: function,
  mutate: function,
}

Optional Parameters


onAllowanceTransaction

callback function that is called when or if a token approve transaction is submitted but before it is mined

{
  const { mutate, depositStatus, TxHash } = useDepositEth({
    daoAddressOrEns: '0x13c6e4f17bbe606fed867a5cd6389a504724e805',
    tokenAddress: "0xd5a2f36a3dfa4c9edcee18fcda6e9e47cc93b8d3"
    amount: 420000000n,
    onAllowanceTransaction(txHash: string) {
      alert(`Transaction hash: ${txHash}`)
    },
  })
}

onDepositTransaction

callback function that is called when the token transfer transaction is submitted but before it is mined

{
  const { mutate, depositStatus, TxHash } = useDepositEth({
    daoAddressOrEns: '0x13c6e4f17bbe606fed867a5cd6389a504724e805',
    tokenAddress: "0xd5a2f36a3dfa4c9edcee18fcda6e9e47cc93b8d3"
    amount: 420000000n,
    onDepositTransaction(txHash: string) {
      alert(`Transaction hash: ${txHash}`)
    },
  })
}