|
|
// require('dotenv').config();
import dotenv from 'dotenv' dotenv.config() const API_URL = process.env.API_URL; // const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
import { createAlchemyWeb3 } from "@alch/alchemy-web3" const web3 = createAlchemyWeb3(API_URL);
// const contract = require("../artifacts/contracts/MyNFT.sol/MyNFT.json");
import contractABI from './MoonbirdPunks.json' assert { type: 'json' } // console.log(JSON.stringify(contract.abi));
const contractAddress = "0x90Bc839511e1a8b32e2ba27f37c7632D12E872B6"; const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress);
async function mintOwnerNFT() { const nonce = await web3.eth.getTransactionCount(process.env.PUBLIC_OWNER_KEY, 'latest'); //get latest nonce
//the transaction
const tx = { 'from': process.env.PUBLIC_OWNER_KEY, 'to': contractAddress, 'nonce': nonce, 'gas': 100000, 'maxFeePerGasGwei': 50, // 'maxPriorityFeePerGas': 1000000000,
'maxPriorityFeePerGasGwei': 2, 'data': nftContract.methods.ownerMint([process.env.PUBLIC_KEY], 1).encodeABI() };
const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_OWNER_KEY); console.log("Minting owner punk...") const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); 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');
// fs.readFile('scripts/geo.json', 'utf8' , (err, data) => {
// if (err) {
// console.error(err)
// return
// }
// // console.log("data:application/json;base64," + base64.encode(data))
// // mintNFT("data:application/json;base64," + base64.encode(data))
// })
mintOwnerNFT() // mintPunk()
|