Skip to main content

Error-Handling

Each Hook returns an error object containing error details. It is recommended to use a UI library (such as react-toastify or sonner) to display user-friendly error messages.

import { toast } from 'sonner';

function ErrorHandler({ error }) {
useEffect(() => {
if (error) {
toast.error('Operation failed', {
description: error.message || error.msg || 'Please try again later',
});
}
}, [error]);

return null;
}

Common Errors

  • Network Error: API request failed, check network connection or API status.
  • Insufficient Balance: User wallet does not have enough tokens, prompt user to top up.
  • Parameter Error: Input chain ID, token address, or amount format error, validate input.
  • Contract Error: Smart contract call failed, check contract address and ABI.
  • Insufficient Gas: Not enough gas, prompt user to increase gas limit.