The goal of this workshop is to discover through some examples how the data on the Solana blockchain works and how to recover this data
# Clone the repository (you can also click "Use this template")
git clone https://github.com/sonarwatch/solana-workshop.git solana-workshop
cd solana-workshop
...
# Install dependencies
yarn install
# Run steps files
.\node_modules\.bin\ts-node-dev .\src\step01.ts
# Run main.ts file
yarn dev # runs main.ts file
...
In this step we get the account info of the USDC token. For this we use connection.getAccountInfo
. We obtain some data as a Buffer that we will decode in the next step.
In this step we decode the USDC token data. For that we decode the buffer thanks to the MintAccountStruct
. MintAccountStruct
is based on the Metaplex Beet library.
In this step, we get the account info a USDC token account. For this, we use connection.getAccountInfo
. We obtain some data as a Buffer that we will decode in the next step.
In this step we decode the USDC token data. For that we decode the buffer thanks to the TokenAccountStruct
. TokenAccountStruct
is based on the Metaplex Beet library.
In this step, the goal is to display the amount of each token that a wallet has. For this there are several steps:
- Get all tokens accounts of a wallet, then decode them with
connection.getProgramAccounts
, then decode them withTokenAccountStruct
. - Get all the mints and get the accounts info with
getMultipleAccountsInfo
, then decode mints accounts withMintAccountStruct
- Divided step 1 amounts by step 2 decimals
- Display tokens amounts in the console
- Display mints as symbols thanks to Solana token list
You can go further and try to decode other accounts. Here are two examples you can start with:
Solana Staking (StakeAccount)
You can recover your staking accounts.
Marinade Finance (TicketAccountData)
On Marinade, When you choose 'Delayed unstake' your mSOL, these operations happen under the hood:
- You are given a claim ticket indicating the amount and due time of your unstake.
- mSOL is burnt and removed from the supply.
- The unstake operation is launched and performed by the bot.
- At due time, you will be able to claim your SOL and destroy the claim ticket in exchange. (A claim ticket has no expiry date.)
What you can do is try to decode the TicketAccount.
Jet Staking (StakeAccount)
Jet Protocol has a governance program where you can stake $JET tokens. You can try to decode your StakeAccount to find out how many $JET you have staked.