Skip to content
Open
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
1,767 changes: 1,207 additions & 560 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "local-hardhat-games",
"version": "1.0.0",
"description": "",
"description": "Let's work on our solidity skills while deploying against a local hardhat blockchain! Inside this repository you'll find 5 smart contracts labled `Game1` to `Game5`. The goal of each smart contract is to:",
"main": "index.js",
"author": "",
"license": "ISC",
"dependencies": {
"hardhat": "^2.12.4"
},
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^2.0.0"
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"hardhat": "^2.17.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
File renamed without changes.
16 changes: 16 additions & 0 deletions scripts/deploy_2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// replace the name of the contract with which one you want to deploy!
const contractName = "Game2";

async function main() {
const Game = await hre.ethers.getContractFactory(contractName);
// if you need to add constructor arguments for the particular game, add them here:
const game = await Game.deploy();
console.log(`${contractName} deployed to address: ${game.address}`);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
16 changes: 16 additions & 0 deletions scripts/deploy_3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// replace the name of the contract with which one you want to deploy!
const contractName = "Game3";

async function main() {
const Game = await hre.ethers.getContractFactory(contractName);
// if you need to add constructor arguments for the particular game, add them here:
const game = await Game.deploy();
console.log(`${contractName} deployed to address: ${game.address}`);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
16 changes: 16 additions & 0 deletions scripts/deploy_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// replace the name of the contract with which one you want to deploy!
const contractName = "Game4";

async function main() {
const Game = await hre.ethers.getContractFactory(contractName);
// if you need to add constructor arguments for the particular game, add them here:
const game = await Game.deploy();
console.log(`${contractName} deployed to address: ${game.address}`);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
16 changes: 16 additions & 0 deletions scripts/deploy_5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// replace the name of the contract with which one you want to deploy!
const contractName = "Game5";

async function main() {
const Game = await hre.ethers.getContractFactory(contractName);
// if you need to add constructor arguments for the particular game, add them here:
const game = await Game.deploy();
console.log(`${contractName} deployed to address: ${game.address}`);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
7 changes: 3 additions & 4 deletions scripts/win.js → scripts/win_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ async function main() {
// attach to the game
const game = await hre.ethers.getContractAt(contractName, gameAddr);

// do whatever you need to do to win the game here:
const tx = await game.win();

//do whatever you need to do to win the game here:
const tx1 = await game.win();
// did you win? Check the transaction receipt!
// if you did, it will be in both the logs and events array
const receipt = await tx.wait();
const receipt = await tx1.wait();
console.log(receipt);
}

Expand Down
26 changes: 26 additions & 0 deletions scripts/win_2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// add the game address here and update the contract name if necessary
const gameAddr = "";
const contractName = "Game2";

async function main() {
// attach to the game
const game = await hre.ethers.getContractAt(contractName, gameAddr);

//do whatever you need to do to win the game here:
const tx1 = await game.setX(25);
await tx1.wait();
const tx2 = await game.setY(25);
await tx2.wait();
const tx3 = await game.win();
// did you win? Check the transaction receipt!
// if you did, it will be in both the logs and events array
const receipt = await tx3.wait();
console.log(receipt);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
22 changes: 22 additions & 0 deletions scripts/win_3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// add the game address here and update the contract name if necessary
const gameAddr = "";
const contractName = "Game3";

async function main() {
// attach to the game
const game = await hre.ethers.getContractAt(contractName, gameAddr);

//do whatever you need to do to win the game here:
const tx1 = await game.win(45);
// did you win? Check the transaction receipt!
// if you did, it will be in both the logs and events array
const receipt = await tx1.wait();
console.log(receipt);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
22 changes: 22 additions & 0 deletions scripts/win_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// add the game address here and update the contract name if necessary
const gameAddr = "";
const contractName = "Game4";

async function main() {
// attach to the game
const game = await hre.ethers.getContractAt(contractName, gameAddr);

//do whatever you need to do to win the game here:
const tx1 = await game.win(56);
// did you win? Check the transaction receipt!
// if you did, it will be in both the logs and events array
const receipt = await tx1.wait();
console.log(receipt);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
26 changes: 26 additions & 0 deletions scripts/win_5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// add the game address here and update the contract name if necessary
const gameAddr = "";
const contractName = "Game5";

async function main() {
// attach to the game
const game = await hre.ethers.getContractAt(contractName, gameAddr);

//do whatever you need to do to win the game here:
const tx1 = await game.giveMeAllowance(20000);
await tx1.wait();
const tx2 = await game.mint(15000);
await tx2.wait();
const tx3 = await game.win();
// did you win? Check the transaction receipt!
// if you did, it will be in both the logs and events array
const receipt = await tx3.wait();
console.log(receipt);
}

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