ChainSentinel — Your eyes on the NEO Network

Tomás Carvalho
Blocksmith
Published in
3 min readAug 3, 2018

Generally, NEO dApps have their backend running on a decentralised network, using one or more Smart Contracts to provide them with the required backend logic. The client, on the frontend, makes some sort of action which will trigger a call to a Smart Contract and receive a reply.

But what if you want to monitor a Smart Contract? What if you want to know if a Smart Contract is being called or if a user has performed an action on a Smart Contract such as registering a new asset? What if you want to develop an application that reacts to whatever action was performed over a Smart Contract?

With ChainSentinel, we provide a service that lets you monitor every event emitted by any Smart Contract on the NEO Network by creating a webhook which will contact a selected endpoint with the data contained in that event. This way, you can update your application (or dApp) with events coming from the NEO network in almost real-time without having to run a network node in your end. By using webhooks your application just need to have an endpoint to handle simple HTTP POST requests, without the need for further integration.

How to use ChainSentinel

Using ChainSentinel is easy. After signing in you’ll have access to your dashboard. Here, you can add new webhooks to listen to smart contracts, either on the NEO Testnet or in the Mainnet. To do so, you just need to insert the hash of the contract you want to listen to, the endpoint you want the service to call whenever an event is emitted by the contract and the network where the contract is running.

ChainSentinel Dashboard

To help developers who just want to test the service, an example endpoint using the Flask Python framework is available here.

ChainSentinel also provides a documentation page, which is regularly updated and which covers the following steps.

Authenticating your Endpoint

In this alpha stage, when you add a new hook, the service will attempt to authenticate your endpoint by sending a POST request with an authentication request. This request will contain JSON data, which will identify the request as an authentication request and a random nonce:

{
“permission”: “asking”,
“nonce”: {random number}
}

To be authenticated your endpoint must reply to this request with the following data, giving permission for the service to contact the endpoint with further requests:

{
“permission”: “given”,
“nonce”: {random number}
}

Receiving event data

Your new hook should now have been created with success, appearing in your dashboard and new events emitted by the contract you want to listen to will be sent to the chosen endpoint.

Event data will be sent in the body of a POST request, to which your endpoint should reply with a 200 success code. If the service fails to deliver the request or the endpoint replies with an error code, the request will be rescheduled and a new delivery will be attempted later.

Event data will be structured as follows:

{
“event_type”: “{value}”,
“contract_hash”: “{value}”,
“tx_hash”: “{value}”,
“block_number”: number,
“event_payload”:
{
“type”: “Array”,
“value”:
[
{
“type”: “ByteArray”,
“value”: “7472616e73666572”
},
{
“type”: “Integer”,
“value”: “number”
},
{
“type”: “String”,
“value”: “a given string”
},
{
“type”: “Boolean”,
“value”: “true”
},

]
},
“execution_success”: true,
“test_mode”: “{value}”,
“extra”: {‘network’: “{value}”}
}

Next Steps

In the near future, we will implement a Web Sockets interface and API to give your frontend app access to real-time information without the need for a backend endpoint.

ChainSentinel is in alpha stage, and as such we are looking for developers who want to try and test this service and give us some feedback, so feel free to do so and drop us an email with any suggestions you might have to hello@blocksmith.tech!

--

--

Tomás Carvalho
Blocksmith

I'm a Software Engineer with interest in Blockchain technology, Web Development and Internet Security. Working at blocksmith.tech.