Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
@alexroan
alexroan / PriceConsumerV3.sol
Last active March 11, 2022 13:39
PriceConsumerV3
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.7;
import "https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract PriceConsumerV3 {
AggregatorV3Interface internal priceFeed;
@alexroan
alexroan / CoinGeckoConsumer.sol
Last active March 16, 2021 13:23
CoinGeckoConsumer.sol
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.0;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/ChainlinkClient.sol";
contract CoinGeckoConsumer is ChainlinkClient {
address private oracle;
bytes32 private jobId;
uint256 private fee;
@alexroan
alexroan / APIConsumer.sol
Last active March 11, 2022 03:38
APIConsumer.sol
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.0;
import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/ChainlinkClient.sol";
contract APIConsumer is ChainlinkClient {
uint256 public volume;
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity 0.6.6;
import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/VRFConsumerBase.sol";
contract RandomNumberConsumer is VRFConsumerBase {
bytes32 internal keyHash;
uint256 internal fee;
@alexroan
alexroan / HistoricalPriceConsumer.sol
Last active March 16, 2021 13:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.7+commit.b8d736ae.js&optimize=false&gist=
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.7;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorInterface.sol";
/**
* Consumer contract which retrieves the latest and historical
* price data from the ETH/USD price feed on the Ropsten network.
*/
@alexroan
alexroan / PriceConsumer.sol
Last active March 16, 2021 13:24
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.7+commit.b8d736ae.js&optimize=false&gist=
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.7;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/interfaces/AggregatorInterface.sol";
contract PriceConsumer {
AggregatorInterface internal priceFeed;
@alexroan
alexroan / Chainlink-PriceConsumer.sol
Last active March 23, 2022 22:18
Chainlink-PriceConsumer.sol
@alexroan
alexroan / aave_full_redeem.js
Last active July 10, 2020 11:28
aave_full_redeem.js
// Get reserve data
const reserveData = await lendingPool.methods.getReserveData("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE").call()
.catch((e) => {
throw Error(`Error getting aave reserve data: ${e.message}`)
});
// Get aToken address
const aTokenAddress = reserveData.aTokenAddress;
// Load aToken
const aTokenInstance = new web3.eth.Contract(aTokenABI, aTokenAddress);
// Redeem asset
@alexroan
alexroan / aave_redeem_atoken.js
Created July 10, 2020 11:10
aave_redeem_atoken.js
aTokenInstance.methods.redeem(withdrawAmount).send({from: account})
.once('transactionHash', (hash) => {
// transaction hash
})
.on('confirmation', (number, receipt) => {
// number of confirmations
})
.on('error', (error) => {
console.log(error);
});
@alexroan
alexroan / aave_load_atoken.js
Last active July 10, 2020 11:13
aave_load_atoken.js
const aTokenInstance = new web3.eth.Contract(aTokenABI, aTokenAddress);