Skip to content
Starknet Start

usePaymasterSendTransaction

Hook to send one or several transactions through a paymaster.

Use this hook together with usePaymasterGasTokens to fetch supported gas tokens & usePaymasterEstimateFees to estimate fees in gas token.

Usage

The following example shows how to transfer $STRK tokens to an address using $USDC as gas token.

import {  } from "@starknetfoundation/starknet-start-react";
import { ,  } from "starknet";
 
const : [] = [
  {
    : "STRK_SEPOLIA_ADDRESS",
    : "transfer",
    : ["recipient_address", "0x1", "0x0"],
  },
];
 
const :  = {
  : "default", // default or sponsored(need api-key)
  : "USDC_SEPOLIA_ADDRESS", // mandatory if 'default'
};
 
const { ,  } = ({
  ,
  : {
    ,
  },
});

Arguments

calls

  • Type: Call[] | undefined

List of smart contract calls to execute. Type is from starknet

options

  • Type: PaymasterDetails | undefined

Paymaster details. Type is from starknet.

maxFeeInGasToken

  • Type: BigNumberish | undefined

Maximum fee in the selected gas token. Type is from starknet.

Returns

send

  • Type: (args?: Call[]) => void

Function to send the request to the user, optionally overriding the arguments to the hook.

sendAsync

  • Type: (args?: Call[]) => Promise<InvokeFunctionResponse>

Send the request to the user and block until it receives a response, optionally overriding the arguments to the hook.

data

  • Type: InvokeFunctionResponse | undefined

The resolved data. This type is defined in starknet.

error

  • Type: Error | null

Any error thrown by the mutation.

reset

  • Type: () => void

Reset the mutation status.

variables

  • Type: Call[] | undefined

The variables passed to send or sendAsync.

status

  • Type: "error" | "idle" | "pending" | "success"

The mutation status.

  • idle: the mutation has not been triggered yet.
  • pending: the mutation is being executed, e.g. waiting for the user to confirm in their wallet.
  • success: the mutation executed without an error.
  • error: the mutation threw an error.

isError

  • Type: boolean

Derived from status.

isIdle

  • Type: boolean

Derived from status.

isPending

  • Type: boolean

Derived from status.

isSuccess

  • Type: boolean

Derived from status.