Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygonzkhacker_zkThon #384

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions solution-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://twitter.com/PolygonZkHacker/status/1641920964530171905
19 changes: 19 additions & 0 deletions solution-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Transaction Hash - 0x0373d3122dfe8e16ea49e7897f8ebf681c290187e7ff9a2ef44b647a83fe3eee

Contract Address - 0xd15320ad97965c99bc5027d9ed19975a95c3ed67

sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract OurToken is ERC20, ERC20Burnable, Ownable{

constructor() ERC20("PolygonZkHacker", "PZH"){
_mint(msg.sender, 1000000 * 10 ** decimals());//whoever deployes the contract will own all the tokens
}
function mint(address to, uint256 amount) public onlyOwner{
_mint(to, amount);
}
}
36 changes: 36 additions & 0 deletions solution-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Transaction Hash - 0x8d7e945f39039e2ad23d1267f4de1a5ad4cd8e9cc175ffed44b5c0b50919ae54

Contract Address - 0xd15320ad97965c99bc5027d9ed19975a95c3ed67

Transaction URL - https://explorer.public.zkevm-test.net/tx/0x8d7e945f39039e2ad23d1267f4de1a5ad4cd8e9cc175ffed44b5c0b50919ae54

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: 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);