r0bre | Accretion.xyz
r0bre | Accretion.xyz
@r0bre
Jul 19 6 months ago 2 tweets Read on X
AI Summary

Here's a quick Solana tip: when creating onchain data structures, put fixed-size values at the start and variable ones at the end. This makes it easier to read fixed parts quickly and helps with RPC calls that need fixed offsets. Simple layout tricks like this can save you time and make your code cleaner.

Daily Solana Tip 8
When designing the structure layouts for your program's onchain data, try putting any fixed-size values at the beginning of your structure, while putting variable-size values, such as options or vectors at the end of your structure. This will allow you to always read the fixed size values at a static offset, which can be helpful for some RPC methods that require a fixed offset

@r0bre
I want to post small daily solana tips for a while. Tiny ideas on how to write better and more secure Solana code. I will link the posts under this.
Let's start with an easy but long one..

Missing some Tweet in this thread? You can try to Update

More Threads by @r0bre

Here's a simple tip for working with Solana projects: organize your code into folders like instructions and state to kee...
2 tweets • 4 months ago
Read Thread
Here's a quick Solana tip: When using Anchor, stick to has_one for constraints. If you need something more complex, put ...
2 tweets • 4 months ago
Read Thread
This tip suggests using lots of strict code checks (linting) like cargo clippy with many warnings enabled. It gives many...
2 tweets • 6 months ago
Read Thread
Using floats for money like $420.69 is a bad idea because they can cause precision errors, like ending up with tiny inac...
2 tweets • 6 months ago
Read Thread
Solana can run multiple transactions at once if they read different accounts, but if they write to the same account, the...
2 tweets • 6 months ago
Read Thread

Unroll Another Thread

Convert any Twitter threads to an easy-to-read article instantly

Have you tried our Twitter bot?

You can now unroll any thread without leaving Twitter/X. Here's how to use our Twitter bot to do it.

  • Give us a follow on Twitter. follow us
  • Drop a comment, mentioning us @unrollnow on the thread you want to Unroll.
  • Wait For Some Time, We will reply to your comment with Unroll Link.
UnrollNow Twitter Bot
Modal Image
0:00 / 0:00