Browse Source

Watch contract on mainnet

main
Kevin Mok 2 years ago
parent
commit
5c346ead31
No known key found for this signature in database GPG Key ID: C072BD80DB66DE18
  1. 1
      .gitignore
  2. 3
      Kitbash.json
  3. 4
      mint-nft.js
  4. 15
      watch.js

1
.gitignore

@ -1,4 +1,5 @@
node_modules/
.env
*.json
*.txt

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

4
mint-nft.js

@ -70,5 +70,5 @@ async function mintPunk() {
// // mintNFT("data:application/json;base64," + base64.encode(data))
// })
// mintOwnerNFT()
mintPunk()
mintOwnerNFT()
// mintPunk()

15
watch.js

@ -8,12 +8,13 @@ const API_URL = process.env.API_URL;
import { createAlchemyWeb3 } from "@alch/alchemy-web3"
const web3 = createAlchemyWeb3(API_URL);
import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
// import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
import contractABI from './Kitbash.json' assert { type: 'json' }
// create options object
const options = {
dappId: 'd30463f1-eb29-42b8-8059-e5596e13d0fe',
networkId: 3,
networkId: 1,
system: 'ethereum', // optional, defaults to ethereum
transactionHandlers: [event => console.log(event.transaction)],
ws: WebSocket, // only neccessary in server environments
@ -23,13 +24,13 @@ const options = {
// initialize and connect to the api
const blocknative = new BlocknativeSdk(options)
const contractAddress = "0x7d82a88Efb60Bb83B3f1665757c20D07E5C0f3ED"
const methodName = "ownerMint"
const contractAddress = "0x5ff1863753C1920C38c7BaE94576f2831eF99695"
const methodName = "mint"
// const methodName = "flipSaleState"
await blocknative.configuration({
scope: contractAddress, // [required] - either 'global' or valid Ethereum address
// filters: [{"contractCall.methodName":methodName}],
filters: [{"contractCall.methodName":methodName}],
abi: contractABI.abi, // [optional] - valid contract ABI
watchAddress: true // [optional] - Whether the server should automatically watch the "scope" value if it is an address
})
@ -43,8 +44,8 @@ const {
details // initial account details which are useful for internal tracking: address
} = blocknative.account(contractAddress)
// console.log(`Watching for ${methodName} on ${contractAddress}...`)
console.log(`Watching for all methods on ${contractAddress}...`)
console.log(`Watching for ${methodName} on ${contractAddress}...`)
// console.log(`Watching for all methods on ${contractAddress}...`)
const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress);

Loading…
Cancel
Save