Skip to content

Explorer module

hihiben edited this page Jan 30, 2018 · 3 revisions

Explorer module

API endpoints

Block

  • GET blocks
  • GET blocks/[:block_hash]
  • GET blocks/[:block_height]

Transaction

  • GET transactions/[:tx_hash]
  • GET transactions/address/[:address]
  • GET transaction/prepare
  • POST general-transaction/prepare

Address

  • GET addresses/[:address]/balance
  • GET addresses/[:address]/utxos
  • GET addresses/[:address]/op_return

Block APIs

GET blocks/

Description

Get latest 50 blocks.

Parameter

Field Type Description
starting_after String the transaction hash starting after, optional parameter
since Integer the since timestamp, optinal parameter
until Integer the until timestamp, optinal parameter
page_size Integer the page size (default 50), optinal parameter

Sample Response

{
    "blocks": [
        {
            "hash": "0000075f2770822d4449ed1b713b979d63092cf19a34873f0a1977ec0e369c0b",
            "height": "363",
            "previous_block_hash": "00000b5f7c9faf0e84e6af52663c947a81be1f6c7a635b81de4bf8a83ea1dc35",
            "next_blocks": [],
            "merkle_root": "09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a",
            "time": "1468553829",
            "bits": "504365040",
            "nonce": "314755",
            "version": "3",
            "branch": "main",
            "size": "331",
            "chain_work": "381687488",
            "confirmation": 9487,
            "difficulty": 0.0009765625,
            "transaction_count": "1",
            "transaction_hashes": [
                "09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a"
            ]
        },
        ...
    ]
}

GET blocks/[:block_hash]

Description

Get the block by block hash.

Parameter

None

Sample Response

{
    "block": {
        "hash": "0000075f2770822d4449ed1b713b979d63092cf19a34873f0a1977ec0e369c0b",
        "height": "363",
        "previous_block_hash": "00000b5f7c9faf0e84e6af52663c947a81be1f6c7a635b81de4bf8a83ea1dc35",
        "next_blocks": [],
        "merkle_root": "09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a",
        "time": "1468553829",
        "bits": "504365040",
        "nonce": "314755",
        "version": "3",
        "branch": "main",
        "size": "331",
        "chain_work": "381687488",
        "confirmation": 9487,
        "difficulty": 0.0009765625,
        "transaction_count": "1",
        "transaction_hashes": [
            "09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a"
        ]
    }
}

GET blocks/[:block_height]

Description

Get the block by block height.

Parameter

None

Sample Response

{
    "block": {
        "hash": "000001ea1d09a8dea7ba616e2597fb526b466781683e7d3d84fe5cbfbe9041c3",
        "height": "2",
        "previous_block_hash": "0000035db602164cbe634024e5e2ba062bf66a733d9606d070e710c9c9523e46",
        "next_blocks": [
            "000004e597624741edb882c695789b2c505b563f1df9989b522630e4d32e68f0"
        ],
        "merkle_root": "8837125afdb8bb3ecb6caee229bdb9ef12787d460e5180ffe41745d26ef1da1c",
        "time": "1466747144",
        "bits": "504365040",
        "nonce": "3815650",
        "version": "3",
        "branch": "main",
        "size": "505",
        "chain_work": "3145776",
        "confirmation": 9487,
        "difficulty": 0.0009765625,
        "transaction_count": "2",
        "transaction_hashes": [
            "d69a6c5b9167632344e41be4b5a215678c94a3e0798e2f35ac367b0ff29dfe3b",
            "668b26a613d26be927461e9d5d117e40adc7118ff0201e63366007111f985c30"
        ]
    }
}

Transaction APIs

GET transactions/[:tx_hash]

Description

Get the transaction by transaction hash.

Parameter

None

Sample Response

{
    "tx": {
        "hash": "09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a",
        "block_hash": "0000075f2770822d4449ed1b713b979d63092cf19a34873f0a1977ec0e369c0b",
        "version": "1",
        "locktime": "1468553828",
        "time": "1468553829",
        "confirmation": 9487,
        "vins": [
            {
                "tx_id": "668b26a613d26be927461e9d5d117e40adc7118ff0201e63366007111f985c30",
                "vout": 0,
                "address": "1BqRyqBK1AHQ55EWiqFXqytMc5R1DP2BZV",
                "scriptSig": "47304402200e5ccc1e5ec92e041b15ded0ed1de1a7c273ea10759ba58092b09dc743[...]",
                "sequence": "4294967294"
            }
        ],
        "vouts": [
            {
                "n": "0",
                "address": "1BqRyqBK1AHQ55EWiqFXqytMc5R1DP2BZV",
                "scriptPubKey": "210357adc9e9ea9b1919045fb02101e5fb1aa7adb35977656c1be841d0dbb5f87f4aac",
                "amount": "0"
            }
        ]
    }
}

GET transactions/address/[:address]

Description

Get transactions related with a certain address (50 transactions per page).

Parameter

Field Type Description
starting_after String the transaction hash starting after, optional parameter
since Integer the since timestamp, optinal parameter
until Integer the until timestamp, optinal parameter
page_size Integer the page size (default 50), optinal parameter

Sample Response

{
    "txs": [
        {
            "hash": "d69a6c5b9167632344e41be4b5a215678c94a3e0798e2f35ac367b0ff29dfe3b",
            "block_hash": "0000075f2770822d4449ed1b713b979d63092cf19a34873f0a1977ec0e369c0b",
            "version": "1",
            "locktime": "1468553828",
            "time": "1468553829",
            "confirmation": 9487,
            "vins": [
                {
                    "tx_id": "668b26a613d26be927461e9d5d117e40adc7118ff0201e63366007111f985c30",
                    "vout": 0,
                    "address": "1BqRyqBK1AHQ55EWiqFXqytMc5R1DP2BZV",
                    "scriptSig": "47304402200e5ccc1e5ec92e041b15ded0ed1de1a7c273ea10759ba58092b09dc743[...]",
                    "sequence": "4294967294"
                }
            ],
            "vouts": [
                {
                    "n": "0",
                    "address": "1BqRyqBK1AHQ55EWiqFXqytMc5R1DP2BZV",
                    "scriptPubKey": "210357adc9e9ea9b1919045fb02101e5fb1aa7adb35977656c1be841d0dbb5f87f4aac",
                    "amount": "0"
                }
            ]
        },
        ...
    ],
    "page": {
        "ending_before": "09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a",
        "starting_after": "d69a6c5b9167632344e41be4b5a215678c94a3e0798e2f35ac367b0ff29dfe3b",
        "next_uri": "/explorer/v1/transactions/address/1BqRyqBK1AHQ55EWiqFXqytMc5R1DP2BZV?starting_after=09596e072f6ea84fdd847226bb691b09a69b71b0f55cb54574165e8c91af656a"
    }
}

GET transaction/prepare

Description

Create a simple raw transaction that sends an amount of color to another address.

Parameter

Field Type Description
from_address str address
to_address str address
amount str amount
op_return_data (optional) str op return data (max 80 bytes)

Sample Response

{
    "raw_tx": "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510103ffffffff0200f2052a01000000232103e3e8f17d8a39e4b541713534ddf4e1c826a874b888e00a8d8a3b2f892a03150fac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000"
}

POST general-transaction/prepare

Description

Create a general raw transaction that sends colors from multiple addresses to others. Each sender should decide the amount and fee they want to provide. op_return_data is optional for recording extra information on chain.

Parameter

{
    "tx_in": # (required)
        [
            {
                "from_address": "", # (required)
                "amount": "", # (required)
                "fee": "" # (optional)
            },
            ......
        ],
    "tx_out": # (required)
        [
            {
                "to_address": "", # (required)
                "amount": "" # (required)
            },
            ......
        ],
     "op_return_data": "Hello blockchain." # (optional)
}

Sample Response

{
  "raw_tx": "01000000017e0b0880b36a7519be9ffccced0a37d100de2bbae13c41d415b683a7318cb11f00000000232103be54b29ee3ced0e6866e58469c5c0a9b7b485cadaa21cb711d5821c72185fdd0acffffffff0200e1f505000000001976a9144dbb7f813bc7899ae6a4f6b549abe7821b0e2d9088ac570400000000000000000000f76a4cf437323131303131303039373436353733373435663665363136643635313736343635373336333732363937303734363936663665356636383635366336633666356637373666373236633634303436653666366536353031303030303030303030303030303030303030303030303030303436653666366536353030303030303030303030303030303030303030303030303030306637373737373732653635373836313664373036633635326536333666366430303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030570400000000000002000000"
}

Address API

GET addresses/[:address]/balance

Description

Get a certain address balance

Parameter

None

Sample Response

{
    "balance": "2600",
}

GET addresses/[:address]/utxos

Description

Get a certain address unspent transaction outputs

Parameter

None

Sample Response

{
    "utxo": [
        {
            "tx": "d69a6c5b9167632344e41be4b5a215678c94a3e0798e2f35ac367b0ff29dfe3b",
            "n": "0"
            "value": "100"
        },
        ...
    ]
}

GET addresses/[:address]/op_return

Description

Get a certain address related op return transaction outputs

Parameter

None

Sample Response

{
    "txout": [
        {
            "tx": "23363f3bfedcbac7fc1897bf45d9f3d7a8477a9554cd67684ba9c84b042ddd2b",
            "n": "3",
            "op_return_data": "Hello blockchain."
        },
        ...
    ]
}