useDepositEth MUTATION

Hook for depositing ETH into a DAO

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

Usage

import { useDepositEth } from '@daobox/use-aragon'
function App() {
  const { mutate, depositStatus, TxHash } = useDepositEth({
    daoAddressOrEns: '0x13c6e4f17bbe606fed867a5cd6389a504724e805',
    amount: 69n,
    onTransaction(txHash: string) {
      alert(`Transaction hash: ${txHash}`)
    },
    onSuccess() {
      alert(`Done!`)
    },
  })

  return (
    <>
      <button onClick={() => mutate?.()}>"Deposit ETH"</button>
      <p>{depositStatus}</p>
      <p>{txHash}</p>
    </>
  )
}

Required Parameters

  • Name
    daoAddressOrEns
    Type
    string
    Description

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

  • Name
    amount
    Type
    bigint
    Description

    The amount of ETH to deposit into the DAO.

Return Values

{
  txHash: string | null,
  depositAmount: bigint | null,
  isLoading: boolean,
  isSuccess: boolean,
  isError: boolean,
  error: Error | null,
  data: DepositReturnData | null,
  reset: function,
  mutate: function,
  depositStatus: 'idle' | 'waitingForSigner' | 'confirming' | 'success' | 'error',
}

Return Data

{
  txHash: string | null,
  depositAmount: bigint | null,
}

Optional Parameters


onTransaction (optional)

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

Example request with bearer token

{
  const { mutate, depositStatus, TxHash } = useDepositEth({
    daoAddressOrEns: '0x13c6e4f17bbe606fed867a5cd6389a504724e805',
    amount: 69n,
    onTransaction(txHash: string) {
      alert(`Transaction hash: ${txHash}`)
    },
  })
}