Data accounts store data. Program accounts store executable programs.
Each account has an address (usually a public key) and an owner (address of a program account). There are a few more fields every account stores, see π
2/ There are a few important ownership rules:
- Only a data account's owner can modify its data and subtract lamports.
- Anyone is allowed to give lamports to a data account.
- The owner of an account may assign a new owner if the account's data is zeroed out.
3/ If you're coming from Ethereum, there's one major differenceβprogram accounts do not store state!
E.g., if you have a counter program that lets you increment a counter, you must create two accounts: one account to store the program's code, and one to store the counter.
4/ To prevent an account from being deleted, you must pay rent.
Why? B/c account data is stored by nodes in the Solana network. And that costs $!
Rent is regularly deducted from an account's balance. But, if an account has enough lamports, it is exempt from rent.
5/ Let's recap:
- There are 2 types of accounts, data accounts and program accounts.
- Each account has an address (usually a public key) and an owner (a program account).
- Program accounts don't store state (unlike Ethereum).
- Accounts must pay rent to stay alive.
6/ Anddd that's it! If you're going to reply that it took 6 or 7 tweetsβthis tweet and the first tweet don't count π
If you want to dive deeper into how Solana accounts work, check out this great resource π
2/ Anchor (by @ProjectSerum) is a framework that will make your life much easier.
There are three parts to Anchor:
- A TypeScript library that's similar to web3.js
- Rust crates that make writing Solana programs easier
- A CLI for building/testing, similar to @HardhatHQ
My 7 favorite resources for getting started with web3...
1/ @3blue1brown's video "But how does bitcoin actually work?" explains Bitcoin's blockchain, and is the most understandable introduction to blockchain I've come across.
2/ The @ethereum whitepaper explains what Ethereum is and how it works. I recommend skimming it to get the general idea and revisiting it later.