Search documentation

 

Welcome to Anyblock Chainlink documentation!

This documentation is about how to use our Anyblock oracles in connection to Chainlink. We have been working with the Chainlink team since summer 2019.

Here you will see their different technical methods to create chainlinked contracts with their different parameters.
This Chainlink has a dedicated connection to the Anyblock Index API and Chainlink will allow requesters to create queries to the API, and return the response.

1. Steps for using this oracle

  1. Write and deploy your Chainlinked contract using the network details below
  2. Fund it with LINK
  3. Call your request method

2. Chainlink Network Details

You will need to use the following LINK token address, oracle address, and Job ID in order to create the Chainlink request.

2.1. Kovan (test network)

Oracle address: 0xc99B3D447826532722E41bc36e644ba3479E4365
Bytes32 JobID: 1e4cf658207a4708b9c0d104c31b8f86
Uint256 JobID: 59411b9de93742c8b9236f52ae492558
Price: 1 (test-)LINK is required per-request on Kovan – Kovan faucet

LINK Token address: 0x20fE562d797A42Dcb3399062AE9546cd06f63280

2.2. Mainnet (live network)

Oracle address: 0x9308B0Bd23794063423f484Cd21c59eD38898108
JobID Anyblock > UInt256: 6005cda8b61b43e8a0c9e323ce583cc5
JobID Anyblock > Bytes32: 628509ad2770481a8a43f75dad89ec94
Price: 0.1 LINK

LINK Token address: 0x514910771AF9Ca656af840dff83E8264EcF986CA

For more Mainnet Adapters & JobIDs (for example the Anyblock DeFi price feeds), please refer to: Anyblock Analytics Mainnet Adapters & JobIDs

3. Create your Chainlinked contract

Import ChainlinkClient.sol into your contract so you can inherit the ability to create Chainlink requests.

pragma solidity ^0.4.24;
import "chainlink/contracts/ChainlinkClient.sol"; 
contract EthEventsChainlink is ChainlinkClient { 
  uint256 oraclePayment; 
  constructor(uint256 _oraclePayment) public {
	setPublicChainlinkToken();
	oraclePayment = _oraclePayment;
  }
  // Additional functions here: 
}

3.1. Tasks

Bytes32 Job

Uint256 Job

3.2. Request Parameters

query | Required | The query for the adapter to use. Available options are:

  • transaction: Get information on a specific transaction
  • blockhash: Get information about a block by its block hash
  • block: Get information about a block by its block number
  • log: Get logs from a given transaction

Solidity example:

req.add("query", "transaction");

id | Required | The unique identifier for the query. Can be a transaction hash, block number, or block hash.

Solidity example:

req.add("id", "0xdebb061255310e8c109379a2556fec666789c663225f20d16e8e1332f395b3c5");

The following URL is useful for the blockchain and network parameters: https://apidocs.anyblock.tools/
These parameters will allow you to select different supported blockchains and networks (like Ethereum Classic’s Morden, or Ethereum’s different test networks, or xDAI, POA, EWC etc.).

blockchain | The chain to use.

Solidity example:

req.add("blockchain", "ethereum");

network | The network to use.

Solidity example:

req.add("network", "mainnet");

copyPath | Required | The path of the desired data field to return to the smart contract.

Below are examples of the payload from different queries:

·       transaction
 
·       blockhash
 
·       block
 
