Magidoc

Example Queries

I want to inspect a contract for malicious behavior

#

The basic usage of the Trugard API is to query by contract ID and network ID to inspect contracts that users are considering interacting with. The following query will return a single contract that matches the provided contract ID and network ID. The response is configurable by the user.

    
  

#

    
  

This can also be optimized for performance, if you are looking to extract only the facets

    
  
    
  

I want to run a deeper analysis on a contract for malicious behavior

#

Many retail and institutional users will find this query useful for inspecting contracts that they are considering interacting with. This example is similar to the previous example, but includes additional information that may be useful for more advanced users, such as 4-byte signatures and opcodes.

    
  
    
  

I want to inspect contracts with a specific list of 4-Byte signatures

#

For users seeking a deeper inspection on collections of contracts, and looking for broader network wide patterns, Trugard makes available the ability to search our dataset by a "contract signature".

A four-byte signature on the EVM is a short code made up of four bytes that uniquely represents a function or operation within a smart contract. It acts like a simplified label that helps the EVM recognize and execute specific tasks or commands in a decentralized application.

Examining four-byte signatures is important for security analysis because they serve as unique labels for functions within smart contracts. By understanding and verifying these signatures, security experts can ensure that the intended actions of the smart contracts are executed, helping to identify and prevent potential vulnerabilities or malicious activities that could compromise the security of the Ethereum blockchain and its associated decentralized applications.

Web3 developers, security researchers, and auditors will find this query useful for inspecting collections of contracts that share a common function signature. This can help make informed decisions on whether to interact with a contract, or to help identify patterns of behavior across a network.

The following query surfaces smart contracts that meet the provided four byte selection criteria by providing the network name, and a list of four byte signatures. As with any other GraphQL API, the response is configurable by the user. The query will return up to 100 contracts.

    
  

The following is a snippet from the response for the query above. The full response contains a listing of 100 contracts with various parameters returned.

    
  

I want to get detailed facet information for a specific contract

#

For users who want to get detailed facet information for a specific contract, the following query can be used. The query returns facet details as well as the facet's decription, and risk.

    
  

#

    
  

GraphQL comparison features

#

There are also some comparison features that can be used to compare different contracts. You can query by deploy time, risk level, solidity compiler version, as some examples.

    
  
    
  

I want to query events over a specific time range

#

You can query the trugard API using time filters. Filters can also apply for things such as risk level and solidity compiler versions.

    
  

#

    
  

I want to know what contracts a specific address has deployed

#

Contracts have some metadata associated with it such as delployer and codesize. A common query may be to query by deployer.

    
  
    
  

I want to query by code size

#

Some developers would like to filter by the size of the code