From 3ce17b1504efa7913745e1a12f50d24b123df2c4 Mon Sep 17 00:00:00 2001 From: Dhruvit Salat Date: Sun, 5 Feb 2023 01:24:53 +0530 Subject: [PATCH] feat: script to deploy nodes to blockchain --- web3/scripts/deploy.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 web3/scripts/deploy.ts diff --git a/web3/scripts/deploy.ts b/web3/scripts/deploy.ts new file mode 100644 index 0000000..d8999ee --- /dev/null +++ b/web3/scripts/deploy.ts @@ -0,0 +1,27 @@ +import { ethers } from 'hardhat'; +import console from 'console'; + +const _metadataUri = 'https://gateway.pinata.cloud/ipfs/https://gateway.pinata.cloud/ipfs/QmX2ubhtBPtYw75Wrpv6HLb1fhbJqxrnbhDo1RViW3oVoi'; + +async function deploy(name: string, ...params: [string]) { + const contractFactory = await ethers.getContractFactory(name); + + return await contractFactory.deploy(...params).then((f) => f.deployed()); +} + +async function main() { + const [admin] = await ethers.getSigners(); + + console.log(`Deploying a smart contract...`); + + const PokeMon = (await deploy('PokeMon', _metadataUri)).connect(admin); + + console.log({ PokeMon: PokeMon.address }); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }); \ No newline at end of file