Huobi Eco Chain Developer APIs

SVG

Access Blockchain Data

SVG

Building DAPPs

SVG

Verify Contracts

SVG

Community Driven

Introduction


The Huobi Eco Chain Developer APIs are provided as a community service and without warranty, so please use what you need and no more. We support both GET/POST requests and there is a rate limit of 5 calls per sec/IP.

Note: Source attribution via a link back or mention that your app is "Powered by hecoinfo.com APIs" is required except for personal/private usage.


Account APIs


Get a list of 'Normal' Transactions By Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

                                    https://api.hecoinfo.com/api?module=account&action=txlist&address=0xc9121e476155ebf0b794b7b351808af3787e727d&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken
                                

(Returned 'isError' values: 0=No Error, 1=Got Error)

(Returns up to a maximum of the last 10000 transactions only)

or

                                    https://api.hecoinfo.com/api?module=account&action=txlist&address=0xc9121e476155ebf0b794b7b351808af3787e727d&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=YourApiKeyToken
                                

(To get paginated results use page=<page number> and offset=<max records to return>)


Get a list of 'Internal' Transactions by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

                                    https://api.hecoinfo.com/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&startblock=0&endblock=2702578&sort=asc&apikey=YourApiKeyToken
                                

(Returned 'isError' values: 0=No Error, 1=Got Error)

(Returns up to a maximum of the last 10000 transactions only)

or

                                    https://api.hecoinfo.com/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&startblock=0&endblock=2702578&page=1&offset=10&sort=asc&apikey=YourApiKeyToken
                                

(To get paginated results use page=<page number> and offset=<max records to return>)


Get "Internal Transactions" by Transaction Hash

                                    https://api.hecoinfo.com/api?module=account&action=txlistinternal&txhash=0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170&apikey=YourApiKeyToken
                                

(Returned 'isError' values: 0=Ok, 1=Rejected/Cancelled)

(Returns up to a maximum of the last 10000 transactions only)


Get "Internal Transactions" by Block Range

                                    https://api.hecoinfo.com/api?module=account&action=txlistinternal&startblock=0&endblock=2702578&page=1&offset=10&sort=asc&apikey=YourApiKeyToken
                                

(Returns up to a maximum of the last 10000 transactions only)


Get a list of "HRC-20 - Token Transfer Events" by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

                                    https://api.hecoinfo.com/api?module=account&action=tokentx&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken
                                

(Returns up to a maximum of the last 10000 transactions only)

or

                                    https://api.hecoinfo.com/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&page=1&offset=100&sort=asc&apikey=YourApiKeyToken
                                

(To get paginated results use page=<page number> and offset=<max records to return>)

or

                                    https://api.hecoinfo.com/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&page=1&offset=100&sort=asc&apikey=YourApiKeyToken
                                

(To get transfer events for a specific token contract, include the contractaddress parameter)

Contract APIs

A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract

    var Web3 = require('web3');
    var web3 = new Web3(new Web3.providers.HttpProvider());
    var version = web3.version.api;
            
    $.getJSON('https://api.hecoinfo.com/api?module=contract&action=getabi&address=0xc9121e476155ebf0b794b7b351808af3787e727d&apikey=YourApiKeyToken', function (data) {
    var contractABI = "";
        contractABI = JSON.parse(data.result);
        if (contractABI != ''){
            var MyContract = web3.eth.contract(contractABI);
            var myContractInstance = MyContract.at("0xc9121e476155ebf0b794b7b351808af3787e727d");
            var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");
            console.log("result1 : " + result);
            var result = myContractInstance.members(1);
            console.log("result2 : " + result);
        } else {
            console.log("Error" );
        }
    });
                                

Get Contract Source Code for Verified Contract Source Codes

                                    1. https://api.hecoinfo.com/api?module=contract&action=getsourcecode&address=0xc9121e476155ebf0b794b7b351808af3787e727d&apikey=YourApiKeyToken (replace the address parameter with the actual contract address)

2. Terms of usage: Please see the usage terms policy

Verify Source Code (beta)

                                    1. Requires a valid HecoInfo APIkey, will reject if otherwise
2. Current daily limit of 100 submissions per day per user (subject to change)
3. Only supports HTTP post due to max transfer size limitations for http get
4. Supports up to 10 different library pairs
5. Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files. You can try using the Blockcat solidity-flattener or SolidityFlattery
6. List of supported solc versions, only solc version v0.4.11 and above is supported. Ex. v0.4.25+commit.59dbf8f1
7. Upon successful submission you will receive a GUID (50 characters) as a receipt.
8. You may use this GUID to track the status of your submission
9. Verified Source Codes will be displayed at contractsVerified

See Demo Source Verification Submission Code at Source Code Verification Sample

Source Code Submission Gist (returns a guid as part of the result upon success):

    //Submit Source Code for Verification
    $.ajax({
        type: "POST",                       //Only POST supported  
        url: "//api.hecoinfo.com/api", //Set to the  correct API url for Other Networks
        data: {
            apikey: $('#apikey').val(),                     //A valid API-Key is required        
            module: 'contract',                             //Do not change
            action: 'verifysourcecode',                     //Do not change
            contractaddress: $('#contractaddress').val(),   //Contract Address starts with 0x...     
            sourceCode: $('#sourceCode').val(),             //Contract Source Code (Flattened if necessary)
            codeformat: $('#codeformat').val(),             //solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support
            contractname: $('#contractname').val(),         //ContractName (if codeformat=solidity-standard-json-input, then enter contractname as ex: erc20.sol:erc20)
            compilerversion: $('#compilerversion').val(),   // see https://hecoinfo.com/solcversions for list of support versions
            optimizationUsed: $('#optimizationUsed').val(), //0 = No Optimization, 1 = Optimization used (applicable when codeformat=solidity-single-file)
            runs: 200,                                      //set to 200 as default unless otherwise  (applicable when codeformat=solidity-single-file)        
            constructorArguements: $('#constructorArguements').val(),   //if applicable
            evmversion: $('#evmVersion').val(),             //leave blank for compiler default, homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul (applicable when codeformat=solidity-single-file)
            licenseType: $('#licenseType').val(),           //Valid codes 1-12 where 1=No License .. 12=Apache 2.0, see https://hecoinfo.com/contract-license-types
            libraryname1: $('#libraryname1').val(),         //if applicable, a matching pair with libraryaddress1 required
            libraryaddress1: $('#libraryaddress1').val(),   //if applicable, a matching pair with libraryname1 required
            libraryname2: $('#libraryname2').val(),         //if applicable, matching pair required
            libraryaddress2: $('#libraryaddress2').val(),   //if applicable, matching pair required
            libraryname3: $('#libraryname3').val(),         //if applicable, matching pair required
            libraryaddress3: $('#libraryaddress3').val(),   //if applicable, matching pair required
            libraryname4: $('#libraryname4').val(),         //if applicable, matching pair required
            libraryaddress4: $('#libraryaddress4').val(),   //if applicable, matching pair required
            libraryname5: $('#libraryname5').val(),         //if applicable, matching pair required
            libraryaddress5: $('#libraryaddress5').val(),   //if applicable, matching pair required
            libraryname6: $('#libraryname6').val(),         //if applicable, matching pair required
            libraryaddress6: $('#libraryaddress6').val(),   //if applicable, matching pair required
            libraryname7: $('#libraryname7').val(),         //if applicable, matching pair required
            libraryaddress7: $('#libraryaddress7').val(),   //if applicable, matching pair required
            libraryname8: $('#libraryname8').val(),         //if applicable, matching pair required
            libraryaddress8: $('#libraryaddress8').val(),   //if applicable, matching pair required
            libraryname9: $('#libraryname9').val(),         //if applicable, matching pair required
            libraryaddress9: $('#libraryaddress9').val(),   //if applicable, matching pair required
            libraryname10: $('#libraryname10').val(),       //if applicable, matching pair required
            libraryaddress10: $('#libraryaddress10').val()  //if applicable, matching pair required
        },
        success: function (result) {
            console.log(result);
            if (result.status == "1") {
                //1 = submission success, use the guid returned (result.result) to check the status of your submission.
                // Average time of processing is 30-60 seconds
                document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;
                // result.result is the GUID receipt for the submission, you can use this guid for checking the verification status
            } else {
                //0 = error
                document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;
            }
            console.log("status : " + result.status);
            console.log("result : " + result.result);
        },
        error: function (result) {
            console.log("error!");
            document.getElementById("postresult").innerHTML = "Unexpected Error"
        }
    });
                                

Check Source code verification submission status:

    //Check Source Code Verification Status
    $.ajax({
        type: "GET",
        url: "//api.hecoinfo.com/api",
        data: {
            apikey: $('#apikey').val(), 
            guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above
            module: "contract",
            action: "checkverifystatus"
        },
        success: function (result) {
            console.log("status : " + result.status);   //0=Error, 1=Pass 
            console.log("message : " + result.message); //OK, NOTOK
            console.log("result : " + result.result);   //result explanation
            $('#guidstatus').html(">> " + result.result);
        },
        error: function (result) {
            alert('error');
        }
    });
                                

General Stats APIs


Get Total Supply of HT on the Huobi Eco Chain

                                    https://api.hecoinfo.com/api?module=stats&action=htsupply&apikey=YourApiKeyToken
                                

(Result returned in Wei, to get value in HT divide the ResultAbove/1000000000000000000)

Public HECO RPC Nodes


Mainnet HECO RPC Nodes

                                    Mainnet HECO RPC Endpoints (ChainID 128):

https://http-mainnet.hecochain.com
https://http-mainnet-node.huobichain.com (China Mainland)

Testnet HECO RPC Nodes

                                    Testnet HECO RPC Endpoints (ChainID 256):

https://http-testnet.hecochain.com

Usage Notes:

                                    Start
You can start the HTTP JSON-RPC with the --rpc flag

## mainnet
geth attach https://http-mainnet.hecochain.com

## testnet
geth attach https://http-testnet.hecochain.com

JSON-RPC methods
Please refer to this wiki page or use Postman: https://documenter.getpostman.com/view/4117254/ethereum-json-rpc/RVu7CT5J?version=latest