Skip to content

Latest commit

 

History

History
252 lines (175 loc) · 10.6 KB

TTC_Rest_API_Documentation.md

File metadata and controls

252 lines (175 loc) · 10.6 KB

TTC Base Rest API

Methods

Get_block_info_by_block_number

GET https://api.ttcnet.io/api/node/block/{height}

Description

Gets information for a block at the given height.

Response

The response body will include the block’s hash, height (null for orphaned blocks), and transaction information.

{
  "errno": 0,
  "errmsg": "",
  "data": {
    "difficulty": "1",
    "extraData": "0xd7820103846765746888676f312e31312e35856c696e75780000000000000000f90259c0c0c0c0c0845c6688f8f83f94aef47cf078825297bb897b8cf8d72d0757fa157d949f4fa2a2c5195cb8ad0521181aab31a55b5bfb3194752c939ade161dfc460346c34a1bb415c87a60bfd594752c939ade161dfc460346c34a1bb415c87a60bf8203e6f901eff901eca000000000000000000000000000000000000000000000000000000000000000019443a788f4fb5889d6098ecdbbce2b723380f369508208d2f901b08432323531aa7431343361373838463466623538383944363039386543644262636532623732333338306633363935308432323530aa7431343361373838463466623538383944363039386543644262636532623732333338306633363935308432323439aa7431343361373838463466623538383944363039386543644262636532623732333338306633363935308432323438aa7431304235386137663836434138643035333435453643353341303433373941363836366266423238398432323437aa7431304235386137663836434138643035333435453643353341303433373941363836366266423238398432323436aa7431304235386137663836434138643035333435453643353341303433373941363836366266423238398432323435aa7431346631323033356444344232463134354638394138424338393937663230653064663942313441378432323434aa7431346631323033356444344232463134354638394138424338393937663230653064663942313441378432323433aa743134663132303335644434423246313435463839413842433839393766323065306466394231344137c0c0c02349d03ecb748fea43820e90250fe4c2e8cbd18567fc88d83c54cbfb27b6d44c311341cd501719fd1b925ca02c069d381bca4447f7e663572c723bd57689187c01",
    "gasLimit": 50000000,
    "gasUsed": 57176,
    "hash": "t003b025fbe173e8f0b55480c4341c3706f7d8784e0410d97387bee4028f500078",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0xt09F4Fa2a2c5195cb8ad0521181AAB31a55b5bFB31",
    "mixHash": "t00000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "parentHash": "t04686786c678bc8db78357adc35b56e96c71e347b78a5331555e34a0ad3f448c3",
    "receiptsRoot": "t0c05aa9fc985c8960e79a289ed90cef982a3e1b7c379aaa181403c4ce4154670c",
    "sha3Uncles": "t01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": 1858,
    "stateRoot": "t017b8fea4834145361e0659850b452005a45cbe5746f4c048967c5a469f26b245",
    "timestamp": 1553490494,
    "totalDifficulty": "1001",
    "transactions": [
      "t0e2ff82ca60f7a6138422598186f79a4dac007a61a398551c478d06a4b3bd3b4a"
    ],
    "transactionsRoot": "t0a8b396ebb1e510e2325fc6d9eee724e8f896c814f50b30550f8f0ff001f29dc8",
    "uncles": [
      
    ],
    "height": 1000
  }
}

Get_block_info_by_block_hash

GET https://api.ttcnet.io/api/node/block/{hash}

Description

Gets information for a block with the given hash.

Response

The response body will include the block’s hash, height (null for orphaned blocks), and transaction information.


  "errno": 0,
  "errmsg": "",
  "data": {
    "difficulty": "1",
    "extraData": "0xd7820103846765746888676f312e31312e35856c696e75780000000000000000f90259c0c0c0c0c0845c6688f8f83f94aef47cf078825297bb897b8cf8d72d0757fa157d949f4fa2a2c5195cb8ad0521181aab31a55b5bfb3194752c939ade161dfc460346c34a1bb415c87a60bfd594752c939ade161dfc460346c34a1bb415c87a60bf8203e6f901eff901eca000000000000000000000000000000000000000000000000000000000000000019443a788f4fb5889d6098ecdbbce2b723380f369508208d2f901b08432323531aa7431343361373838463466623538383944363039386543644262636532623732333338306633363935308432323530aa7431343361373838463466623538383944363039386543644262636532623732333338306633363935308432323439aa7431343361373838463466623538383944363039386543644262636532623732333338306633363935308432323438aa7431304235386137663836434138643035333435453643353341303433373941363836366266423238398432323437aa7431304235386137663836434138643035333435453643353341303433373941363836366266423238398432323436aa7431304235386137663836434138643035333435453643353341303433373941363836366266423238398432323435aa7431346631323033356444344232463134354638394138424338393937663230653064663942313441378432323434aa7431346631323033356444344232463134354638394138424338393937663230653064663942313441378432323433aa743134663132303335644434423246313435463839413842433839393766323065306466394231344137c0c0c02349d03ecb748fea43820e90250fe4c2e8cbd18567fc88d83c54cbfb27b6d44c311341cd501719fd1b925ca02c069d381bca4447f7e663572c723bd57689187c01",
    "gasLimit": 50000000,
    "gasUsed": 57176,
    "hash": "t003b025fbe173e8f0b55480c4341c3706f7d8784e0410d97387bee4028f500078",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0xt09F4Fa2a2c5195cb8ad0521181AAB31a55b5bFB31",
    "mixHash": "t00000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "parentHash": "t04686786c678bc8db78357adc35b56e96c71e347b78a5331555e34a0ad3f448c3",
    "receiptsRoot": "t0c05aa9fc985c8960e79a289ed90cef982a3e1b7c379aaa181403c4ce4154670c",
    "sha3Uncles": "t01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": 1858,
    "stateRoot": "t017b8fea4834145361e0659850b452005a45cbe5746f4c048967c5a469f26b245",
    "timestamp": 1553490494,
    "totalDifficulty": "1001",
    "transactions": [
      "t0e2ff82ca60f7a6138422598186f79a4dac007a61a398551c478d06a4b3bd3b4a"
    ],
    "transactionsRoot": "t0a8b396ebb1e510e2325fc6d9eee724e8f896c814f50b30550f8f0ff001f29dc8",
    "uncles": [
      
    ],
    "height": 1000
  }
}

