- Coinbase Pro account: https://pro.coinbase.com/
- NodeJS latest version: https://nodejs.org/
- yarn / npm: https://classic.yarnpkg.com/en/docs/install/
- ganache-cli
npm install -g ganache-cli
git clone https://github.com/compound-finance/open-oracle
cd open-oracle && yarn install
- In a separate terminal run
ganache-cli
to start a local testnet - (back to the main terminal) Compile contracts
yarn run compile
- Deploy OpenOraclePriceData
yarn run deploy OpenOraclePriceData
. Remember the address of the deployed contract - we'll need it in the next step. - Deploy DelFiPrice contract
yarn run deploy DelFiPrice "${OpenOraclePriceData address}" "0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC":array "0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC" "00"
. Remember the address of the deployed contract - we'll need it later.0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC
here is Coinbase Oracle public key. - Create Coinbase Pro API token
- Post prices on-chain:
- Open a separate terminal,
cd poster
- Assign the values from step #7 to environment variables:
export API_PASSPHRASE=${your passphrase} export API_KEY_ID=${your key id} export API_SECRET=${your secret}
yarn install
(ignore the typings errors if any)- Get deployed DelFiPrice contract from step #6 and a private key from the
ganache-cli
output yarn run start --view_address=${DelFiPrice address} --poster_key={ETH private key} --sources=https://api.pro.coinbase.com/oracle
- Open a separate terminal,
- Read on-chain prices:
- In the main terminal open saddle console
yarn run console
- Get ETH price
await delFiPrice.methods.medianPrice("ETH", ["0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC"]).call()
- Optionally repeat the posting step and check the updated price.
- In the main terminal open saddle console
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