Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new script using DAS #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions get-collection-ts/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RPC_URL=https://mainnet.helius-rpc.com
API_KEY=85b1b62b-6788-41cd-8979-13152d8ebf4c
64 changes: 64 additions & 0 deletions get-collection-ts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { PublicKey } from "@solana/web3.js";
import fs from "fs";
import dotenv from "dotenv";

dotenv.config();

const RPC_URL = process.env.RPC_URL
const API_KEY = process.env.API_KEY
const url = `${RPC_URL}?api-key=${API_KEY}`;

const getAssetsByGroup = async () => {
const args = process.argv.slice(2, 4);

let collection_id = new PublicKey(args[0]);
console.time("getAssetsByGroup"); // Start the timer
let page = 1;
let assetList = [];

while (page) {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetsByGroup",
params: {
groupKey: "collection",
groupValue: collection_id,
page: page,
limit: 1000,
},
}),
});
const { result } = await response.json();

assetList.push(...result.items);
if (result.total !== 1000) {
page = false;
} else {
page++;
}
}
const resultData = {
totalResults: assetList.length,
results: assetList,
};
console.log(`${collection_id} Assets`, resultData);

const mints = resultData.results.map((item) => {
return item.id;
}
);
console.log(`${collection_id} Mints`, mints);
console.timeEnd("getAssetsByGroup"); // Stop the timer
fs.writeFileSync(`${collection_id}_full.json`, JSON.stringify(resultData));
fs.writeFileSync(`${collection_id}_mints.json`, JSON.stringify(mints));

//

};
getAssetsByGroup();
89 changes: 0 additions & 89 deletions get-collection-ts/index.ts

This file was deleted.

Loading