format project

This commit is contained in:
Ruidy 2022-04-11 06:08:46 -04:00
parent 705513d025
commit fc83b6f37a
14 changed files with 69 additions and 69 deletions

View file

@ -1,17 +1,16 @@
# Wave Portal # Wave Portal
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts. This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample
script that deploys that contract, and an example of a task implementation, which simply lists the available accounts.
## Screenshots ## Screenshots
[Frontend available](https://waveportal-starter-project.rjnemo.repl.co)
[Frontend available](https://waveportal-starter-project.rjnemo.repl.co)
[![screenshot](./docs/homepage.png)](https://waveportal-starter-project.rjnemo.repl.co) [![screenshot](./docs/homepage.png)](https://waveportal-starter-project.rjnemo.repl.co)
[![NFT](https://lh3.googleusercontent.com/JdpzIf6XyZuG48Ki2vTDP7FwH1ezrhaW4Dt5lT9AlaX9ntMkHTUjcriPWJG7CW1THcXHdN92JPktNwC9wBJVUUcHgOVAj6BKN8Fo5g=w600)](https://opensea.io/assets/matic/0x3cd266509d127d0eac42f4474f57d0526804b44e/16450) [![NFT](https://lh3.googleusercontent.com/JdpzIf6XyZuG48Ki2vTDP7FwH1ezrhaW4Dt5lT9AlaX9ntMkHTUjcriPWJG7CW1THcXHdN92JPktNwC9wBJVUUcHgOVAj6BKN8Fo5g=w600)](https://opensea.io/assets/matic/0x3cd266509d127d0eac42f4474f57d0526804b44e/16450)
Try running some of the following tasks: Try running some of the following tasks:
```shell ```shell

View file

@ -42,8 +42,9 @@ contract WavePortal {
console.log("%s won!", msg.sender); console.log("%s won!", msg.sender);
uint256 prizeAmount = 0.001 ether; uint256 prizeAmount = 0.001 ether;
require(prizeAmount <= address(this).balance); require(prizeAmount <= address(this).balance);
(bool success, ) = (msg.sender).call{value: prizeAmount}(""); (bool success,) = (msg.sender).call{value : prizeAmount}("");
require(success, "Failed to withdraw from the contract"); // mark the transaction as an error if it failed // mark the transaction as an error if it failed
require(success, "Failed to withdraw from the contract");
} }
emit NewWave(msg.sender, block.timestamp, _message); emit NewWave(msg.sender, block.timestamp, _message);

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -2,26 +2,26 @@ require("@nomiclabs/hardhat-waffle");
require("dotenv").config(); require("dotenv").config();
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners(); const accounts = await hre.ethers.getSigners();
for (const account of accounts) { for (const account of accounts) {
console.log(account.address); console.log(account.address);
} }
}); });
/** /**
* @type import('hardhat/config').HardhatUserConfig * @type import('hardhat/config').HardhatUserConfig
*/ */
module.exports = { module.exports = {
solidity: "0.8.4", solidity: "0.8.4",
networks: { networks: {
rinkeby: { rinkeby: {
url: STAGING_ALCHEMY_URL, url: process.env.STAGING_ALCHEMY_URL,
accounts: [PRIVATE_KEY], accounts: [process.env.PRIVATE_KEY],
},
mainnet: {
url: process.env.PROD_ALCHEMY_URL,
accounts: [process.env.PRIVATE_KEY],
},
}, },
mainnet: {
url: PROD_ALCHEMY_URL,
accounts: [PRIVATE_KEY],
},
},
}; };

View file

@ -1,24 +1,24 @@
const main = async () => { const main = async () => {
const [deployer] = await hre.ethers.getSigners(); const [deployer] = await hre.ethers.getSigners();
const accountBalance = await deployer.getBalance(); const accountBalance = await deployer.getBalance();
console.log(`Deploying contracts with address: ${deployer.address}`); console.log(`Deploying contracts with address: ${deployer.address}`);
console.log(`Account balance: ${accountBalance.toString()}`); console.log(`Account balance: ${accountBalance.toString()}`);
const Token = await hre.ethers.getContractFactory("WavePortal"); const Token = await hre.ethers.getContractFactory("WavePortal");
const portal = await Token.deploy({ value: hre.ethers.utils.parseEther("0.01") }); const portal = await Token.deploy({value: hre.ethers.utils.parseEther("0.01")});
await portal.deployed(); await portal.deployed();
console.log("WavePortal address: ", portal.address); console.log("WavePortal address: ", portal.address);
}; };
const runMain = async () => { const runMain = async () => {
try { try {
await main(); await main();
process.exit(0); process.exit(0);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
process.exit(1); process.exit(1);
} }
}; };
runMain(); runMain();

View file

@ -1,46 +1,46 @@
const main = async () => { const main = async () => {
const [owner, randomPerson] = await hre.ethers.getSigners(); const [owner, randomPerson] = await hre.ethers.getSigners();
const waveContractFactory = await hre.ethers.getContractFactory("WavePortal"); const waveContractFactory = await hre.ethers.getContractFactory("WavePortal");
const waveContract = await waveContractFactory.deploy({ const waveContract = await waveContractFactory.deploy({
value: hre.ethers.utils.parseEther("0.1"), value: hre.ethers.utils.parseEther("0.1"),
}); });
await waveContract.deployed(); await waveContract.deployed();
console.log(`Contract deployed to: ${waveContract.address}`); console.log(`Contract deployed to: ${waveContract.address}`);
console.log(`Contract deployed by: ${owner.address}`); console.log(`Contract deployed by: ${owner.address}`);
let contractBalance = await hre.ethers.provider.getBalance(waveContract.address); let contractBalance = await hre.ethers.provider.getBalance(waveContract.address);
console.log(`Contract balance: ${hre.ethers.utils.formatEther(contractBalance)}`); console.log(`Contract balance: ${hre.ethers.utils.formatEther(contractBalance)}`);
let waveCount; let waveCount;
waveCount = await waveContract.getTotalWaves(); waveCount = await waveContract.getTotalWaves();
let waveTxn = await waveContract.wave("A message"); let waveTxn = await waveContract.wave("A message");
await waveTxn.wait(); await waveTxn.wait();
waveTxn = await waveContract.wave("Hi!"); waveTxn = await waveContract.wave("Hi!");
await waveTxn.wait(); await waveTxn.wait();
waveCount = await waveContract.getTotalWaves(); waveCount = await waveContract.getTotalWaves();
waveTxn = await waveContract.connect(randomPerson).wave("another one"); waveTxn = await waveContract.connect(randomPerson).wave("another one");
await waveTxn.wait(); await waveTxn.wait();
contractBalance = await hre.ethers.provider.getBalance(waveContract.address); contractBalance = await hre.ethers.provider.getBalance(waveContract.address);
console.log(`Contract balance: ${hre.ethers.utils.formatEther(contractBalance)}`); console.log(`Contract balance: ${hre.ethers.utils.formatEther(contractBalance)}`);
let allWaves = await waveContract.getAllWaves(); let allWaves = await waveContract.getAllWaves();
console.log(allWaves); console.log(allWaves);
waveCount = await waveContract.getTotalWaves(); waveCount = await waveContract.getTotalWaves();
}; };
const runMain = async () => { const runMain = async () => {
try { try {
await main(); await main();
process.exit(0); process.exit(0);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
process.exit(1); process.exit(1);
} }
}; };
runMain(); runMain();