Skip to content

Instantly share code, notes, and snippets.

View AndreyNikitsich's full-sized avatar

AndreyNikitsich

View GitHub Profile
@Aviksaikat
Aviksaikat / get_decimals_sol.py
Last active July 17, 2024 07:33
Get decimals of a token from SOLANA chain from a given address
from spl.token._layouts import MINT_LAYOUT
from solana.rpc.api import Client, Pubkey
http_client = Client("https://api.mainnet-beta.solana.com")
# USDC token address
addr = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
info = http_client.get_account_info(addr)
decimals = MINT_LAYOUT.parse(info.value.data).decimals