Skip to content

Commit

Permalink
Ropsten setup
Browse files Browse the repository at this point in the history
  • Loading branch information
antico5 committed Aug 27, 2021
1 parent ffd4e06 commit da8ec6e
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 4 deletions.
2 changes: 2 additions & 0 deletions faucet/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALCHEMY_API_KEY=
ROPSTEN_PRIVATE_KEY=
9 changes: 9 additions & 0 deletions faucet/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { task } from "hardhat/config";
import "@nomiclabs/hardhat-waffle";

import dotenv from 'dotenv'
dotenv.config()

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (args, hre) => {
Expand All @@ -16,4 +19,10 @@ task("accounts", "Prints the list of accounts", async (args, hre) => {

export default {
solidity: "0.8.7",
networks: {
ropsten: {
url: `https://eth-ropsten.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
accounts: [`0x${process.env.ROPSTEN_PRIVATE_KEY}`],
},
},
};
16 changes: 16 additions & 0 deletions faucet/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions faucet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@types/mocha": "^9.0.0",
"@types/node": "^16.7.1",
"chai": "^4.3.4",
"dotenv": "^10.0.0",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.4.5",
"hardhat": "^2.6.1",
Expand Down
12 changes: 8 additions & 4 deletions faucet/scripts/faucet_deploy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const hre = require("hardhat");

async function main() {
const faucetFactory = await hre.ethers.getContractFactory("Faucet");
const faucetContract = await faucetFactory.deploy();
const [deployer] = await ethers.getSigners();

await faucetContract.deployed();
console.log("Deploying contracts with the account:", deployer.address);

console.log("Contract deployed to:", faucetContract.address);
console.log("Account balance:", (await deployer.getBalance()).toString());

const Faucet = await ethers.getContractFactory("Faucet");
const faucet = await Faucet.deploy();

console.log("Faucet address:", faucet.address);
}

main()
Expand Down
22 changes: 22 additions & 0 deletions faucet/scripts/faucet_deposit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { TransactionResponse } from '@ethersproject/abstract-provider';
import { providers, Signer } from 'ethers';
import {ethers} from 'hardhat'

const contractAddress = '0x252ccddA5cb868f5fB69120985b332c11dB15bE7';

async function main() {
const [account] = await ethers.getSigners();

const tx = await account.sendTransaction({to: contractAddress, value: ethers.utils.parseEther('0.01')})
console.log('Transaction sent')

const receipt = await tx.wait() as any
console.log('Transaction confirmed')
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
23 changes: 23 additions & 0 deletions faucet/scripts/faucet_withdraw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TransactionResponse } from '@ethersproject/abstract-provider';
import { providers, Signer } from 'ethers';
import {ethers} from 'hardhat'

const contractAddress = '0x252ccddA5cb868f5fB69120985b332c11dB15bE7';

async function main() {
const factory = await ethers.getContractFactory('Faucet')
const contract = factory.attach(contractAddress)

const tx = await contract.withdraw(ethers.utils.parseEther('0.01')) as TransactionResponse
console.log('Transaction sent')

const receipt = await tx.wait() as any
console.log('Transaction confirmed')
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit da8ec6e

Please sign in to comment.