Quick Start
Our data is accessible through the Chainlink decentralized oracle network. The table below gives the list of networks supported by our oracle and their corresponding details that you need to specify so as to get data from our oracle. You can visit the Chainlink documentation to learn more about working with their oracle network.
Shamba Oracle and Chain Ids
Network |
ETH_CHAIN_ID |
Mainnet Block Explorer for getting API key |
Testnet Block Explorer for deployed contract |
---|---|---|---|
Avalanche Fuji |
43113 |
||
Binance Testnet |
97 |
||
Ethereum Goerli |
5 |
||
Milkomeda-C1 Testnet |
200101 |
||
Moonbase Alpha |
1287 |
||
Optimism Goerli |
420 |
||
Polygon Mumbai |
80001 |
Accessing Shamba Chainlink Oracle
The Shamba Chainlink oracle provides geospatial data to smart contracts. To access it you need to import the ShambaGeoConsumer and ShambaFireConsumer smart-contracts from our smart-contract-kit or install it via our npm module. To make this process easier, we have provided tools like our contracts tool for generating boilerplate smart contract code to interact with our data oracle. And we also have our brownie and hardhat mixes setup for the Oracle Facing Smart Contracts to interact with the same.
Requesting Data From The Oracle
Deploy your Oracle Facing Smart Contract and then fund the same with 1 test LINK corresponding to your deployed contract’s network, and then call the requestGeostatsData()
or requestFireData()
function with the required parameters as explained in this README.
NOTE: You can get the LINK addresses and their corresponding faucets from here.
Response Data for Geo-Statistics
Data returned is of type map having two corresponding fields as a string storing the value of cid and an integer storing the value of geostatistic result (which is getting the value from the API multiplied by 10**18. This multiplication is done to remove all decimals from the data being returned on-chain).
You can see the response by calling the getGeostatsData()
and getLatestCid()
functions.
Response Data for Fire-Analysis
Data returned is of type map having two corresponding fields as a string that is storing the cid and an array that is storing the values of fire detection in the sequence of property ids, like 1 (if the fire is detected) and 9 (if the fire is not detected). The reason behind having the values as 1 and 9 is because the by-default value in the solidity (smart contract) is 0, so if there’s no data in any index of the array, then it returns it as 0.
We’re getting the value of fire-detection from the API as true or false, so assigning a value of 1 if it returns true and 9 if it returns false.
You can see the response by calling the getFireData()
and getLatestCid()
functions.