create account

ETCPlanet.org: How To Create Your Own Ethereum Classic Blockchain Explorer For Learning (& Fun) by cseberino

View this thread on: hive.blogpeakd.comecency.com
· @cseberino · (edited)
$2.83
ETCPlanet.org: How To Create Your Own Ethereum Classic Blockchain Explorer For Learning (& Fun)
![ETC](https://i.imgsafe.org/f9555d4001.jpg)

Ethereum Classic (ETC) blockchain explorers are convenient sources of information about the ETC blockchain.  They may appear complex, but, it is relatively easy to build your own!  Creating an ETC blockchain explorer is also a great learning exercise.

# Requirements

![checkmarks](https://i.imgsafe.org/73050c30cd.jpg)

ETC blockchain explorers require access to an ETC network node.  These computers contain continually updated copies of the ETC blockchain.  It is relatively easy to [set up an ETC node with Parity](https://steemit.com/etc/@cseberino/how-to-easily-set-up-an-amazing-ethereum-classic-node-and-talk-to-it-with-your-own-code).  Blockchain information can be obtained from ETC Parity nodes with [JavaScript Object Notation (JSON) commands](https://github.com/ethcore/parity/wiki/JSONRPC).  You will likely also want a web application framework to build a web interface.

Users should be able to at least request information about blocks, transactions and accounts.  These can all be specified with hashes.  Users should also be able to specify blocks with block numbers.  There is no immediate way to determine if a 32 byte hash refers to a block or transaction.  You may have to search for both a block *and* a transaction to see which leads to nonempty results.

Here is Python code that processes search requests, and sends JSON commands to a local ETC Parity node, to get the relevant blockchain information:

```
import urllib.request
import json

NODE_URL           = "http://127.0.0.1:8545"
N_TRANS_HASH_BYTES = 32

def do_json_rpc(method, args):
        """
        Does a JSON RPC command.
        """

        node_data = {"method"  : method,
                     "params"  : args,
                     "jsonrpc" : "2.0",
                     "id"      : 1}
        node_data = json.dumps(node_data).encode()
        node_post = urllib.request.Request(NODE_URL)
        node_post.add_header("Content-Type", "application/json")
        node_post = urllib.request.urlopen(node_post, node_data).read().decode()

        return json.loads(node_post)

def get_blockchain_info(search_text):
        """
        Gets blockchain info.
        """

        search_text = search_text.strip()
        if search_text.startswith("0x"):
                if len(search_text) == 2 * N_TRANS_HASH_BYTES + 2:
                        method = "eth_getTransactionByHash"
                        data   = do_json_rpc(method, [search_text])
                        if (not "result" in data) or (not data["result"]):
                                method = "eth_getBlockByHash"
                                args   = [search_text, "false"]
                                data   = do_json_rpc(method, args)
                else:
                        method  = "eth_getBalance"
                        data    = [do_json_rpc(method, [search_text])]
                        method  = "eth_getCode"
                        data   += [do_json_rpc(method, [search_text])]
        else:
                method = "eth_getBlockByNumber"
                data   = do_json_rpc(method, [search_text, "false"])
        try:
                if isinstance(data, list):
                        data = (search_text,
                                data[0]["result"],
                                data[1]["result"])
                else:
                        data = data["result"]
        except KeyError:
                method = None

        return (method, data)
```


# ETCPlanet.org

![planet](https://i.imgsafe.org/f99889e683.jpg)

I created the ETCPlanet.org blockchain explorer using the [Django web framework](https://www.djangoproject.com/) and [Nginx web server](https://nginx.org/en/).  Search requests are relayed to a local ETC Parity node and the corresponding blockchain information is quickly displayed.  Feel free to  [try it out](https://etcplanet.org) and [inspect the source code](https://bitbucket.org/seberino/etcplanet).

# Conclusion

![happy](https://i.imgsafe.org/f95547b415.jpg)

Best of luck if you decide to attempt this project.  If you need any assistance feel free to contact me.  If you are successful, you might consider benefiting the ETC community by announcing your new resource on the [ETC Reddit](https://www.reddit.com/r/EthereumClassic/), adding it to the [ETC bootstrap node list](https://github.com/ethereumproject/volunteer/issues/20), and, adding it to [the ETC network status monitor list](http://etcstats.net/).

# Feedback

Feel free to leave any comments or questions below.  You can also contact me by clicking any of these icons:

[![twitter](https://i.imgsafe.org/fcbc8685c1.png)](https://twitter.com/chris_seberino) [![facebook](https://i.imgsafe.org/fcbc627df9.png)](https://www.facebook.com/cseberino) [![linkedin](https://i.imgsafe.org/fcbcf09c9e.png)](https://www.linkedin.com/in/christian-seberino-776897110)

# Acknowledgements

I would like to thank IOHK (Input Output Hong Kong) for funding this effort.

# License

![license](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)

This work is licensed under the Creative Commons Attribution ShareAlike 4.0 International License.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 133 others
properties (23)
authorcseberino
permlinketcplanet-org-how-to-create-your-own-ethereum-classic-blockchain-explorer-for-learning-and-fun
categoryetc
json_metadata{"tags":["etc","eth","ethereumclassic","ethereum","blockchain"],"image":["https://i.imgsafe.org/f9555d4001.jpg","https://i.imgsafe.org/73050c30cd.jpg","https://i.imgsafe.org/f99889e683.jpg","https://i.imgsafe.org/f95547b415.jpg","https://i.imgsafe.org/fcbc8685c1.png","https://i.imgsafe.org/fcbc627df9.png","https://i.imgsafe.org/fcbcf09c9e.png","https://i.creativecommons.org/l/by-sa/4.0/88x31.png"],"links":["https://steemit.com/etc/@cseberino/how-to-easily-set-up-an-amazing-ethereum-classic-node-and-talk-to-it-with-your-own-code","https://github.com/ethcore/parity/wiki/JSONRPC","https://www.djangoproject.com/","https://nginx.org/en/","https://etcplanet.org","https://bitbucket.org/seberino/etcplanet","https://www.reddit.com/r/EthereumClassic/","https://github.com/ethereumproject/volunteer/issues/20","http://etcstats.net/","https://twitter.com/chris_seberino","https://www.facebook.com/cseberino","https://www.linkedin.com/in/christian-seberino-776897110"],"app":"steemit/0.1","format":"markdown"}
created2017-03-14 01:24:51
last_update2017-03-16 21:55:24
depth0
children2
last_payout2017-04-14 03:11:48
cashout_time1969-12-31 23:59:59
total_payout_value2.142 HBD
curator_payout_value0.690 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,185
author_reputation5,161,857,859,658
root_title"ETCPlanet.org: How To Create Your Own Ethereum Classic Blockchain Explorer For Learning (& Fun)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,715,221
net_rshares7,859,914,566,950
author_curate_reward""
vote details (197)
@machete · (edited)
ETC network status monitor link is http://etcstats.net/
👍  
properties (23)
authormachete
permlinkre-cseberino-etcplanet-org-how-to-create-your-own-ethereum-classic-blockchain-explorer-for-learning-and-fun-20170316t055629591z
categoryetc
json_metadata{"tags":["etc"],"links":["http://etcstats.net/"],"app":"steemit/0.1"}
created2017-03-16 05:56:39
last_update2017-03-16 05:58:27
depth1
children1
last_payout2017-04-14 03:11:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length55
author_reputation0
root_title"ETCPlanet.org: How To Create Your Own Ethereum Classic Blockchain Explorer For Learning (& Fun)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,734,766
net_rshares0
author_curate_reward""
vote details (1)
@cseberino · (edited)
Thanks!   Fixed.  Do you know why etcstats.net does not use at least a free letsencrypt cert to do SSL?  Just curious.
properties (22)
authorcseberino
permlinkre-machete-re-cseberino-etcplanet-org-how-to-create-your-own-ethereum-classic-blockchain-explorer-for-learning-and-fun-20170316t212954758z
categoryetc
json_metadata{"tags":["etc"],"app":"steemit/0.1"}
created2017-03-16 21:29:54
last_update2017-03-16 21:32:24
depth2
children0
last_payout2017-04-14 03:11:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length118
author_reputation5,161,857,859,658
root_title"ETCPlanet.org: How To Create Your Own Ethereum Classic Blockchain Explorer For Learning (& Fun)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,740,641
net_rshares0