Smart Contract API

Endpoint Overview

TokenInfo.AI provides endpoints for retrieving the source code of a smart contract and auditing the smart contract. These endpoints are essential for developers and security auditors who want to verify and ensure the integrity of smart contracts deployed on various blockchain networks.

Endpoints

  1. Retrieve Contract Source Code

  2. Audit Smart Contract

Retrieve Contract Source Code

Endpoint

GET/contract/:chain/:address/source

Request Parameters

Parameters

  • address:

    • Type: String

    • Description: The address of the smart contract. This parameter is required.

  • chain:

    • Type: Number (optional)

    • Description: The network chain on which the smart contract is deployed. Defaults to 1 (Ethereum) if not provided. Use 900 for Solana.

Request Example

Here is an example of how to structure the request:

GET /contract/1/0xContractAddress/source
Content-Type: application/json

Response

The response from the endpoint will vary depending on the success or failure of the request.

Success Response

  • Status Code: 200 OK

  • Response Body:

{
  "status": true,
  "result": [
    {
      "source": "pragma solidity ^0.5.0; contract YourContract { ... }",
      "name": "YourContract",
      "isProxy": false
    }
  ]
}

Error Responses

  1. Missing Parameters

    • Status Code: 400 Bad Request

    • Response Body:

    {
      "error": "Missing parameters",
      "expecting": "contractAddress"
    }
  2. Unsupported Chain

    • Status Code: 400 Bad Request

    • Response Body:

    {
      "error": "Unsupported blockchain network"
    }
  3. Source Code Not Found

    • Status Code: 404 Not Found

    • Response Body:

    {
      "status": false,
      "msg": "Source code not found"
    }
  4. Internal Server Error

    • Status Code: 500 Internal Server Error

    • Response Body:

    {
      "error": "An internal server error occurred"
    }

Audit Smart Contract

Endpoint

POST /contract/audit

Request Parameters

Body Parameters

  • sourceCode:

    • Type: String

    • Description: The source code of the smart contract. This parameter is required.

Request Example

Here is an example of how to structure the request:

POST /contract/audit
Content-Type: application/json

{
  "sourceCode": "pragma solidity ^0.5.0; contract YourContract { ... }"
}

Response

The response from the endpoint will vary depending on the success or failure of the request.

Success Response

  • Status Code: 200 OK

  • Response Body:

{
  "status": true,
  "result": "Audit result details here..."
}

Error Responses

  1. Missing Parameters

    • Status Code: 400 Bad Request

    • Response Body:

    {
      "error": "Missing parameters",
      "expecting": "sourceCode"
    }
  2. Internal Server Error

    • Status Code: 500 Internal Server Error

    • Response Body:

    {
      "error": "An internal server error occurred"
    }

By utilizing the Contract Management Endpoints, developers and auditors can efficiently retrieve the source code of deployed smart contracts and perform audits to ensure their security and integrity within the TokenInfo.AI platform.

Last updated