Skip to content

useSendFunds

Hook to send or withdraw assets from an Account.

Import

import { useSendFunds } from '@abstract-money/react'

Usage

index.tsx
import { useSendFunds } from '@abstract-money/react'
import { stringToAccountId } from '@abstract-money/core'
 
function App() {
  const sendFunds = useSendFunds({
    accountId: stringToAccountId('pion-1'),
    chainName: 'pion',
  })
 
  return (
    <button
      onClick={() =>
        sendFunds.mutate({
          fee: 'auto',
          args: {
            assets: [
              {
                denom: 'uosmo',
                amount: '1000',
                type: 'native',
              },
            ],
            recipient: 'recipient_address',
          },
        })
      }
    >
      withdraw
    </button>
  )
}

Hook Parameters

accountId

AccountId | undefined

Account Id to be used to fetch the query.

chainName

string | undefined

Name of the chain to be used to fetch the query.

mutation

MutationOptions | undefined

MutationOptions to use.

Mutation Parameters

fee

number | StdFee | "auto"

The fee to be paid for the transaction. Can be a number, a StdFee object, or "auto" for automatic fee calculation.

memo (optional)

string | undefined

An optional memo to attach to the transaction.

funds

An array of coin objects representing the funds to be sent with the transaction. Each object contains:

  • denom: The denomination of the coin
  • amount: The amount of the coin

args

Arguments passed to the mutation. This includes:

assets

An array of Asset objects to withdraw. An Asset can be either a NativeAsset or a CW20Asset:

For NativeAsset:

  • type: 'native'
  • denom: The denomination of the native token
  • amount: The amount to withdraw

For CW20Asset:

  • type: 'cw20'
  • address: The contract address of the CW20 token
  • amount: The amount to withdraw

recipient

string

The address to send the withdrawn assets to.