Browse Source

Note down what to change for live

main
Kevin Mok 2 years ago
parent
commit
3fa99dab59
No known key found for this signature in database GPG Key ID: C072BD80DB66DE18
  1. 3
      Kitbash.json
  2. 3
      Otherside.json
  3. 15
      index.js
  4. 2
      watch.js

3
Kitbash.json
File diff suppressed because it is too large
View File

3
Otherside.json
File diff suppressed because it is too large
View File

15
index.js

@ -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)
})

2
watch.js

@ -9,6 +9,7 @@ import { createAlchemyWeb3 } from "@alch/alchemy-web3"
const web3 = createAlchemyWeb3(API_URL);
// import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
// change ABI/contract address
import contractABI from './Otherside.json' assert { type: 'json' }
// create options object
@ -53,6 +54,7 @@ const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress);
emitter.on('txPool', transaction => {
// emitter.on('txSent', transaction => {
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
blocknative.unsubscribe(contractAddress)
})
// blocknative.unsubscribe(contractAddress)

Loading…
Cancel
Save