From 264332f8fc67484e612063c524f4fee68767a0db Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:56:38 -0400 Subject: [PATCH 1/5] add config for nova (Hardhat) --- smart_contract/.env.example | 7 ++++++- smart_contract/hardhat.config.ts | 25 +++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/smart_contract/.env.example b/smart_contract/.env.example index b1b8b54..0e1bd04 100644 --- a/smart_contract/.env.example +++ b/smart_contract/.env.example @@ -1,3 +1,7 @@ +# Subspace - Nova +RPC_URL_NOVA="https://subspace-nova.gemini-3g.subspace.network/ws" +PRIVATE_KEY_NOVA="" + # Subspace - Gemini RPC_URL_GEMINI="https://domain-3.evm.gemini-3f.subspace.network/ws" PRIVATE_KEY_GEMINI="" @@ -6,7 +10,8 @@ PRIVATE_KEY_GEMINI="" RPC_URL_GOERLI="https://goerli.infura.io/v3/" PRIVATE_KEY_GOERLI="" -# Blockscout - Gemini +# Blockscout - Nova&Gemini +NOVA_SCAN_API_KEY="" GEMINI_SCAN_API_KEY="" # Etherscan diff --git a/smart_contract/hardhat.config.ts b/smart_contract/hardhat.config.ts index a93a403..c83404e 100644 --- a/smart_contract/hardhat.config.ts +++ b/smart_contract/hardhat.config.ts @@ -1,12 +1,16 @@ -import { HardhatUserConfig } from 'hardhat/config' -import { NetworksUserConfig } from 'hardhat/types' import '@nomicfoundation/hardhat-toolbox' import 'dotenv/config' import 'hardhat-awesome-cli' +import { HardhatUserConfig } from 'hardhat/config' +import { NetworksUserConfig } from 'hardhat/types' let networks: NetworksUserConfig = {} const { + // Nova + RPC_URL_NOVA, + PRIVATE_KEY_NOVA, + NOVA_SCAN_API_KEY, // Gemini 3 RPC_URL_GEMINI, PRIVATE_KEY_GEMINI, @@ -17,6 +21,14 @@ const { ETHERSCAN_API_KEY, } = process.env +if (RPC_URL_NOVA && PRIVATE_KEY_NOVA) { + networks.nova = { + url: RPC_URL_NOVA, + chainId: 1002, + accounts: [PRIVATE_KEY_NOVA], + } +} + if (RPC_URL_GEMINI && PRIVATE_KEY_GEMINI) { networks.gemini = { url: RPC_URL_GEMINI, @@ -50,10 +62,19 @@ const config: HardhatUserConfig = { }, etherscan: { apiKey: { + nova: `${NOVA_SCAN_API_KEY}`, gemini: `${GEMINI_SCAN_API_KEY}`, goerli: `${ETHERSCAN_API_KEY}`, }, customChains: [ + { + network: 'nova', + chainId: 1002, + urls: { + apiURL: 'https://blockscout.subspace.network/api', + browserURL: 'https://blockscout.subspace.network/', + }, + }, { network: 'gemini', chainId: 1002, From 1e7413d992f44786e1dcdd1e51887ee4f7950bec Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:56:59 -0400 Subject: [PATCH 2/5] add deployment log --- smart_contract/contractsAddressDeployed.json | 14 +++++++++++++- .../contractsAddressDeployedHistory.json | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/smart_contract/contractsAddressDeployed.json b/smart_contract/contractsAddressDeployed.json index 0278734..cb11088 100644 --- a/smart_contract/contractsAddressDeployed.json +++ b/smart_contract/contractsAddressDeployed.json @@ -10,5 +10,17 @@ "blockNumber": 0, "tag": "Faucet deployed by deploy script", "extra": {} + }, + { + "name": "Faucet", + "address": "0x872f3534a525023F9E42Ad69b788B44fc958D5aa", + "network": "nova", + "deployer": "0xC89F6C6DF2f2e29AfFA81E19515CC08579a93980", + "deploymentDate": "Wed Nov 01 2023 20:52:48 GMT-0400 (Eastern Daylight Saving Time)", + "chainId": 1002, + "blockHash": "", + "blockNumber": 0, + "tag": "Faucet deployed by deploy script", + "extra": {} } -] \ No newline at end of file +] diff --git a/smart_contract/contractsAddressDeployedHistory.json b/smart_contract/contractsAddressDeployedHistory.json index 0278734..cb11088 100644 --- a/smart_contract/contractsAddressDeployedHistory.json +++ b/smart_contract/contractsAddressDeployedHistory.json @@ -10,5 +10,17 @@ "blockNumber": 0, "tag": "Faucet deployed by deploy script", "extra": {} + }, + { + "name": "Faucet", + "address": "0x872f3534a525023F9E42Ad69b788B44fc958D5aa", + "network": "nova", + "deployer": "0xC89F6C6DF2f2e29AfFA81E19515CC08579a93980", + "deploymentDate": "Wed Nov 01 2023 20:52:48 GMT-0400 (Eastern Daylight Saving Time)", + "chainId": 1002, + "blockHash": "", + "blockNumber": 0, + "tag": "Faucet deployed by deploy script", + "extra": {} } -] \ No newline at end of file +] From 1a8111a68ccc242ffc0fd3b4ff44c3acdc03687f Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:01:42 -0400 Subject: [PATCH 3/5] add helpful scripts --- smart_contract/scripts/addMinter.ts | 23 +++++++++++++ smart_contract/scripts/createWallet.ts | 14 ++++++++ smart_contract/scripts/faucetDetails.ts | 22 ++++++++++++ smart_contract/scripts/requestTokens.ts | 29 ++++++++++++++++ smart_contract/scripts/setup.ts | 45 +++++++++++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 smart_contract/scripts/addMinter.ts create mode 100644 smart_contract/scripts/createWallet.ts create mode 100644 smart_contract/scripts/faucetDetails.ts create mode 100644 smart_contract/scripts/requestTokens.ts create mode 100644 smart_contract/scripts/setup.ts diff --git a/smart_contract/scripts/addMinter.ts b/smart_contract/scripts/addMinter.ts new file mode 100644 index 0000000..9dbeafa --- /dev/null +++ b/smart_contract/scripts/addMinter.ts @@ -0,0 +1,23 @@ +import { addressBook, ethers, network } from 'hardhat' + +async function main() { + const [deployer] = await ethers.getSigners() + const deployerAddress = await deployer.getAddress() + + let faucetAddressIfDeployed: string | undefined = undefined + faucetAddressIfDeployed = addressBook.retrieveContract('Faucet', network.name) + if (network.name === 'localhost' || network.name === 'hardhat') + faucetAddressIfDeployed = '0x5FbDB2315678afecb367f032d93F642f64180aa3' + + const faucet = await ethers.getContractAt('Faucet', faucetAddressIfDeployed, deployer) + const addMinter = await faucet.addMinter(deployerAddress) + console.log('addMinter txHash', addMinter.hash) + + const receipt = await addMinter.wait() + console.log('receipt', receipt) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/smart_contract/scripts/createWallet.ts b/smart_contract/scripts/createWallet.ts new file mode 100644 index 0000000..3a773a4 --- /dev/null +++ b/smart_contract/scripts/createWallet.ts @@ -0,0 +1,14 @@ +import { ethers } from 'hardhat' + +async function main() { + const randomWallet = ethers.Wallet.createRandom() + + console.log('randomWallet.address', randomWallet.address) + console.log('randomWallet.privateKey', randomWallet.privateKey) + console.log('randomWallet.mnemonic', randomWallet.mnemonic) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/smart_contract/scripts/faucetDetails.ts b/smart_contract/scripts/faucetDetails.ts new file mode 100644 index 0000000..3b58d2f --- /dev/null +++ b/smart_contract/scripts/faucetDetails.ts @@ -0,0 +1,22 @@ +import { addressBook, ethers, network } from 'hardhat' + +async function main() { + const [deployer] = await ethers.getSigners() + + let faucetAddressIfDeployed: string | undefined = undefined + faucetAddressIfDeployed = addressBook.retrieveContract('Faucet', network.name) + if (network.name === 'localhost' || network.name === 'hardhat') + faucetAddressIfDeployed = '0x5FbDB2315678afecb367f032d93F642f64180aa3' + + const faucet = await ethers.getContractAt('Faucet', faucetAddressIfDeployed, deployer) + const lockTime = await faucet.lockTime() + console.log('lockTime', lockTime.toString()) + + const withdrawalAmount = await faucet.withdrawalAmount() + console.log('withdrawalAmount', withdrawalAmount.toString()) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/smart_contract/scripts/requestTokens.ts b/smart_contract/scripts/requestTokens.ts new file mode 100644 index 0000000..59426fc --- /dev/null +++ b/smart_contract/scripts/requestTokens.ts @@ -0,0 +1,29 @@ +import { addressBook, ethers, network } from 'hardhat' + +async function main() { + const [deployer] = await ethers.getSigners() + const deployerAddress = await deployer.getAddress() + const deployerBalance = await deployer.provider.getBalance(deployerAddress) + console.log('deployerBalance', deployerBalance) + + let faucetAddressIfDeployed: string | undefined = undefined + faucetAddressIfDeployed = addressBook.retrieveContract('Faucet', network.name) + if (network.name === 'localhost' || network.name === 'hardhat') + faucetAddressIfDeployed = '0x5FbDB2315678afecb367f032d93F642f64180aa3' + + const faucet = await ethers.getContractAt('Faucet', faucetAddressIfDeployed, deployer) + + const requestTokens = await faucet.requestTokens(deployerAddress) + console.log('requestTokens txHash', requestTokens.hash) + + const receipt = await requestTokens.wait() + console.log('receipt', receipt) + + const deployerBalanceFinal = await deployer.provider.getBalance(deployerAddress) + console.log('deployerBalance', deployerBalanceFinal) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/smart_contract/scripts/setup.ts b/smart_contract/scripts/setup.ts new file mode 100644 index 0000000..22f785f --- /dev/null +++ b/smart_contract/scripts/setup.ts @@ -0,0 +1,45 @@ +import { addressBook, ethers, network } from 'hardhat' + +const SECONDS_BETWEEN_REQUEST = 60 * 60 * 24 +const AMOUNT_BY_REQUEST = ethers.parseEther('0.2') + +async function main() { + const [deployer] = await ethers.getSigners() + const deployerAddress = await deployer.getAddress() + + let faucetAddressIfDeployed: string | undefined = undefined + faucetAddressIfDeployed = addressBook.retrieveContract('Faucet', network.name) + if (network.name === 'localhost' || network.name === 'hardhat') + faucetAddressIfDeployed = '0x5FbDB2315678afecb367f032d93F642f64180aa3' + + const faucet = await ethers.getContractAt('Faucet', faucetAddressIfDeployed, deployer) + + const lockTime = await faucet.lockTime() + console.log('lockTime', lockTime.toString()) + + const setLockTime = await faucet.setLockTime(SECONDS_BETWEEN_REQUEST) + console.log('setLockTime txHash', setLockTime.hash) + + const receipt = await setLockTime.wait() + console.log('receipt', receipt) + + const lockTimeFinal = await faucet.lockTime() + console.log('lockTimeFinal', lockTimeFinal.toString()) + + const withdrawalAmount = await faucet.withdrawalAmount() + console.log('withdrawalAmount', withdrawalAmount.toString()) + + const setWithdrawalAmount = await faucet.setWithdrawalAmount(AMOUNT_BY_REQUEST) + console.log('setWithdrawalAmount txHash', setWithdrawalAmount.hash) + + const receipt2 = await setWithdrawalAmount.wait() + console.log('receipt', receipt2) + + const withdrawalAmountFinal = await faucet.withdrawalAmount() + console.log('withdrawalAmountFinal', withdrawalAmountFinal.toString()) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) From 18c6d56797be021a7c6c075b8a2d0c69938e33d5 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:07:52 -0400 Subject: [PATCH 4/5] set webapp contract address --- web-app/src/constants/contracts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-app/src/constants/contracts.ts b/web-app/src/constants/contracts.ts index 929aaa6..b2b0926 100644 --- a/web-app/src/constants/contracts.ts +++ b/web-app/src/constants/contracts.ts @@ -72,7 +72,7 @@ export const contracts: Contract[] = [ { chainId: 1002, name: 'Faucet', - address: `0x74377fe8209015Bf6e58e52CC0fe2F1bDA8102B3`, + address: `0x872f3534a525023F9E42Ad69b788B44fc958D5aa`, abi: FAUCET } ] From 7961aaa61ae9e15cdbc4f49cedde9de45a1f243d Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:21:14 -0400 Subject: [PATCH 5/5] fix rpc in env.example --- smart_contract/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smart_contract/.env.example b/smart_contract/.env.example index 0e1bd04..2d8efb4 100644 --- a/smart_contract/.env.example +++ b/smart_contract/.env.example @@ -1,5 +1,5 @@ # Subspace - Nova -RPC_URL_NOVA="https://subspace-nova.gemini-3g.subspace.network/ws" +RPC_URL_NOVA="https://nova.gemini-3g.subspace.network/ws" PRIVATE_KEY_NOVA="" # Subspace - Gemini