Mint multiple with payable
This commit is contained in:
28
mint-nft.js
28
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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user