diff --git a/packages/hardhat/scripts/contractAddresses.json b/packages/hardhat/scripts/contractAddresses.json new file mode 100644 index 0000000..8420241 --- /dev/null +++ b/packages/hardhat/scripts/contractAddresses.json @@ -0,0 +1,6 @@ +{ + "FootballGame": "0x940540782303c7380b28D0781d076ad05d1cB6eA", + "FootballCoin": "0xc314278217Ae8D99D95BdAb3432e174A1a483Ed1", + "ChallengerAddress" : "0xbb1DF1ab33786Ac6B91d9D16b445c7b66825979e", + "OpponentAddress" : "0x0534eaF0FdCE77771b7988F8501AEac47f53f011" +} diff --git a/packages/hardhat/scripts/gameFlow.js b/packages/hardhat/scripts/gameFlow.js index 9bc459a..9cf9508 100644 --- a/packages/hardhat/scripts/gameFlow.js +++ b/packages/hardhat/scripts/gameFlow.js @@ -1,10 +1,15 @@ const { ethers } = require("hardhat"); +const fs = require('fs'); async function main() { - const footballGameAddress = "0x940540782303c7380b28D0781d076ad05d1cB6eA"; - const footballCoinAddress = "0xc314278217Ae8D99D95BdAb3432e174A1a483Ed1"; // Address of deployed FootballCoin contract - const challengerAddress = "0xbb1DF1ab33786Ac6B91d9D16b445c7b66825979e"; - const opponentAddress = "0x0534eaF0FdCE77771b7988F8501AEac47f53f011"; + + const rawdata = fs.readFileSync('/home/arjanjohan/git/hack/taipei24/scaffold-eth-2/packages/hardhat/scripts/contractAddresses.json'); + const addresses = JSON.parse(rawdata); + + const footballGameAddress = addresses.FootballGame; + const footballCoinAddress = addresses.FootballCoin; + const challengerAddress = addresses.ChallengerAddress; + const opponentAddress = addresses.OpponentAddress; const wagerAmount = "1000000000000000000"; // 1 token in Wei const defaultFormation = [1, 4, 5, 6, 7 , 8 ,9 ,10, 11, 12 ,13] @@ -29,6 +34,7 @@ async function main() { console.log("gm"); await proposeTx.wait(); + console.log("Game proposed"); // Assume game ID is 1 for this example. Retrieve actual game ID from the event log in a real scenario. const gameId = await footballGame.getGameCount(); console.log(`Game ID: ${gameId}`); diff --git a/packages/hardhat/scripts/interactWithFootballCoin.js b/packages/hardhat/scripts/interactWithFootballCoin.js index af694b0..1a83046 100644 --- a/packages/hardhat/scripts/interactWithFootballCoin.js +++ b/packages/hardhat/scripts/interactWithFootballCoin.js @@ -1,13 +1,18 @@ // interactWithFootballCoin.js +const fs = require('fs'); const { ethers } = require("hardhat"); // npx hardhat run scripts/interactWithFootballCoin.js --network ten async function main() { // Replace the following addresses with the actual addresses - const footballCoinAddress = "0xc314278217Ae8D99D95BdAb3432e174A1a483Ed1"; // Address of deployed FootballCoin contract - const accountToMintTo = "0x0534eaF0FdCE77771b7988F8501AEac47f53f011"; // Address to which you want to mint FootballCoin tokens - const spenderAddress = "0x44CbD15D584f2D7865232123146e8e20404c6952"; // Address allowed to spend the tokens (another contract or wallet) + + const rawdata = fs.readFileSync('/home/arjanjohan/git/hack/taipei24/scaffold-eth-2/packages/hardhat/scripts/contractAddresses.json'); + const addresses = JSON.parse(rawdata); + + const footballCoinAddress = addresses.FootballCoin; + const accountToMintTo = addresses.ChallengerAddress; // Address to which you want to mint FootballCoin tokens + const spenderAddress = addresses.FootballGame; // Address allowed to spend the tokens (another contract or wallet) const mintAmount = "1000000000000000000000"; // Amount to mint, e.g., 1000 FBC const allowanceAmount = "1000000000000000000000"; // Allowance amount, e.g., 500 FBC diff --git a/packages/hardhat/scripts/loadPlayers.js b/packages/hardhat/scripts/loadPlayers.js index 0dae6b8..0826d20 100644 --- a/packages/hardhat/scripts/loadPlayers.js +++ b/packages/hardhat/scripts/loadPlayers.js @@ -1,10 +1,15 @@ const { ethers } = require("hardhat"); +const fs = require('fs'); async function main() { const [deployer] = await ethers.getSigners(); console.log("Interacting with the smart contract using the account:", deployer.address); - const contractAddress = "0x940540782303c7380b28D0781d076ad05d1cB6eA"; + + const rawdata = fs.readFileSync('/home/arjanjohan/git/hack/taipei24/scaffold-eth-2/packages/hardhat/scripts/contractAddresses.json'); + const addresses = JSON.parse(rawdata); + + const contractAddress = addresses.FootballGame; const contractArtifact = await hre.artifacts.readArtifact("FootballGame"); const contract = new ethers.Contract(contractAddress, contractArtifact.abi, deployer);