Lakshya Profile picture
Sep 20 7 tweets 3 min read
The curious case of using offset values with data slice property 🤔 #Solana #Day8 #offset Image
dataSlice is used to literally slice 🔪 the returned data buffer.

Let's say you have a dataBuffer in which the first 8bytes are storing data you don't need. So, we can slice that from all the data and then carry out operations on the remaining data. Optimized much? 🤌
Now, the no. of bytes, to slice from the beginning, is defined as an 'offset' value inside of it.

Or

using offset value in dataSlice defines how much bytes to slice, in the returned buffer. Image
However, when you specify the offset value within the filters property, you are specifying how much bytes to skip before matching with the query data (mentioned in bytes)

Therefore, it doesn't affect the returned data buffer in terms of byte size. Image
This is an easy concept, but can be quite confusing for beginners or if someone doesn't know about the underlying concept behind using dataSlice and filters property.
Also, TIL that Borsh uses the the first 4bytes of any dynamic field to store the field's length in bytes.

(That's why started the slice from 4bytes to access the correct data in the snippet 👇)

Incase one doesn't accounts for these bytes, It may result in faulty calculations. Image
Implemented Paging, Ordering and Searching Functionality in my project. This hands on practice post every tutorial helps me in understanding the concepts better. Calling it a day 🫡.

Can't wait to start the next phase. Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Lakshya

Lakshya Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @void_stack

Sep 27
NFTs on Solana are simply just some SPL-Tokens. But what makes them special from other tokens? Few things... #Day11 #Solana #NFTs Image
1. Max Supply - The max supply of such tokens is restricted to 1. Which means at any time, there won't exist more than 1 such token. Image
2. Decimals - These tokens can't be fractionalized. Their decimals property is set to 0.

You can't send someone 0.5 NFT right? as compared to sending someone 0.5 Sols or some other token. Image
Read 7 tweets
Sep 27
Spent the last few days building my own token-minter application using Next and Chakra-UI.

Got to learn why we can't simply use inbuilt functions to build trxs when we need to send them to the user's wallet for approval.

#Day10 #Solana #TokenMinter Image
Added 4 different functionalities:

1. Creating Mints & Token Accounts ✅

2. Minting Tokens to the account user wants ✅

3. Transferring tokens from user's acc ➡️ receiver's acc ✅

4. Checking Available Token in one's acc ✅ Image
Tried to deploy any such web app for the first time on Vercel and realized it's not the same as using it on localhost 😐

Facing some issues while interacting with Phantom wallet on the deployed website. Will try to find more about it and fix it.
Read 5 tweets
Sep 19
Analogy: You can either buy all the potatoes and then decide what potatoes to use for making 🍟 or you can filter out the good potatoes while purchasing them. In either case the fries will be made of good 🥔 #Day7 #Solana #filtering
Sorry 😛, stay with me. Here purchasing 🥔 refer to fetching accounts data using 2 approaches:

1. Fetching all acc. without any data (just their pubKeys) ~ (purchasing all)

2. Filtering what acc. to fetch, before fetching them without any data ~ (filtering before buying) Image
In the 1st approach, one is fetching accounts without any data.

Now what that means is, we have a pubkey with us.

Whenever a client demands for data, we will be using the pubkey we saved earlier to further fetch associated account data. ImageImage
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(