Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error pr #14

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/challenge_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Challenge request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your challenge request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the challenge you'd like**
A clear and concise description of what you want to happen.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ build
.yarn/cache
.yarn/install-state.gz
.yarn/build-state.yml
yarn.lock
.eslintcache
# testing
coverage
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,29 @@ Prerequisites: [Node](https://nodejs.org/en/download/) plus [Yarn](https://class
> clone/fork 🏗 scaffold-eth:

```bash
git clone https://github.com/austintgriffith/scaffold-eth.git
git clone https://github.com/scaffold-eth/scaffold-eth-challenges.git challenge-4-oracle
```

> install and start your 👷‍ Hardhat chain:

```bash
cd scaffold-eth
cd challenge-4-oracle
git checkout challenge-4-oracle
yarn install
yarn chain
```

> in a second terminal window, start your 📱 frontend:

```bash
cd scaffold-eth
cd challenge-4-oracle
yarn start
```

> in a third terminal window, 🛰 deploy your contract:

```bash
cd scaffold-eth
cd challenge-4-oracle
yarn deploy
```

Expand Down
33 changes: 33 additions & 0 deletions packages/hardhat/contracts/EthPriceFeed.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract PriceConsumerV3 {

AggregatorV3Interface internal priceFeed;

/**
* Network: Kovan
* Aggregator: ETH/USD
* Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
*/
constructor() {
priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
}

/**
* Returns the latest price
*/
function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();

return price;
}
}
70 changes: 38 additions & 32 deletions packages/hardhat/deploy/00_deploy_your_contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,61 @@ module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
const chainId = await getChainId();

await deploy("YourContract", {
// Learn more about args here: https://www.npmjs.com/package/hardhat-deploy#deploymentsdeploy
from: deployer,
// args: [ "Hello", ethers.utils.parseEther("1.5") ],
log: true,
});

// Uncomment to deploy your price feed on kovan
// await deploy("EthPriceFeed", {
// from: deployer,
// log: true,
// });

// Getting a previously deployed contract
const YourContract = await ethers.getContract("YourContract", deployer);
/* await YourContract.setPurpose("Hello");

To take ownership of yourContract using the ownable library uncomment next line and add the
address you want to be the owner.
// yourContract.transferOwnership(YOUR_ADDRESS_HERE);
// const EthPriceFeedContract = await ethers.getContract(
// "EthPriceFeed",
// deployer
// );

//const yourContract = await ethers.getContractAt('YourContract', "0xaAC799eC2d00C013f1F11c37E654e59B0429DF6A") //<-- if you want to instantiate a version of a contract at a specific address!
*/
// await YourContract.setPurpose("Hello");

/*
//If you want to send value to an address from the deployer
const deployerWallet = ethers.provider.getSigner()
await deployerWallet.sendTransaction({
to: "0x34aA3F359A9D614239015126635CE7732c18fDF3",
value: ethers.utils.parseEther("0.001")
})
*/
// To take ownership of yourContract using the ownable library uncomment next line and add the
// address you want to be the owner.
// yourContract.transferOwnership(YOUR_ADDRESS_HERE);

/*
//If you want to send some ETH to a contract on deploy (make your constructor payable!)
const yourContract = await deploy("YourContract", [], {
value: ethers.utils.parseEther("0.05")
});
*/
// if you want to instantiate a version of a contract at a specific address!
// const yourContract = await ethers.getContractAt('YourContract', "0xaAC799eC2d00C013f1F11c37E654e59B0429DF6A");

/*
//If you want to link a library into your contract:
// reference: https://github.com/austintgriffith/scaffold-eth/blob/using-libraries-example/packages/hardhat/scripts/deploy.js#L19
const yourContract = await deploy("YourContract", [], {}, {
LibraryName: **LibraryAddress**
});
*/
// If you want to send value to an address from the deployer
// const deployerWallet = ethers.provider.getSigner()
// await deployerWallet.sendTransaction({
// to: "0x34aA3F359A9D614239015126635CE7732c18fDF3",
// value: ethers.utils.parseEther("0.001")
// })

