Smart Contract Scanner
A comprehensive smart contract analysis tool for security scanning, function exploration, and code verification.
Contract Scanner
Enter a contract address to analyze its security, ownership, and potential risks
Installation
Run the following command to add the Smart Contract Scanner component to your project:
npx shadcn@latest add https://w3-kit.com/registry/smart-contract-scanner.jsonThis will:
- Create the component in your
components/uidirectory - Add all necessary dependencies to your package.json
- Set up required configuration files
- Add contract scanning utilities to your project
Error Handling
The Smart Contract Scanner component provides comprehensive error handling through the onError callback and the ContractError enum.
Error Types
- INVALID_ADDRESS: The provided address doesn't match the Ethereum address format
- NOT_FOUND: The contract address doesn't exist on the blockchain
- NOT_VERIFIED: The contract exists but isn't verified
- NETWORK_ERROR: Connection issues with the blockchain provider
- SCAN_FAILED: General scanning failure
- RATE_LIMIT: API rate limit exceeded
- TIMEOUT: Request timeout
- UNKNOWN: Unspecified error
Example Error Handler
// Example error handler with different responses per error type
const handleContractError = (error: ContractError) => {
switch(error) {
case ContractError.INVALID_ADDRESS:
showNotification("Please enter a valid Ethereum address");
break;
case ContractError.NOT_FOUND:
showNotification("Contract not found on this network");
break;
case ContractError.NOT_VERIFIED:
showNotification("This contract is not verified", "warning");
break;
case ContractError.NETWORK_ERROR:
showNotification("Network connection error. Please try again", "error");
break;
case ContractError.RATE_LIMIT:
showNotification("Too many requests. Please wait and try again", "error");
break;
default:
showNotification("An error occurred while scanning the contract", "error");
}
};