Skip to content

Latest commit

 

History

History
131 lines (122 loc) · 15.2 KB

File metadata and controls

131 lines (122 loc) · 15.2 KB

🕵️‍♂️ InterfaceDetector

This agent uses ContractInspector alerts and it automatically detects for interfaces adherences and contract type.

It detects contracts:

It detects interfaces:

How to support more interfaces

  • Create a new isItXXX function in src/inspectors.ts file where XXX is the name of the interface you want to support.
  • In this new function add the function and events names of the interface definition into the functionsInInterface and eventsInInterface. Be sure to remove parameters name and indexes/memory/calldata keywords or any other keyword that is not used to calculate the signatures of those functions and events.
  • Add isItXXX to the imports of the agent.ts file.
  • Call the isItXXX function inside the analyzeInterface and take the call results.
  • Use the call results to push a new object into the observationResults array. Look at other examples to know how to fill the pushing object. Be sure to do this before observationResults is returned.

Output

  • Test block: npm run block 15128926
{
  "name": `Interface detected`,
  "description": `Contract {contractAddress} adheres to some interfaces`
  "alertId": `ID`,
  "protocol": "ethereum",
  "severity": "Info",
  "type": "Info",
  "metadata": {
    "types": // A list of supported interfaces
    "contractAddress": , // the contract address
    "overallConfidence": , // confidence level, many function signatures can correspond to different actual functions
    "extras": "{}" // extra fields
  }
}