// If you want to send some ETH to a contract on deploy (make your constructor payable!);
// const yourContract = await deploy("YourContract", [], {
// value: ethers.utils.parseEther("0.05")
// });

// If you want to link a library into your contract:
// const yourContract = await deploy("YourContract", [], {}, {
// LibraryName: **LibraryAddress**
// });

// Verify your contracts with Etherscan
// You don't want to verify on localhost
if (chainId !== localChainId) {
await run("verify:verify", {
run("verify:verify", {
address: YourContract.address,
contract: "contracts/YourContract.sol:YourContract",
contractArguments: [],
});

// Add verification for your price feed contract here
// ...
}
};
module.exports.tags = ["YourContract"];

module.exports.tags = ["YourContract", "EthPriceFeed"];
23 changes: 15 additions & 8 deletions packages/hardhat/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,36 @@
# Infura endpoints should be passed in WITHOUT the rest of the url
# Private keys should be pasted WITHOUT the 0x prefix

# Moralis Key(s)
MORALIS_SERVER=
MORALIS_SECRET=

# Example
EXAMPLE_INFURA_KEY=582dabbadbeef8...
EXAMPLE_DEPLOYER_PRIV_KEY=deadbeef01EEdf972aBB...
EXAMPLE_INFURA_KEY=7b0e75d38d424750b92791477924d133
EXAMPLE_DEPLOYER_PRIV_KEY=deadbeef01EEdf972aBB ...

# Rinkeby
RINKEBY_INFURA_KEY=
RINKEBY_INFURA_KEY=7b0e75d38d424750b92791477924d133
RINKEBY_DEPLOYER_PRIV_KEY=

# Kovan
KOVAN_INFURA_KEY=
KOVAN_INFURA_KEY=7b0e75d38d424750b92791477924d133
KOVAN_DEPLOYER_PRIV_KEY=

# mainnet
MAINNET_INFURA_KEY=
MAINNET_INFURA_KEY=7b0e75d38d424750b92791477924d133
MAINNET_DEPLOYER_PRIV_KEY=

# Ropsten
ROPSTEN_INFURA_KEY=
ROPSTEN_INFURA_KEY=7b0e75d38d424750b92791477924d133
ROPSTEN_DEPLOYER_PRIV_KEY=

# Goerli
GOERLI_INFURA_KEY=
GOERLI_INFURA_KEY=7b0e75d38d424750b92791477924d133
GOERLI_DEPLOYER_PRIV_KEY=

# xDai
XDAI_DEPLOYER_PRIV_KEY=
XDAI_DEPLOYER_PRIV_KEY=

# CoinMarketCap
COINMARKETCAP=
79 changes: 14 additions & 65 deletions packages/hardhat/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,10 @@ require("@nomiclabs/hardhat-etherscan");

const { isAddress, getAddress, formatUnits, parseUnits } = utils;

/*
📡 This is where you configure your deploy configuration for 🏗 scaffold-eth

check out `packages/scripts/deploy.js` to customize your deployment

out of the box it will auto deploy anything in the `contracts` folder and named *.sol
plus it will use *.args for constructor args
*/

//
// Select the network you want to deploy to here:
//
const defaultNetwork = "localhost";
const defaultNetwork = "kovan";

const mainnetGwei = 21;
const mainnetGwei = 115;

function mnemonic() {
try {
Expand Down Expand Up @@ -67,81 +56,41 @@ module.exports = {
networks: {
localhost: {
url: "http://localhost:8545",
/*
notice no mnemonic here? it will just use account 0 of the hardhat node to deploy
(you can put in a mnemonic here to set the deployer locally)

*/
// notice no mnemonic here? it will just use account 0 of the hardhat node to deploy
// (you can put in a mnemonic here to set the deployer locally)
},

// rinkeby: {
// url: `https://rinkeby.infura.io/v3/${process.env.RINKEBY_INFURA_KEY}`,
// accounts: [`${process.env.RINKEBY_DEPLOYER_PRIV_KEY}`],
// },
// kovan: {
// url: `https://rinkeby.infura.io/v3/${process.env.KOVAN_INFURA_KEY}`,
// accounts: [`${process.env.KOVAN_DEPLOYER_PRIV_KEY}`],
// },
// mainnet: {
// url: `https://mainnet.infura.io/v3/${process.env.MAINNET_INFURA_KEY}`,
// accounts: [`${process.env.MAINNET_DEPLOYER_PRIV_KEY}`],
// },
// ropsten: {
// url: `https://ropsten.infura.io/v3/${process.env.ROPSTEN_INFURA_KEY}`,
// accounts: [`${process.env.ROPSTEN_DEPLOYER_PRIV_KEY}`],
// },
// goerli: {
// url: `https://goerli.infura.io/v3/${process.env.GOERLI_INFURA_KEY}`,
// accounts: [`${process.env.GOERLI_DEPLOYER_PRIV_KEY}`],
// },
// xdai: {
// url: 'https://dai.poa.network',
// gasPrice: 1000000000,
// accounts: [`${process.env.XDAI_DEPLOYER_PRIV_KEY}`],
// },

rinkeby: {
url: "https://rinkeby.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)

url: "https://rinkeby.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXX", // <---- YOUR INFURA ID! (or it won't work)
// url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/eth/rinkeby", // <---- YOUR MORALIS ID! (not limited to infura)

accounts: {
mnemonic: mnemonic(),
},
},
kovan: {
url: "https://kovan.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)

url: "https://kovan.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXX", // <---- YOUR INFURA ID! (or it won't work)
// url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/eth/kovan", // <---- YOUR MORALIS ID! (not limited to infura)

accounts: {
mnemonic: mnemonic(),
},
},
mainnet: {
url: "https://mainnet.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)

url: "https://mainnet.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXX", // <---- YOUR INFURA ID! (or it won't work)
// url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXXXX/eth/mainnet", // <---- YOUR MORALIS ID! (not limited to infura)

gasPrice: mainnetGwei * 1000000000,
accounts: {
mnemonic: mnemonic(),
},
},
ropsten: {
url: "https://ropsten.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)

url: "https://ropsten.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXX", // <---- YOUR INFURA ID! (or it won't work)
// url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXXXX/eth/ropsten",// <---- YOUR MORALIS ID! (not limited to infura)

accounts: {
mnemonic: mnemonic(),
},
},
goerli: {
url: "https://goerli.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)

url: "https://goerli.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXX", // <---- YOUR INFURA ID! (or it won't work)
// url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXXXX/eth/goerli", // <---- YOUR MORALIS ID! (not limited to infura)

accounts: {
mnemonic: mnemonic(),
},
Expand All @@ -160,14 +109,13 @@ module.exports = {
mnemonic: mnemonic(),
},
},
polytest: {
mumbai: {
url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/polygon/mumbai", // <---- YOUR MORALIS ID! (not limited to infura)
gasPrice: 1000000000,
accounts: {
mnemonic: mnemonic(),
},
},

matic: {
url: "https://rpc-mainnet.maticvigil.com/",
gasPrice: 1000000000,
Expand Down Expand Up @@ -277,6 +225,7 @@ module.exports = {
},
},
solidity: {
// Add compilers here vvvv
compilers: [
{
version: "0.8.4",
Expand All @@ -299,19 +248,19 @@ module.exports = {
],
},
ovm: {
solcVersion: "0.7.6",
solcVersion: "0.8.4",
},
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
default: 0, // this will by default take the first account as deployer
},
},
etherscan: {
apiKey: "DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW",
},
};

const DEBUG = false;
const DEBUG = true;

function debug(text) {
if (DEBUG) {
Expand Down
Loading