The asset.check
method allows you to check the current threat status of a single asset. This method is ideal for real-time protection and individual asset verification.
API Reference
Method Signature
client . asset . check ( request : AssetCheckInput ): Promise < AssetCheckOutput >
Parameters
The asset check request object containing the asset type and content. Show AssetCheckInput Properties
The type of asset you are checking. Supported types: URL
, PAGE
, ADDRESS
.
The actual asset content you are checking.
For URL
or PAGE
assets: The URL of the asset
For ADDRESS
assets: The wallet or contract address
Returns
The threat status of the asset. Possible values: UNKNOWN
, ALLOWED
, BLOCKED
.
The reason why the asset was allowed or blocked (if applicable). ChainPatrol
aggregates data from multiple sources: - eth-phishing-detect
- Asset is on
MetaMask’s blocklist - reported
- Asset was reported by users and added to
ChainPatrol’s blocklist
Supported Asset Types
URL Web URLs and domains https://example.com
PAGE Specific web pages https://site.com/login
ADDRESS Crypto addresses 0x1234...abcd
Status Types
The asset has been identified as malicious or suspicious and should be blocked.
The asset has been verified as safe and can be trusted.
The asset hasn’t been classified yet. Use your own discretion or additional verification.
Getting Started
Quick Start
Basic Check
Address Check
Example Response
import { ChainPatrolClient } from "@chainpatrol/sdk" ;
const client = new ChainPatrolClient ({
apiKey: "cp_live_your_api_key_here" ,
});
const result = await client . asset . check ({
type: "URL" ,
content: "https://suspicious-site.com" ,
});
console . log ( result );
Basic Usage Patterns
// Simple safety check
async function isSafe ( url : string ) : Promise < boolean > {
const result = await client . asset . check ({
type: "URL" ,
content: url ,
});
return result . status !== "BLOCKED" ;
}
// Detailed threat analysis
async function analyzeThreat ( asset : string , type : "URL" | "ADDRESS" ) {
const result = await client . asset . check ({ type , content: asset });
return {
isSafe: result . status !== "BLOCKED" ,
status: result . status ,
reason: result . reason ,
recommendation:
result . status === "BLOCKED" ? "Block access" : "Allow access" ,
};
}
Implementation Guide
Real-time Protection
async function checkAssetSafety ( url : string ) : Promise < boolean > {
try {
const result = await client . asset . check ({
type: "URL" ,
content: url ,
});
switch ( result . status ) {
case "BLOCKED" :
console . warn ( `🚨 Blocked: ${ url } ( ${ result . reason } )` );
return false ;
case "ALLOWED" :
console . log ( `✅ Allowed: ${ url } ` );
return true ;
case "UNKNOWN" :
console . log ( `❓ Unknown: ${ url } - proceed with caution` );
return true ; // Or implement your own logic
default :
return true ;
}
} catch ( error ) {
console . error ( "Asset check failed:" , error );
return false ; // Fail safe
}
}
Browser Extension Integration
// Content script for browser extension
class URLMonitor {
private client : ChainPatrolClient ;
constructor ( apiKey : string ) {
this . client = new ChainPatrolClient ({ apiKey });
}
async checkCurrentPage () : Promise < void > {
const currentUrl = window . location . href ;
const result = await this . client . asset . check ({
type: "URL" ,
content: currentUrl ,
});
if ( result . status === "BLOCKED" ) {
this . showWarning ( result . reason );
}
}
private showWarning ( reason : string ) : void {
// Display warning to user
console . warn ( `⚠️ This site may be dangerous: ${ reason } ` );
}
}
Batch Checking with Rate Limiting
async function checkMultipleAssets ( assets : string []) {
const results = [];
for ( const asset of assets ) {
try {
const result = await client . asset . check ({
type: "URL" ,
content: asset ,
});
results . push ({ asset , ... result });
// Rate limiting - wait between requests
await new Promise (( resolve ) => setTimeout ( resolve , 100 ));
} catch ( error ) {
console . error ( `Failed to check ${ asset } :` , error );
}
}
return results ;
}
Technical Details
Error Handling
import { ChainPatrolClientError } from "@chainpatrol/sdk" ;
try {
const result = await client . asset . check ({
type: "URL" ,
content: "example.com" ,
});
} catch ( error ) {
if ( error instanceof ChainPatrolClientError ) {
console . error ( "API Error:" , error . message );
} else {
console . error ( "Unexpected error:" , error );
}
}
Rate Limits - Individual requests: Up to 10 requests per second -
Recommended for real-time checking - For bulk operations, use asset.list
instead
Performance Considerations - Cache results when possible to reduce API
calls - Implement exponential backoff for failed requests - Consider using
asset.list
for bulk checking scenarios
Additional Documentation