from solders.pubkey import Pubkeyfrom solana.rpc.api import Clientfrom borsh_construct import CStruct, String, U8, Boolfrom construct import Bytesclient = Client("https://api.mainnet-beta.solana.com")def get_metadata(address: str): try: metadata_account_info = get_pda(address) if metadata_account_info.value: metadata_layout = CStruct("update_authority" / Bytes(32),"mint" / Bytes(32),"name" / String,"symbol" / String,"uri" / String, ) isMutable_layout = CStruct("updateAuthority" / Bytes(32),"mint" / Bytes(32), "data" / CStruct("name_length" / Bytes(4),"name" / Bytes(32),"symbol_length" / Bytes(4),"symbol"/ Bytes(32),"uri_length" / Bytes(10),"uri" / Bytes(200), ), "isMutable" / Bool ) metadata_data = metadata_layout.parse(metadata_account_info.value.data) isMutable_data = isMutable_layout.parse(metadata_account_info.value.data) isMutable = isMutable_data.isMutable name = metadata_data.name symbol = metadata_data.symbol print(f"{name}\n{symbol}\n{isMutable}\n{"-" * 30}") except Exception as e: print("Error getting metadata: ", e)def get_pda(token_address: str): new_token = Pubkey.from_string(token_address) token_metadata_program = Pubkey.from_string("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s") metadata_pda = Pubkey.find_program_address([b"metadata", bytes(token_metadata_program), bytes(new_token)], token_metadata_program)[0] metadata_account_info = client.get_account_info(metadata_pda) if metadata_account_info.value: return metadata_account_info else: print("Metadata account not found.") return Nonedef main(): mint1 = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" mint2 = "3T9mBXQzfAn8Rf1LKDutvGMTd1EruJbFh3cM7MSMq3Py" mint3 = "Ap5zQ4V62riDNnYN9ihFyNM8brdiYenkvMpHeF3Epump" mint4 = "8HYCrj9AFaWXtwMbYdZBsGC27fNctKDriNDJP72gBubE" get_metadata(mint1) get_metadata(mint2) get_metadata(mint3) get_metadata(mint4)main()
On isMutable_layout
, whenever I change the symbol bytes to 32, the mint3 and mint4 show the true value of isMutable
which is True and mint1 and mint2 become false, but when I change the value of bytes to 10, the mint1 and mint2 will show the True value which is True.
All of them are mutable tokens, you can verify it on different scanners. Mint1 and Mint2 is an old tokens, "Bonk" and "Chippy" which I think affects the structuring of the layout.
I already tried to set the symbol length to bytes(4) and uri_length to bytes(4) but all of them returned False. I tried to monitor the newly listed or created tokens and compare the value of isMutable
to different scanners like Rugcheck and Helius at the same time, and the bytes(32) of the symbol matches them.
But still, the example mint addresses are all mutable tokens and I don't want to retrieve an inappropriate value in the future scanning by just relying on making the symbol bytes to 32.