From 4186de01c600b0a8fffecbab125c03dc031abe61 Mon Sep 17 00:00:00 2001 From: Parth Mandale <116056639+Parthmandale@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:51:56 +0530 Subject: [PATCH 1/4] Create solution-1.md Challenge 1 :- Added the twitter thread link. --- solution-1.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 solution-1.md diff --git a/solution-1.md b/solution-1.md new file mode 100644 index 00000000..6277dfe5 --- /dev/null +++ b/solution-1.md @@ -0,0 +1 @@ +https://twitter.com/ParthMandale/status/1639942433252204545?s=20 From f658abb6053d410575c8a8d28a428ea108dba285 Mon Sep 17 00:00:00 2001 From: Parth Mandale <116056639+Parthmandale@users.noreply.github.com> Date: Sat, 1 Apr 2023 01:26:54 +0530 Subject: [PATCH 2/4] Create solution-2.md --- solution-2.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 solution-2.md diff --git a/solution-2.md b/solution-2.md new file mode 100644 index 00000000..99da6f37 --- /dev/null +++ b/solution-2.md @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.9; + +import "@openzeppelin/contracts@4.8.2/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts@4.8.2/token/ERC20/extensions/ERC20Burnable.sol"; +import "@openzeppelin/contracts@4.8.2/access/Ownable.sol"; + +contract Parth is ERC20, ERC20Burnable, Ownable { + constructor() ERC20("Parth", "PVM") { + _mint(msg.sender, 100000 * 10 ** decimals()); + } + + function mint(address to, uint256 amount) public onlyOwner { + _mint(to, amount); + } +} From 662de1aef2d5ea76797ba73c30c76086dc11b474 Mon Sep 17 00:00:00 2001 From: Parth Mandale <116056639+Parthmandale@users.noreply.github.com> Date: Sat, 1 Apr 2023 03:50:13 +0530 Subject: [PATCH 3/4] Solution-2 --- solution2.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 solution2.md diff --git a/solution2.md b/solution2.md new file mode 100644 index 00000000..bcd21be8 --- /dev/null +++ b/solution2.md @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; + +import "@openzeppelin/contracts@4.8.2/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts@4.8.2/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts@4.8.2/access/Ownable.sol"; + +contract Parth is ERC20, ERC20Burnable, Ownable { constructor() ERC20("Parth", "PVM") { _mint(msg.sender, 100000 * 10 ** decimals()); } + +function mint(address to, uint256 amount) public onlyOwner { + _mint(to, amount); +} +} From a24f47425789513e80b34c93173f91a3d82f1877 Mon Sep 17 00:00:00 2001 From: Parth Mandale <116056639+Parthmandale@users.noreply.github.com> Date: Sat, 1 Apr 2023 04:06:38 +0530 Subject: [PATCH 4/4] Create solution-3.md --- solution-3.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solution-3.md diff --git a/solution-3.md b/solution-3.md new file mode 100644 index 00000000..1753302e --- /dev/null +++ b/solution-3.md @@ -0,0 +1,25 @@ +```js +const Web3 = require('web3'); +const tokenAbi = process.env.TOKEN_ABI; +const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); +const tokenAddress = ''; // Replace with the address of your token +const fromAddress = ''; // Replace with the address you want to mint tokens from +const privateKey = ''; // Replace with your private key +const token = new web3.eth.Contract(tokenAbi, tokenAddress); +async function mintToken(toAddress, amount) { + const nonce = await web3.eth.getTransactionCount(fromAddress); + const gasPrice = await web3.eth.getGasPrice(); + const txParams = { + nonce: nonce, + gasPrice: gasPrice, + gasLimit: 500000, + to: tokenAddress, + value: 0, + data: http://token.methods.mint(toAddress, amount).encodeABI() + }; + const signedTx = await web3.eth.accounts.signTransaction(txParams, privateKey); + const txReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); +} +mintToken('Address', 10); + +```