Usage

"use client";
import { useSponsorTokenWithETH } from "@tx-kit/hooks";

const MyComponent = () => {
    const { 
        sponsorTokenWithETH,
        tokenId,
        status, 
        txHash,
        error 
    } = useSponsorTokenWithETH()

    const onClick = () => {
        sponsorTokenWithETH({ ... })
    }

    return <button onClick={onClick}>Sponsor Token</button>
}

Returns

sponsorTokenWithETH

Function to sponsor a token with ETH. See sponsorTokenWithETH args.

  • type: ({ channelAddress: string; sponsoredToken: DeferredTokenIntentWithSignature; to: string; amount: number; mintReferral: string; data: string; transactionOverrides?: TransactionOverrides; }) => Promise<{ tokenId: bigint | undefined; events: Log[]; } | undefined>

status

  • type: ContractExecutionStatus
type ContractExecutionStatus =
  | 'pendingApproval'
  | 'txInProgress'
  | 'complete'
  | 'error'

the status of the transaction

tokenId

  • type: bigint

the token id of the sponsored token

txHash

  • type: string

the transaction hash of the transaction

error

  • type: any

the revert message if the transaction fails