Created
May 1, 2024 21:46
-
-
Save ronnyhaase/92b73a49a0097e1d48c5419d55ee41d4 to your computer and use it in GitHub Desktop.
16-Bit Solana Logo - Raffle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const collectionAddress = "HXbJbA5CEzJhYoMH1kmiDGHwZFZyJMGqDXvXqHGQNenW"; | |
const myself = "rnywTUFMTv9KbMoMXYwHKkeYjHBwffnAh9RVE8YkG1d"; | |
(async function main() { | |
const headers = new Headers(); | |
headers.append("x-api-key", "<Shyft API Key>"); | |
const requestOptions = { | |
method: "GET", | |
headers, | |
redirect: "follow", | |
}; | |
const owners = await fetch( | |
`https://api.shyft.to/sol/v1/collections/get_nfts?network=mainnet-beta&collection_address=${collectionAddress}&size=50`, | |
requestOptions, | |
) | |
.then((response) => response.json()) | |
.then((body) => | |
body.result.nfts | |
.map((nft) => nft.owner) | |
.filter((owner) => owner !== myself), | |
) | |
.catch((error) => console.log("Error: ", error)); | |
console.log(`Owners (${owners.length}):`); | |
owners.map((owner) => console.log(owner)); | |
console.log("\nWINNER:", owners[Math.floor(Math.random() * owners.length)]); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment