example-chainlinks
所属分类:数值算法/人工智能
开发工具:Solidity
文件大小:630KB
下载次数:0
上传日期:2022-12-09 21:37:37
上 传 者:
sh-1993
说明: 示例链接,用于去中心化oracle网络的示例链接<https:链接.link>
文件列表:
build (0, 2020-12-18)
build\contracts (0, 2020-12-18)
build\contracts\APIAggregatorConsumer.json (409246, 2020-12-18)
build\contracts\AliceAndBob.json (746338, 2020-12-18)
build\contracts\AlphaVantageConsumer.json (255945, 2020-12-18)
build\contracts\AssetPriceConsumer.json (277052, 2020-12-18)
build\contracts\Buffer.json (562067, 2020-12-18)
build\contracts\CBOR.json (382288, 2020-12-18)
build\contracts\Chainlink.json (239822, 2020-12-18)
build\contracts\ChainlinkClient.json (475314, 2020-12-18)
build\contracts\ChainlinkRequestInterface.json (31069, 2020-12-18)
build\contracts\Chainlinked.json (457018, 2020-12-18)
build\contracts\Consumer.json (215139, 2020-12-18)
build\contracts\ENSInterface.json (70093, 2020-12-18)
build\contracts\ENSResolver.json (8293, 2020-12-18)
build\contracts\LinkTokenInterface.json (83919, 2020-12-18)
build\contracts\Migrations.json (54211, 2020-12-18)
build\contracts\Oracle.json (618616, 2020-12-18)
build\contracts\OracleInterface.json (41048, 2020-12-18)
build\contracts\Ownable.json (89816, 2020-12-18)
build\contracts\PointerInterface.json (6364, 2020-12-18)
build\contracts\RapidAPIWeatherConsumer.json (564131, 2020-12-18)
build\contracts\SafeMath.json (92411, 2020-12-18)
build\contracts\WolframAlphaConsumer.json (420182, 2020-12-18)
contracts (0, 2020-12-18)
contracts\APIAggregatorConsumer.sol (3207, 2020-12-18)
contracts\AliceAndBob.sol (2899, 2020-12-18)
contracts\AlphaVantageConsumer.sol (2262, 2020-12-18)
contracts\AssetPriceConsumer.sol (2594, 2020-12-18)
contracts\Consumer.sol (1688, 2020-12-18)
contracts\Migrations.sol (507, 2020-12-18)
contracts\RapidAPIWeatherConsumer.sol (4215, 2020-12-18)
contracts\WolframAlphaConsumer.sol (2393, 2020-12-18)
contracts\lib (0, 2020-12-18)
contracts\lib\Oracle.sol (67, 2020-12-18)
migrations (0, 2020-12-18)
... ...
# Example Chainlinks
Example Chainlinks that get data from various sources. Already deployed to Ropsten, you can run the included scripts to easily fetch data on-chain via Chainlink.
### Current examples:
- **AlphaVantage** ([Bridges URL](https://s3.linkpool.io/bridges/alphavantage.json))**:** Forex rates
- **[API Aggregator](https://github.com/linkpoolio/bridges/tree/master/examples/apiaggregator)**: Aggregate values from
multiple APIs for ETH & BTC.
- **[Asset Price](https://github.com/linkpoolio/asset-price-cl-ea):** Specify any crypto pair and get a price aggregated by weighted volume from all supported exchanges
that list a pair. Eg: BTC-USD, LINK-BTC, ETH-USDT, ADA-BTC.
- **[Wolfram Alpha](https://github.com/linkpoolio/bridges/tree/master/examples/wolframalpha):** Find the distance between
two locations in miles using the Short Answers API and natural language.
- **Rapid API (Weather)** ([Bridges URL](https://s3.linkpool.io/bridges/rapidapi.json))**:** Get the temperature,
humidity and windspeeds at any global location.
## Install
Install dependencies with yarn/npm.
## General Usage
To first use this on Ropsten, you can update `truffle.js` with your private key and RPC host for deployment.
This could be Infura or your own node for example.
**This repository includes the ropsten contract `build` files, so once you set up `truffle.js` you can use the scripts
on the Ropsten network.**
You can also deploy this locally using `ganache-cli`, but you need to deploy the `Oracle.sol` contract for
your Chainlink node and create a new job spec as per the example you want to use in `specs`.
### Setup
In `truffle.js` enter your mnemonic and Ethereum URL, eg Infura.
### Deployment
To deploy, run a standard Truffle migration (uses Truffle from local deps):
```
npm run migrate
```
### Requesting Data
#### Alpha Vantage
Request the current rate of the pound to the dollar:
```
npm run exec scripts/alphavantage/request.js -- GBP USD --network ropsten
npm run exec scripts/alphavantage/get.js -- GBP USD --network ropsten
```
#### API Aggregator
Request the current price of BTC aggregated from Coinbase & Bitstamp:
```
npm run exec scripts/apiaggregator/request.js -- --network ropsten
npm run exec scripts/apiaggregator/get.js -- --network ropsten
```
#### Asset Price
Request the price of BTC-USD aggregated from many exchanges:
```
npm run exec scripts/assetprice/request.js BTC USD -- --network ropsten
npm run exec scripts/assetprice/get.js BTC USD -- --network ropsten
```
LINK-BTC:
```
npm run exec scripts/assetprice/request.js LINK BTC -- --network ropsten
npm run exec scripts/assetprice/get.js LINK BTC -- --network ropsten
```
#### WolframAlpha Location Distance (Short Answers API)
Request the distance between London and Tokyo:
```
npm run exec scripts/wolframalpha/request.js London Tokyo -- --network ropsten
npm run exec scripts/wolframalpha/get.js London Tokyo -- --network ropsten
```
#### Rapid API Weather (OpenWeatherMap)
Request the temperature in Celsius:
```
npm run exec scripts/rapidapiweather/request.js metricTemp London,uk -- --network ropsten
npm run exec scripts/rapidapiweather/get.js metricTemp London,uk -- --network ropsten
```
Request the humidity percentage:
```
npm run exec scripts/rapidapiweather/request.js humidity London,uk -- --network ropsten
npm run exec scripts/rapidapiweather/get.js humidity London,uk -- --network ropsten
```
Request the windspeed in mph:
```
npm run exec scripts/rapidapiweather/request.js windSpeed London,uk -- --network ropsten
npm run exec scripts/rapidapiweather/get.js windSpeed London,uk -- --network ropsten
```
## Notes
The `truffle.js` ropsten network is configured to point to a [LinkPool](https://linkpool.io) node.
You don't need to change the configuration as our node will accept requests from your contract with no changes.
Although, you can edit the `jobId` and `oracleAddress` as specified in the Truffle configuration to point to
your own node.
近期下载者:
相关文件:
收藏者: