Transactions
Transaction Hooks
Core Transaction Hooks
Types
// Transaction Types
type TransactionStatus = 'ready' | 'pending' | 'waitingConfirmation' | 'success' | 'error';
type TransactionStatusErrorType = {
type: 'UserRejectedError' | 'RevertReasonError';
reason: string;
};
type EnhancedClause = {
to: string;
value?: string;
data?: string;
comment?: string;
abi?: any;
};
interface TransactionHookReturnValue {
sendTransaction: (clauses?: TransactionClause[]) => Promise<void>;
isTransactionPending: boolean;
isWaitingForWalletConfirmation: boolean;
txReceipt: TransactionReceipt | null;
status: TransactionStatus;
resetStatus: () => void;
error?: TransactionStatusErrorType;
}
interface TransferVETParams {
fromAddress: string;
receiverAddress: string;
amount: string;
onSuccess?: () => void;
onError?: (error: Error) => void;
}
interface TransferERC20Params {
fromAddress: string;
receiverAddress: string;
amount: string;
tokenAddress: string;
tokenName: string;
onSuccess?: () => void;
onError?: (error: Error) => void;
}
interface SendTransactionParams {
signerAccountAddress: string;
clauses: EnhancedClause[];
onTxConfirmed?: () => void;
onTxFailedOrCancelled?: () => void;
}Usage example
Last updated
Was this helpful?