·       log
{
     	"took": 18,
     	"timed_out": false,
     	"_shards": {
              	"total": 40,
              	"successful": 40,
              	"skipped": 0,
              	"failed": 0
     	},
     	"hits": {
              	"total": 1,
              	"max_score": 0,
              	"hits": [
                       	{
                                 	"_index": "0006-ethereum-ethereum-mainnet-tx",
                                 	"_type": "tx",
                                 	"_id": "0xdebb061255310e8c109379a2556fec666789c663225f20d16e8e1332f395b3c5",
                                 	"_score": 0,
                                 	"_source": {
                                          	"blockHash": "0x3b36d41b5478cdd30b133205de0adb72d21092dabfc87f2a9d835b5a53ec0f7e",
                                          	"blockNumber": {
                                                   	"raw": "8317172",
                                                   	"num": 8317172
                                          	},
                                          	"cumulativeGasUsed": {
                                                   	"raw": "6658336",
                                                   	"num": 6658336
                                          	},
                                          	"from": "0xA587fE3482B0d167970dc1e00D0CFff3258fbF16",
                                          	"gas": {
                                                   	"raw": "52048",
                                                   	"num": 52048
                                          	},
                                          	"gasPrice": {
                                                   	"raw": "1000000000",
                                                   	"num": 1000000000
                                          	},
                                          	"gasUsed": {
                                                   	"raw": "52048",
                                                   	"num": 52048
                                          	},
                                          	"hash": "0xdebb061255310e8c109379a2556fec666789c663225f20d16e8e1332f395b3c5",
                                          	"input": "0xa9059cbb000000000000000000000000833ffad0f7891f3fbcd98ac1b62f94d48815095400000000000000000000000000000000000000000000001b1ae4d6e2ef500000",
                                          	"logsBloom": "0x00000000000000000000000000000004000000000000000000000000000000000000000000000100000000000000000000000000000000000000020000000000000000000000000200000008000000000000000001000000000000000000000000002000000000000000000000000000000002000000000000000010000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000400000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
                                          	"nonce": {
                                                   	"raw": "4020",
                                                   	"num": 4020
                                          	},
                                          	"r": "0xda0ded98a2e951d84d2cd5f61ba84b9eb7e99846a70215cf250c0519075bc9ac",
                                          	"s": "0x1cf284db330016a0a74433bdf2146ea2597fc783a0a46aaf20a59aff7bc7e948",
                                          	"status": true,
                                          	"timestamp": 1565364196,
                                          	"to": "0x432555E5c898F83fC5F00dF631BD9c2801FeA289",
                                          	"publicKey": "0x99d5e9e3dfe0a4c02788f2e4e5b5836e6eb687b154eb6c75c5a563e745ffcaf9679866587eb0cb5d4634b1d7a5bcf67b18da52eec157e88b3bd6a59ac6b73d5f",
                                          	"transactionIndex": {
                                                   	"raw": "44",
                                                   	"num": 44
                                          	},
                                          	"standardV": "0x1",
                                          	"v": "0x26",
                                          	"value": {
                                                   	"raw": "0",
                                                   	"padded": "0x0000000000000000000000000000000000000000000000000000000000000000",
                                                   	"eth": 0,
                                                   	"num": 0
                                          	}
                                 	}
                       	}
              	]
     	}
}

Solidity example:

req.add("copyPath", "hits.hits.0.blocknumber.num");

3.3. Chainlink Examples

The examples below show how to create requests for the quotes and convert endpoints.

getConfirmations

·       getConfirmations
function getConfirmations(address _oracle, bytes32 _jobId, string _txid)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.checkTxConfirmations.selector);
  req.add("query", "transaction");
  req.add("id", _txid);
  req.add("copyPath", "hits.hits.0._source.blockNumber.num");
  sendChainlinkRequestTo(_oracle, req, oraclePayment);
}

Fulfill method
Here is an example of the fulfill method:

·       checkTxConfirmations
uint256 constant public REQUIRED_CONFIRMATIONS = 30;
 
function checkTxConfirmations(bytes32 _requestId, uint256 _blockNum)
  public
  recordChainlinkFulfillment(_requestId)
{
  if (_blockNum < block.number - REQUIRED_CONFIRMATIONS) {
	// do something
  }
}

3.4. Chainlink node infrastructure monitoring

We released two small open source projects to better monitor our infrastructure:

  • Blockchain Node Metrics fetches latest block and # of peers from RPC enabled Ethereum Node and writes the result in InfluxDB line protocol syntax.The image below shows the dashboard for multiple blockchain & #chainlink nodes:Chainlink monitoring
  • Chainlink Node Metrics does the same, but for #chainlink oracle nodes. Check out the readme and sourcecode on how to integrate with telegraf, let us know what you think or even send a pull request.

You can also find our dockerized #chainlink adapters:

  1. our @AmpleforthOrg Market Adapter
  2. our Anyblock Analytics API Adapter, to use the Anyblock Index as a cross-chain oracle data source from our 17+ networks

3.5. Further information about Chainlink oracles

Remember that you can use our Anyblock Chainlink oracle generically for pretty much any data that you can query with our API – see interactive swagger documentation for details on what is available.

You can find more information and additional resources about Chainlink on the Chainlink website and in their documentation.

BlockchainHub defines a blockchain oracle as “an agent that finds and verifies real-world occurrences and submits this information to a blockchain to be used by smart contracts.” And “an oracle is a data feed – provided by a third party service – designed for use in smart contracts on the blockchain.”
Some more explanations and use case examples can be found in our article about blockchain oracles.

And of course, we are happy to personally answer any questions you might have and discuss possible oracle use cases with you – just send a message to contact@anyblockanalytics.com!

Interested or questions?

 

Sascha Göbel
(Co-Founder & Chief Technology Officer)
sascha@anyblockanalytics.com
+49 6131 3272372

    

Pin It on Pinterest