This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.6.0; | |
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/ChainlinkClient.sol"; | |
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/vendor/Ownable.sol"; | |
contract ExampleOracleClient is ChainlinkClient, Ownable { | |
address constant private ORACLE = 0x83dA1beEb89Ffaf56d0B7C50aFB0A66Fb4DF8cB1; | |
string constant private JOB_ID = "93547cb3c6784ec08a366be6211caa24"; | |
uint256 constant private ORACLE_PAYMENT = 1 * LINK / 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Contracts | |
const Exchange = artifacts.require("Exchange") | |
// Utils | |
const ether = (n) => { | |
return new web3.utils.BN( | |
web3.utils.toWei(n.toString(), 'ether') | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function(callback) { | |
console.log("IT WORKS"); | |
callback(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Exchange { | |
//fill an order | |
function fillOrder(uint256 _id) public { | |
//... | |
} | |
//make order | |
function makeOrder(address _tokenGet, uint256 _amountGet, address _tokenGive, uint256 _amountGive) public { | |
//... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function(callback) { | |
// do some stuff | |
callback(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cEthInstance.methods.redeemUnderlying(redeemAmount).send({from: account}) | |
.once('transactionHash', (hash) => { | |
// Transaction Hash | |
}) | |
.on('confirmation', (number, receipt) => { | |
// Number of confirmations | |
}) | |
.on('error', (error) => { | |
console.log(error); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cEthInstance.methods.mint().send({from: account, value: supplyValue}) | |
.once('transactionHash', (hash) => { | |
// Transaction hash | |
}) | |
.on('confirmation', (number, receipt) => { | |
// Number of confirmations | |
}) | |
.on('error', (error) => { | |
console.log(error); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.6.2; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@openzeppelin/contracts/utils/EnumerableSet.sol"; | |
import "@openzeppelin/contracts/utils/Address.sol"; | |
import "@openzeppelin/contracts/math/SafeMath.sol"; | |
import "./RandomNumberGenerator.sol"; | |
contract Lottery is Ownable{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawNumber(uint256 _seed) public onlyOwner isState(LotteryState.Open) { | |
_changeState(LotteryState.Closed); | |
randomNumberRequestId = RandomNumberGenerator(randomNumberGenerator).request(_seed); | |
emit NumberRequested(randomNumberRequestId); | |
} | |
function numberDrawn(bytes32 _randomNumberRequestId, uint _randomNumber) public onlyRandomGenerator isState(LotteryState.Closed) { | |
if (_randomNumberRequestId == randomNumberRequestId) { | |
winningNumber = _randomNumber; | |
emit NumberDrawn(_randomNumberRequestId, _randomNumber); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.2; | |
import "./VRFConsumerBase.sol"; | |
import "./Lottery.sol"; | |
contract RandomNumberGenerator is VRFConsumerBase { | |
address requester; | |
bytes32 keyHash; | |
uint256 fee; |