From 7e63bf12e238f9f1f2c39a725e1f52e54b70dbbe Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Sun, 1 May 2022 14:02:06 -0400 Subject: [PATCH] Mint multiple with payable --- mint-nft.js | 28 ++++++++++++++++++++++++++-- send-tx.js | 8 +++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/mint-nft.js b/mint-nft.js index ea91b81..3b2194a 100644 --- a/mint-nft.js +++ b/mint-nft.js @@ -10,7 +10,7 @@ const web3 = createAlchemyWeb3(API_URL); import contractABI from './MoonbirdPunks.json' assert { type: 'json' } // console.log(JSON.stringify(contract.abi)); -const contractAddress = "0x7d82a88Efb60Bb83B3f1665757c20D07E5C0f3ED"; +const contractAddress = "0x90Bc839511e1a8b32e2ba27f37c7632D12E872B6"; const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress); async function mintOwnerNFT() { @@ -35,6 +35,29 @@ async function mintOwnerNFT() { console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`); } +async function mintPunk() { + const nonce = await web3.eth.getTransactionCount(process.env.PUBLIC_KEY, 'latest'); //get latest nonce + + //the transaction + const tx = { + 'from': process.env.PUBLIC_KEY, + 'to': contractAddress, + 'value': .001 * Math.pow(10, 18) * 2, + 'nonce': nonce, + 'gas': 150000, + 'maxFeePerGasGwei': 40, + // 'maxPriorityFeePerGas': 1000000000, + 'maxPriorityFeePerGasGwei': 1, + 'data': nftContract.methods.mintPunk(2).encodeABI() + }; + + const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_KEY); + console.log("Minting punk...") + const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); + + console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`); +} + // const fs = require('fs') // const base64 = require('base-64'); @@ -47,4 +70,5 @@ async function mintOwnerNFT() { // // mintNFT("data:application/json;base64," + base64.encode(data)) // }) -mintOwnerNFT() +// mintOwnerNFT() +mintPunk() diff --git a/send-tx.js b/send-tx.js index 13303ec..49a7d9f 100644 --- a/send-tx.js +++ b/send-tx.js @@ -20,12 +20,14 @@ async function sendEth() { const tx = { 'from': process.env.PUBLIC_OWNER_KEY, 'to': process.env.PUBLIC_KEY, - 'value': .01 * Math.pow(10, 18), + // 'value': .001 * Math.pow(10, 18), + 'value': 0, 'nonce': nonce, 'gas': 25000, - 'maxFeePerGasGwei': 30, + 'gasPrice': 60000000000, + 'maxFeePerGasGwei': 50, // 'maxPriorityFeePerGas': 1000000000, - 'maxPriorityFeePerGasGwei': 1, + 'maxPriorityFeePerGasGwei': 2, }; const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_OWNER_KEY);