Get_transaction_info

GET https://api.ttcnet.io/api/node/transaction/{hash}

Description

Gets information for a transaction with the given hash.

Response

The response body will include the transaction’s hash, block information (null blockhash and height for pending transactions).

{
  "errno": 0,
  "errmsg": "",
  "data": {
    "blockHash": "t003b025fbe173e8f0b55480c4341c3706f7d8784e0410d97387bee4028f500078",
    "from": "0xt043a788F4FB5889D6098EcdbBCE2B723380f36950",
    "gas": 3000000,
    "gasPrice": "30000000",
    "hash": "t0e2ff82ca60f7a6138422598186f79a4dac007a61a398551c478d06a4b3bd3b4a",
    "input": "0x75666f3a313a73633a636f6e6669726d3a7431303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030313a323235383a313535333439303438383a32323531237431343361373838463466623538383944363039386543644262636532623732333338306633363935302332323530237431343361373838463466623538383944363039386543644262636532623732333338306633363935302332323439237431343361373838463466623538383944363039386543644262636532623732333338306633363935302332323438237431304235386137663836434138643035333435453643353341303433373941363836366266423238392332323437237431304235386137663836434138643035333435453643353341303433373941363836366266423238392332323436237431304235386137663836434138643035333435453643353341303433373941363836366266423238392332323435237431346631323033356444344232463134354638394138424338393937663230653064663942313441372332323434237431346631323033356444344232463134354638394138424338393937663230653064663942313441372332323433237431346631323033356444344232463134354638394138424338393937663230653064663942313441373a",
    "nonce": 226,
    "to": "0xt043a788F4FB5889D6098EcdbBCE2B723380f36950",
    "transactionIndex": 0,
    "value": "0",
    "v": "0xa68",
    "r": "0xdcfea0113cd6abeb4b42b00d2b630347527e7050b7d82a7653959c7d530ec972",
    "s": "0x2852e4477b04fa18f660c119554a263372df46f7f9b0ef638741492dfc4288ab",
    "blockHeight": 1000
  }
}

Get_node_info

GET https://api.ttcnet.io/api/node

Description

Gets information about a node.

Response

The response body will include number of connected peers, blockchain height, and gas price.

{
  "errno": 0,
  "errmsg": "",
  "data": {
    "connectedPeers": 2,
    "height": 69172,
    "gasPrice": 30000000
  }
}

Get_address_info

GET https://api.ttcnet.io/api/wallet/address/{address}

Description

Gets TTC balance of an address.

Response

When invoked with a valid address, will return HTTP 200 code and the response body will include the address’ balance.

When invoked with an invalid address, will return an HTTP 404 code

{
    "errno": 0,
    "errmsg": "",
    "data": {
        "balance": "409558325350499741412241"
    }
}

Create_account

POST https://api.ttcnet.io/api/wallet/address

Description

Creates a new address.

Recommend to create the wallet locally, and you can use the same method of creating Ethereum wallet and private key, fully compatible.

Response

The response body will include the newly-created address.

{
    "errno": 0,
    "errmsg": "",
    "data": {
        "address": "t0176B7858188c48aa32A557C02f7B206B28069Df5",
        "privateKey": "**********************************************************"


    }
}

Submit_transaction

POST https://api.ttcnet.io/api/wallet/transaction/

Description

Creates, signs, and submits a transaction to the network.

Params

signedTxData: "Your signed transaction data"

Place this field in the request body.

Response

The response body will include the transaction ID.

{
"txHash": "t02d0f25b1e10b847b3e41755fab6e9bfab2c99d44d1700d49cad5848825a71073"
}