0

I searched for a similar question but couldn't find one.

So, I get the last block, then inside this, block I parsing all transactions. My task is to find information that a new token has been created. I want to get its address.

The problem is that in the list of all transactions in the block, I don't understand what flags signal that a new token has been registered and assigned an address.

How to find information about a new token in the list of all transactions from the last block

I get a list of all the transactions in there. I've looked through a lot of data, and I can't figure out what parameters to rely on to know that a new token has been created and assigned an address

{
    meta: {
      computeUnitsConsumed: 2100,
      err: null,
      fee: 5000,
      innerInstructions: [],
      loadedAddresses: [Object],
      logMessages: [Array],
      postBalances: [Array],
      postTokenBalances: [],
      preBalances: [Array],
      preTokenBalances: [],
      rewards: [],
      status: [Object]
    },
    transaction: { message: [Message], signatures: [Array] },
    version: 'legacy'
  },

thank you

4
  • 1
    Does this answer your question? How do I get real-time information about newly created tokens on Solana?
    – Ahri
    Commented Jan 12 at 8:01
  • thanks, yes I saw this post, my question is how to filter the data to really understand that the token was created and get its address. @GuiomarRaissa
    – slntrx
    Commented Jan 12 at 8:05
  • Added an answer that should solve your issue below
    – Ahri
    Commented Jan 14 at 21:05
  • Thanks guys, I have read your tips, they look logical, I will proceed with the development). thanks
    – slntrx
    Commented Jan 15 at 4:58

3 Answers 3

1

Inside your block, you've got a list of transactions. These transactions in turn have a list of instructions (inside the message of each transaction). What you want to check for is instructions that created a new token. You can do this by filtering instructions first by the program they're calling (you want to make sure the program they're calling is the Token program). Once you've done this, you'll want to check if the remaining instruction matches the InitializeMint instruction by verifying if the bytes of the instruction match the format of that instruction. You can find its format here. Then, if you found a InitializeMint instruction, a new token has been created, and, as you can see by the format, the first account will be the newly created token mint account.

5
  • > You can do this by filtering the instructions by the program they call. to do this, the instructions have to be decoded?
    – slntrx
    Commented Jan 16 at 10:03
  • Would it be considered reliable if I parsed the data from logMessage? It is an array of strings, inside of which there is data about InitializeMint2. I'm asking because I can't decode these instructions I guess I can't rely on logMessage. Since there is no address for the new token there
    – slntrx
    Commented Jan 16 at 11:28
  • 1
    The docs explain how instructions are encoded pretty well: docs.solana.com/developing/programming-model/…
    – Ahri
    Commented Jan 16 at 11:33
  • yes i read that, but i can't figure out how to decode it with js.
    – slntrx
    Commented Jan 16 at 11:56
  • 1
    In that case, I suggest you open another question specifically asking how to parse encoded token instructions in javascript, as this answer would be beyond the scope of a comment.
    – Ahri
    Commented Jan 16 at 12:12
2

You can use the following API to create the latest tokens.

Tokens created in a block - https://ide.bitquery.io/Solana-new-token-created-in-a-block

Latest Tokens created API - https://ide.bitquery.io/Latest-Created-tokens-on-Solana_1

Latest Token created Webscoket - https://ide.bitquery.io/Websocket---Latest-Created-tokens-on-Solana

Get authorities of a token - https://ide.bitquery.io/get-authorities-of-token-on-solana

Count of tokens created on solana - https://ide.bitquery.io/Count---Tokens-created-on-Solana_1

Disclosure - I work for Bitquery

1

To add to Guiomar's answer, be aware there are 2 token programs, token and token2022, so you want to make sure you are including both in your filter.

Another thing to note is that there's InitializeMint2, which you can find here

You can choose to target either token or token2022, or any of the initialize instructions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.