Skip to content

useSpend

Primitive for sending AE tokens to a recipient.

Import

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

Usage

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

function SendAE() {
  const spend = useSpend()

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

Parameters

See spend Parameters.

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.

Action