Skip to main content

useTransactor

Use this hook to interact with the chain and give UI feedback on the transaction status.

Transaction success

Any error will instead show a popup with nice error message.

Error Example

const { writeTransaction, transactionReceiptInstance, sendTransactionInstance } = useTransactor();
const calls = [
{
contractAddress: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
entrypoint: "transfer",
calldata: ["0x123...", "1000000000000000000", "0"],
},
];
await writeTransaction(calls);

This example tries to send a transfer transaction, prompting the connected wallet for a signature. In the case of a successful transaction, it will show a popup in the UI with the message: "๐ŸŽ‰ Transaction completed successfully!".

You can pass in a list of valid Call โ€” Type is from starknet.

Refer to this recipe for a more detailed example.

Configurationโ€‹

useTransactorโ€‹

useTransactor() takes no arguments. It internally uses useSendTransaction from @starknet-start/react.

writeTransactionโ€‹

ParameterTypeDescription
callsCall[]A list of valid Call โ€” Type is from starknet.

Return Valuesโ€‹

writeTransactionโ€‹

  • The function that is used to initialize the UI feedback flow. Takes a Call[] array directly.

transactionReceiptInstanceโ€‹

sendTransactionInstanceโ€‹