I would like to give SPL Token holders "SPL Token according to the ownership rate" as an incentive

I would like to give SPL Token holders “SPL Token according to the ownership rate” as an incentive. How can this be achieved?

for example
Get a list of accounts that have SPL Token and grant it at a certain timing
(But I don’t know how to get the account list)

1 Like

Hi @jsfskiz and welcome to the forum! :wave:

With the Web3.js API you can use the getProgramAccounts to get a list of accounts owned by the token program.

By default this will give you all of the token accounts for every token, though, which isn’t what you want. You can include in it’s arguments a GetProgramAccountFilter that can specify only to return accounts that have a certain token mint. You have to specify this very manually, though, but looking into the token program’s format for token accounts, checking the byte-offset of the token mint field, and telling the filter to only include accounts with the bytes for your token mint at that location.

There’s not an easier way that I know of to get that information, and I don’t have time right now to get you a working example, sorry!

You might ask on Discord to see if anybody has either better ideas or a working example.

I am very grateful for your advice.

I tried to get a list of token holders as follows:

curl https://api.devnet.solana.com -X POST -H “Content-Type: application/json” -d ’
“jsonrpc”: “2.0”,
“id”: 1,
“method”: “getProgramAccounts”,
“params”: [

※ xxxxxxxxxx is TokenAddress

But the response is empty.

I’ll ask a question on Discord.