# Solana Notes **Published by:** [hatem.eth](https://paragraph.com/@hatem/) **Published on:** 2024-05-16 **URL:** https://paragraph.com/@hatem/solana-notes ## Content Notes I put together on Solana in 2022. Lots of the ecosystem stuff is outdated now.Overviewover 60,000 tps$0.00025 transaction fees800 ms blocktimeSets of validators called clusters work together to validate client transactions. Different clusters may coexist and are identified by their genesis block. Two clusters that share the same genesis block will attempt to merge, otherwise they will ignore each other. Differs from traditional blockchains in that actions across nodes can be synchronized using proof of history (PoH).leader creates cryptographic proof with entries that some duration has passed since the last proofleader shares new entries with validator nodes which verify those proofsverifiable timestamps allow entries to arrive at validators in any order since the validators can reconstruct their order"blocks" are a set of entries that have been confirmed together.validator nodes optimistically process transactions in entries and roll back changes in the event that consensus wasn't achieved.Miscellaneousend users can create atomic transactions to multiple programs. On Ethereum this is only possible through a smart contract router.account model was designed to be easily parallelizedprograms are completely immutable accounts that store executable byte code. Programs store their state in non-executable accounts.Accounts can specify an owner which is the only program allowed to make modifications to the accountto parallelize transactions, transactions specify all the accounts they will read from or write to so that validators know ahead of time which transactions can be parallelized and which conflict. Enabling programs to store data in different accounts allows devs to optimize for parallelization so that as many transactions can be parallelized as possible.transaction signaturesan array of signatures is passed to solana transactions so if on chain programs are looking for more than one signature (say for a multisig wallet), all the signatures can efficiently be verified by a GPU instead of within a programrecentBlockhash vs noncesolana transactions sign a recent blockhash and old transactions cannot be verified. This solves the same problem as an Ethereum nonce while also ensuring old transactions can't be runsol transfersthere's a solana program, the system program, which allows users to transfer soltransactions roughly have a fixed cost and there is a limit to the compute cost a transaction can usesolana instructions (think Ethereum tx data) are commands for on chain programs. Transactions can include multiple instructions (executed atomically). The encoded size of a transaction is 1232 bytes so instructions cannot become too large.solana has special programs for deploying programs and transferring sol.account ownershipall accounts have an owner. By default their owner is the system program. When a program owns an account it is able to change its data. When an program does not own an account, it can merely read the account's dataTerminologyAccount: record on the ledger that holds data or is an executable programBank State: state of all programs on the ledger at a given tick heightentry: an entry on the ledger which is either a tick or a transaction entry. Blocks consist of entries which are smaller smaller batches of transactions.tick: an entry that estimates wallclock duration (timestamp)Usage Notessuper fast, feels basically instantSmart Contract Development + Developer Toolsprograms compiled via LLVM compiler infrastructure to Executable and Linkable Format (standard binary file format for Unix) containing Berkeley Packet Filter (BPF) bytecodesmart contracts can be written in any language that can be compiled down to solana's backend. Rust is popular.Deposits/WithdrawalsFTXCoinbaseLogin/Walletsmagic.linkphantomExisting Smart Contract InfrastructureConditional Token ContractsAMMsToken Swap ProgramOrder BookSerumGas Station Networkwe'd have to create our own custom solutionProxy WalletsSolana uses a proxy-wallet like architecture by default for their tokens because user token data is stored in an Account that is controlled by the programOracleshttps://solana.com/ecosystem/bandprotocolhttps://solana.com/ecosystem/chainlinkBlockchain Indexershttps://aleph.im/#/Cross Chain Communication with Ethereumhttps://wormholenetwork.com/en/ whose docs can be found here.wormhole allows for generic message passing between solana and ethereumnetwork of (currently 19) guardians watches wormhole contracts. When enough guardians sign an observation, the message is then posted on the destination chainResources:https://docs.solana.com/https://2501babe.github.io/posts/solana101.htmlhttps://solana.wiki/zh-cn/docs/ethereum-comparison/https://dev.to/cogoo/solana-teardown-walkthrough-of-the-example-helloworld-program-18m4https://github.com/solana-labs/solana-program-libraryhttps://docs.solana.com/developing/on-chain-programs/developing-rustDev NotesSPL TokenStateSeparate accounts forMint infodefines total supply, decimals, who can optionally mint, and who can optionally freezeAccount for each address with a token balancedefines the owner, mint, and amount held by the account among other thingsMultisigstruct enables many diffLife Cyclecreate an account for the new token's Mint storage. This includes creating a new key pair or passing in an existing key pair for the new account. This key pair will be one of signers of the transaction. The address of the spl token will be the owner of the account. Importantly, there is one piece of code that manages how many different tokens operate.creating the account includes transferring the minimum balance the account needs for 2 years of rent exemptionclient specifies a fixed storage size preallocated to the accountinitialize_mint to define the account that can mint new tokensinitialize the user's accountuse create_associated_token_account to deterministically create an account for the user's token datainitialize the account. Write the initial data to the account.mint tokens to the users accountupdate Mint account with the updated supplyupdate Account account with it's updated token amounttransfer tokensif the recipient account isn't created, create an associated token account for the recipientuse create_associated_token_account to create the accountprocess the transferensure the Mint account of both Accounts is the same (i.e. it is the same token) and a bunch of other checksupdate the balances in both accountsapprove an account to spend your tokens ## Publication Information - [hatem.eth](https://paragraph.com/@hatem/): Publication homepage - [All Posts](https://paragraph.com/@hatem/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@hatem): Subscribe to updates