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 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); + } +} 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); + +``` 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); +} +}