Skip to content

useSpend

Hook for sending AE tokens to a recipient.

Import

typescript
import { useSpend } from '@growae/reactive-react'

Usage

tsx
import { useSpend } from '@growae/reactive-react'

function SendAE() {
  const { mutate: spend, isPending, isSuccess, data } = useSpend()

  return (
    <div>
      <button
        onClick={() =>
          spend({
            recipient: 'ak_2dA...',
            amount: '1.5',
          })
        }
        disabled={isPending}
      >
        Send 1.5 AE
      </button>
      {isSuccess && <p>Tx: {data.hash}</p>}
    </div>
  )
}

Return Type

See TanStack Query mutation docs for full return type.

data

See spend Return Type.

Parameters

See spend Parameters for all available options.

Key parameters:

ParameterTypeDefaultDescription
recipientstringRequired. Recipient address or AENS name.
amountbigint | stringRequired. Amount to send.
ttlnumber300Transaction TTL in blocks relative to current height. Set to 0 for no expiration.

Default TTL

All transactions default to a TTL of 300 blocks (~15 hours). This prevents stale transactions from lingering indefinitely. Override with ttl: 0 for no expiration.

mutation

See TanStack Query mutation docs for mutation options.

Action