Skip to content

Instantly share code, notes, and snippets.

@arivictor
Created August 25, 2022 08:15
Show Gist options
  • Select an option

  • Save arivictor/4af4eb686f8fb843d71e3d45e7fd2304 to your computer and use it in GitHub Desktop.

Select an option

Save arivictor/4af4eb686f8fb843d71e3d45e7fd2304 to your computer and use it in GitHub Desktop.
// "@metaplex-foundation/js": "^0.15.0",
import {Metaplex} from "@metaplex-foundation/js";
import {Connection, PublicKey, ConfirmedSignatureInfo} from "@solana/web3.js";
import * as fs from "fs";
const RPC_URL = 'https://...';
const MASTER_EDITION_ADDRESS = '6g2...ZfK2';
const RESULT_OUTPUT_PATH = './hashlist.json';
(async () => {
const connection = new Connection(RPC_URL);
const metaplex = new Metaplex(connection);
const master = await metaplex.nfts().findByMint({
mintAddress: new PublicKey(MASTER_EDITION_ADDRESS),
commitment: 'finalized',
}).run()
if (master.model === "sft") {
return
}
if (!master.edition.isOriginal) {
return
}
const signatures: { signature: string; }[] = []
let before: string | undefined = undefined;
while (true) {
const sigs: ConfirmedSignatureInfo[] = await metaplex.connection.getSignaturesForAddress(
master.address,
{
before: before
},
'finalized'
)
if (!sigs.length) break
signatures.push(...sigs)
before = sigs[sigs.length - 1].signature
}
const hashlist: string[] = []
for (let i = 0; i < signatures.length; i++) {
console.log(`${i}/${signatures.length}`, hashlist.length, 'so far');
await metaplex.connection.getParsedTransaction(signatures[i].signature).then(tx => {
if (!tx) return
const logs = JSON.stringify(tx.meta?.logMessages)
if (logs.toLowerCase().includes('error')) return
if (logs.includes('MintLimitedEdition') && logs.includes('Mint New Edition from Master Edition Via Token')) {
const addresses = tx.transaction.message.accountKeys.map(a => a.pubkey.toString())
const mintAddress = addresses[1]
console.log(mintAddress)
hashlist.push(mintAddress)
}
});
}
const supply = master.edition.supply
console.log('found', hashlist.length, 'expected', supply.toString())
fs.writeFileSync(RESULT_OUTPUT_PATH, JSON.stringify(hashlist, null, 2))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment