Note down what to change for live
This commit is contained in:
File diff suppressed because one or more lines are too long
3
Otherside.json
Normal file
3
Otherside.json
Normal file
File diff suppressed because one or more lines are too long
15
index.js
15
index.js
@@ -8,6 +8,14 @@ const API_URL = process.env.API_URL;
|
|||||||
import { createAlchemyWeb3 } from "@alch/alchemy-web3"
|
import { createAlchemyWeb3 } from "@alch/alchemy-web3"
|
||||||
const web3 = createAlchemyWeb3(API_URL);
|
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' }
|
import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
|
||||||
|
|
||||||
// create options object
|
// create options object
|
||||||
@@ -24,7 +32,6 @@ const options = {
|
|||||||
// initialize and connect to the api
|
// initialize and connect to the api
|
||||||
const blocknative = new BlocknativeSdk(options)
|
const blocknative = new BlocknativeSdk(options)
|
||||||
const contractAddress = "0x90Bc839511e1a8b32e2ba27f37c7632D12E872B6";
|
const contractAddress = "0x90Bc839511e1a8b32e2ba27f37c7632D12E872B6";
|
||||||
// const methodName = "ownerMint"
|
|
||||||
const methodName = "flipSaleState"
|
const methodName = "flipSaleState"
|
||||||
|
|
||||||
await blocknative.configuration({
|
await blocknative.configuration({
|
||||||
@@ -47,7 +54,7 @@ console.log(`Watching for ${methodName} on ${contractAddress}...`)
|
|||||||
|
|
||||||
const nftContract = new web3.eth.Contract(contractABI.abi, 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
|
const nonce = await web3.eth.getTransactionCount(process.env.PUBLIC_KEY, 'latest'); //get latest nonce
|
||||||
|
|
||||||
//the transaction
|
//the transaction
|
||||||
@@ -62,7 +69,7 @@ async function mintPunk(maxFee, maxPriorityFee) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_KEY);
|
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);
|
const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
|
||||||
|
|
||||||
console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
|
console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
|
||||||
@@ -73,7 +80,7 @@ emitter.on('txPool', transaction => {
|
|||||||
// emitter.on('txSent', transaction => {
|
// emitter.on('txSent', transaction => {
|
||||||
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
|
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
|
||||||
blocknative.unsubscribe(contractAddress)
|
blocknative.unsubscribe(contractAddress)
|
||||||
mintPunk(transaction.maxFeePerGas,
|
mintNFT(transaction.maxFeePerGas,
|
||||||
transaction.maxPriorityFeePerGas)
|
transaction.maxPriorityFeePerGas)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
2
watch.js
2
watch.js
@@ -9,6 +9,7 @@ import { createAlchemyWeb3 } from "@alch/alchemy-web3"
|
|||||||
const web3 = createAlchemyWeb3(API_URL);
|
const web3 = createAlchemyWeb3(API_URL);
|
||||||
|
|
||||||
// import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
|
// import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
|
||||||
|
// change ABI/contract address
|
||||||
import contractABI from './Otherside.json' assert { type: 'json' }
|
import contractABI from './Otherside.json' assert { type: 'json' }
|
||||||
|
|
||||||
// create options object
|
// create options object
|
||||||
@@ -53,6 +54,7 @@ const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress);
|
|||||||
emitter.on('txPool', transaction => {
|
emitter.on('txPool', transaction => {
|
||||||
// emitter.on('txSent', transaction => {
|
// emitter.on('txSent', transaction => {
|
||||||
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
|
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
|
||||||
|
blocknative.unsubscribe(contractAddress)
|
||||||
})
|
})
|
||||||
|
|
||||||
// blocknative.unsubscribe(contractAddress)
|
// blocknative.unsubscribe(contractAddress)
|
||||||
|
|||||||
Reference in New Issue
Block a user