|
|
@ -8,6 +8,14 @@ const API_URL = process.env.API_URL; |
|
|
|
import { createAlchemyWeb3 } from "@alch/alchemy-web3" |
|
|
|
const web3 = createAlchemyWeb3(API_URL); |
|
|
|
|
|
|
|
// change:
|
|
|
|
// networkId
|
|
|
|
// ABI
|
|
|
|
// contract address
|
|
|
|
// method name
|
|
|
|
// mint gas
|
|
|
|
// mint method data
|
|
|
|
// public/private key
|
|
|
|
import contractABI from './MoonbirdPunks.json' assert { type: 'json' } |
|
|
|
|
|
|
|
// create options object
|
|
|
@ -24,7 +32,6 @@ const options = { |
|
|
|
// initialize and connect to the api
|
|
|
|
const blocknative = new BlocknativeSdk(options) |
|
|
|
const contractAddress = "0x90Bc839511e1a8b32e2ba27f37c7632D12E872B6"; |
|
|
|
// const methodName = "ownerMint"
|
|
|
|
const methodName = "flipSaleState" |
|
|
|
|
|
|
|
await blocknative.configuration({ |
|
|
@ -47,7 +54,7 @@ console.log(`Watching for ${methodName} on ${contractAddress}...`) |
|
|
|
|
|
|
|
const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress); |
|
|
|
|
|
|
|
async function mintPunk(maxFee, maxPriorityFee) { |
|
|
|
async function mintNFT(maxFee, maxPriorityFee) { |
|
|
|
const nonce = await web3.eth.getTransactionCount(process.env.PUBLIC_KEY, 'latest'); //get latest nonce
|
|
|
|
|
|
|
|
//the transaction
|
|
|
@ -62,7 +69,7 @@ async function mintPunk(maxFee, maxPriorityFee) { |
|
|
|
}; |
|
|
|
|
|
|
|
const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_KEY); |
|
|
|
console.log("Minting punk...") |
|
|
|
console.log("Minting NFT...") |
|
|
|
const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); |
|
|
|
|
|
|
|
console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`); |
|
|
@ -73,7 +80,7 @@ emitter.on('txPool', transaction => { |
|
|
|
// emitter.on('txSent', transaction => {
|
|
|
|
console.log(`Sending ${transaction.value} wei to ${transaction.to}`) |
|
|
|
blocknative.unsubscribe(contractAddress) |
|
|
|
mintPunk(transaction.maxFeePerGas, |
|
|
|
mintNFT(transaction.maxFeePerGas, |
|
|
|
transaction.maxPriorityFeePerGas) |
|
|
|
}) |
|
|
|
|
|
|
|