> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chipipay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# useRecordSendTransaction

> Records a send transaction in the Chipi system for tracking and webhook notifications.

## Usage

```typescript theme={null}
const { 
  recordSendTransactionAsync, 
  data, 
  isLoading, 
  error 
} = useRecordSendTransaction();
```

### Parameters

The hook accepts an object with:

* `params` (`RecordSendTransactionParams`):
  * `transactionHash` (string): The hash of the transaction to record
  * `chain` (`Chain`): The blockchain network. Use `Chain.STARKNET`
  * `expectedSender` (string): The expected sender wallet address
  * `expectedRecipient` (string): The expected recipient wallet address
  * `expectedToken` (`ChainToken`): The expected token. Use `ChainToken.USDC`
  * `expectedAmount` (string): The expected transaction amount
* `bearerToken` (string): Bearer token for authentication

### Return Value

Returns an object containing:

* `recordSendTransaction`: Function to record transaction (fire-and-forget)
* `recordSendTransactionAsync`: Promise-based function that resolves with the transaction record
* `data`: The recorded transaction data (`Transaction | undefined`)
* `isLoading`: Boolean indicating if the operation is in progress
* `isError`: Boolean indicating if an error occurred
* `error`: Error instance when `isError` is true, otherwise `null`
* `isSuccess`: Boolean indicating if the recording completed successfully
* `reset`: Function to reset the mutation state

## Example Implementation

```typescript theme={null}
import { useRecordSendTransaction } from "@chipi-stack/chipi-react";
import { Chain, ChainToken } from "@chipi-stack/types";

export function RecordTransactionForm() {
  const { recordSendTransactionAsync, data, isLoading, isError, error } = useRecordSendTransaction();
  const { getToken } = useAuth();

  const handleRecordTransaction = async () => {
    try {
      const token = await getToken();
      if (!token) throw new Error("No token found");

      // After a transfer, record the transaction
      const transactionHash = "0x..."; // From your transfer transaction
      const senderWallet = { publicKey: "0x123..." };
      const merchant = "0x456...";
      const amountUsd = "100.00";

      await recordSendTransactionAsync({
        params: {
          transactionHash,
          chain: Chain.STARKNET,
          expectedSender: senderWallet.publicKey,
          expectedRecipient: merchant,
          expectedToken: ChainToken.USDC,
          expectedAmount: amountUsd,
        },
        bearerToken: token,
      });
    } catch (err) {
      console.error('Recording transaction failed:', err);
    }
  };

  return (
    <div className="bg-white rounded-xl shadow-lg p-6">
      <h2 className="text-2xl font-bold mb-4">Record Transaction</h2>
      
      <button 
        onClick={handleRecordTransaction}
        disabled={isLoading}
        className="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 disabled:bg-gray-400"
      >
        {isLoading ? 'Recording...' : 'Record Transaction'}
      </button>

      {data && (
        <div className="mt-4 p-3 bg-gray-50 rounded-md">
          <p className="text-sm font-mono break-all">
            Transaction Recorded: {data.id}
          </p>
        </div>
      )}

      {isError && error && (
        <div className="mt-4 p-3 bg-red-50 text-red-700 rounded-md">
          Error: {error.message}
        </div>
      )}
    </div>
  );
}
```

## Security Considerations

* Always verify recipient addresses
* Use encrypted private keys
* Implement proper PIN validation
* Monitor transaction status

## Error Handling

* Handle insufficient token balance
* Validate wallet addresses
* Monitor gas fees
* Implement retry logic for failed transactions

<Danger>
  Always verify recipient addresses. Transfers on StarkNet are irreversible.
</Danger>

## Related Hooks

* **useTransfer** - Execute the transfer before recording it
* **useGetTransactionList** - List all recorded transactions
