Skip to content

Commit

Permalink
Update demo hardhat configs to use env variable for eth endpoint (#277)
Browse files Browse the repository at this point in the history
* Use an env variable for eth RPC endpoint in hardhat config

* Add a task to get main account address in erc20 watcher
  • Loading branch information
prathamesh0 authored Dec 21, 2022
1 parent 9566dff commit a834250
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/erc20-watcher/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './test/tasks/token-transfer';
import './test/tasks/token-approve';
import './test/tasks/token-transfer-from';
import './test/tasks/block-latest';
import './test/tasks/account';

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
Expand All @@ -20,7 +21,7 @@ export default {
solidity: '0.8.0',
networks: {
docker: {
url: 'http://geth:8545'
url: process.env.ETH_RPC_URL
}
},
paths: {
Expand Down
2 changes: 2 additions & 0 deletions packages/erc20-watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"token:transfer-from:docker": "hardhat --network docker token-transfer-from",
"block:latest": "hardhat --network localhost block-latest",
"block:latest:docker": "hardhat --network docker block-latest",
"account": "hardhat --network localhost account",
"account:docker": "hardhat --network docker account",
"reset": "DEBUG=vulcanize:* node --enable-source-maps dist/cli/reset.js",
"reset:dev": "DEBUG=vulcanize:* ts-node src/cli/reset.ts"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/erc20-watcher/test/tasks/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Copyright 2022 Vulcanize, Inc.
//

import { task } from 'hardhat/config';
import '@nomiclabs/hardhat-ethers';

task('account', 'Prints the account', async (taskArgs, hre) => {
const [account] = await hre.ethers.getSigners();

console.log(account.address);
});
2 changes: 1 addition & 1 deletion packages/erc721-watcher/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
solidity: '0.8.0',
networks: {
docker: {
url: 'http://geth:8545'
url: process.env.ETH_RPC_URL
}
},
paths: {
Expand Down
3 changes: 2 additions & 1 deletion packages/erc721-watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"nft:transfer:docker": "hardhat --network docker nft-transfer",
"block:latest": "hardhat --network localhost block-latest",
"block:latest:docker": "hardhat --network docker block-latest",
"account": "hardhat --network localhost account"
"account": "hardhat --network localhost account",
"account:docker": "hardhat --network docker account"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit a834250

Please sign in to comment.