Skip to content

Commit

Permalink
docs: add useSendTransaction to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
helciofranco committed Jun 4, 2024
1 parent a20145a commit da7f896
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions packages/docs/docs/dev/hooks-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ console.log(chain.name);

## `useConnect`

Facilitates the connection to the Fuel wallet. Allows selecting a connector by name. It also provides a function `<UseMutateAsyncFunction<boolean | undefined>>` to initiate the connection and relevant mutation properties for managing the connection state.
Facilitates the connection to the Fuel wallet. Allows selecting a connector by name. It also provides a function `UseMutateAsyncFunction<boolean | undefined>` to initiate the connection and relevant mutation properties for managing the connection state.

```tsx
const { connect, connectAsync } = useConnect();
Expand Down Expand Up @@ -89,7 +89,7 @@ console.log(connectors);

## `useDisconnect`

Facilitates disconnection from the Fuel Wallet. It provides a function `<UseMutateAsyncFunction<boolean | undefined>>` to initiate disconnection.
Facilitates disconnection from the Fuel Wallet. It provides a function `UseMutateAsyncFunction<boolean | undefined>` to initiate disconnection.

```tsx
const { disconnect } = useDisconnect();
Expand Down Expand Up @@ -138,6 +138,40 @@ const { provider } = useProvider();

[See the source file](https://github.com/FuelLabs/fuels-npm-packs/tree/main/packages/react/src/hooks/useProvider.ts)

## `useSendTransaction`

Hook for signing and sending transactions to the Fuel network.

```tsx
const { sendTransaction, sendTransactionAsync } = useSendTransaction();

const handleSendTransaction = async () => {
// The amount of coins to transfer.
const amount = bn(1);

// Create a transaction request using wallet helper (check useWallet hook if needed)
const transactionRequest = await wallet.createTransfer(
destination,
amount
);

sendTransaction({
address: '0xd7ad97...', // The address to sign the transaction
transactionRequest,
})

// Async way
await sendTransactionAsync({
address: '0xd7ad97...', // The address to sign the transaction
transactionRequest,
});
};

handleSendTransaction();
```

[See the source file](https://github.com/FuelLabs/fuels-npm-packs/tree/main/packages/react/src/hooks/useSendTransaction.ts)

## `useTransaction`

Retrieves transaction information associated with a specific transaction ID.
Expand Down

0 comments on commit da7f896

Please sign in to comment.