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

Getting the list of stakers (their real wallet) #103

Open
rxrxrxrx opened this issue Jun 9, 2022 · 1 comment
Open

Getting the list of stakers (their real wallet) #103

rxrxrxrx opened this issue Jun 9, 2022 · 1 comment

Comments

@rxrxrxrx
Copy link

rxrxrxrx commented Jun 9, 2022

Hi,

I would like to take a snapshot of our holders, those who stake at the moment.
I didnt really find how to do that, any doc or recommandation?

I would like to make a list of wallet so we can airdrop them in the future

thanks for the help

@zkRemda
Copy link

zkRemda commented Aug 25, 2022

Hi this is easy to do, you just need to do something like this:

const commitment = "confirmed"
const connection = new Connection(RPC_URL, { commitment })
const wallet = web3.Keypair.generate()
const gemFarm = anchor.Program<GemFarm>(
     farmIdl as any, 
     GEM_FARM_PROG_ID, 
     new anchor.Provider(connection, new anchor.Wallet(wallet), { commitment })
)

const fetchFarmers = async (farm: PublicKey) => {
   const filters = [
        {
            memcmp: {
                offset: 8,
                bytes: farm.toBase58()
            }
        }
    ]

    return await gemFarm.account.farmer.all(filters)
}

// then call fetchFarmers with your farm public key as parameter.
fetchFarmers(FARM_KEY)

// After that you just need to store the output somewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants