Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1.08 KB

solution-3.md

File metadata and controls

33 lines (25 loc) · 1.08 KB

Transaction url:- https://explorer.public.zkevm-test.net/tx/0x1a4320963752ce0146e60a273effc2ad506313f0cca29be963e0f95f575c704c

const Web3 = require('web3');
const tokenAbi = process.env.TOKEN_ABI;

const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));

const tokenAddress = '0xf46acbbb848bbae9a0998a36afdd9395e7508f92'; 
const fromAddress = '0xDD408755826267Aeef80685133CDFE63e491160e'; 
const privateKey = 'YOUR_PRIVATE_KEY'; // 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', 100000);