Category: Solana

17 May 2024
8 minutes

Cross Program Invocation In Anchor

Cross Program Invocation In Anchor Cross Program Invocation (CPI) is Solana’s terminology for a program calling the public function of another program. We’ve already done CPI before when we sent…

Read Article
07 May 2024
8 minutes

Reading Another Anchor Program’s Account Data On Chain

Reading Another Anchor Program’s Account Data On Chain In Solidity, reading another contract’s storage requires calling a view function or the storage variable being public. In Solana, an off-chain client…

Read Article
06 April 2024
8 minutes

#[derive(Accounts)] in Anchor: different kinds of accounts

[derive(Accounts)] in Anchor: different kinds of accounts #[derive(Accounts)] in Solana Anchor is an attribute-like macro for structs that holds references to all the accounts the function will access during its…

Read Article
15 March 2024
13 minutes

Modifying accounts using different signers

Modifying accounts using different signers In our Solana tutorials thus far, we’ve only had one account initialize and write to the account. In practice, this is very restrictive. For example,…

Read Article
12 March 2024
6 minutes

Deleting and Closing Accounts and Programs in Solana

Deleting and Closing Accounts and Programs in Solana In the Anchor framework for Solana, close is the opposite of init (initializing an account in Anchor) — it reduces the lamport…

Read Article
11 March 2024
10 minutes

PDA (Program Derived Address) vs Keypair Account in Solana

PDA (Program Derived Address) vs Keypair Account in Solana A program derived address (PDA) is an account whose address is derived from the address of the program that created it…

Read Article
11 March 2024
8 minutes

Owner vs Authority in Solana

Owner vs Authority in Solana Newcomers to Solana are frequently confused by the distinction between an “owner” and an “authority.” This article attempts to clear up the confusion as succinctly…

Read Article
10 March 2024
9 minutes

Multicall in Solana: Batching Transactions and Transaction Size Limit

Multicall in Solana: Batching Transactions and Transaction Size Limit Solana has multicall built in In Ethereum, we use the multicall pattern if we want to batch multiple transactions together atomically.…

Read Article
08 March 2024
11 minutes

Init_if_needed in Anchor and the Reinitialization Attack

Init_if_needed in Anchor and the Reinitialization Attack In previous tutorials, we’ve had to initialize an account in a separate transaction before we can write data to it. We may wish…

Read Article
07 March 2024
12 minutes

Understanding Account Ownership in Solana: Transferring SOL out of a PDA

Understanding Account Ownership in Solana: Transferring SOL out of a PDA The owner of an account in Solana is able to reduce the SOL balance, write data to the account,…

Read Article
02 March 2024
8 minutes

Transferring SOL and building a payment splitter: “msg.value” in Solana

Transferring SOL and building a payment splitter: “msg.value” in Solana This tutorial will introduce the mechanism by which Solana Anchor programs can transfer SOL as part of the transaction. Unlike…

Read Article
01 March 2024
4 minutes

Function modifiers (view, pure, payable) and fallback functions in Solana: why they don’t exist

Function modifiers (view, pure, payable) and fallback functions in Solana: why they don’t exist Solana does not have fallback or receive functions A Solana transaction must specify in advance the…

Read Article
29 February 2024
5 minutes

Reading an account balance in Anchor: address(account).balance in Solana

Reading an account balance in Anchor: address(account).balance in Solana Reading an account balance in Anchor Rust To read the Solana balance of an address inside a Solana program, use the…

Read Article
28 February 2024
8 minutes

Cost of storage, maximum storage size, and account resizing in Solana

Cost of storage, maximum storage size, and account resizing in Solana When allocating storage space, the payer must pay a certain number of SOL per byte allocated. Solana calls this…

Read Article
27 February 2024
8 minutes

Creating “mappings” and “nested mapping” in Solana

Creating “mappings” and “nested mapping” in Solana In the previous tutorials, the seeds=[] parameter was always empty. If we put data into it, it behaves like a key or keys…

Read Article
26 February 2024
8 minutes

Read account data with Solana web3 js and Anchor

Read account data with Solana web3 js and Anchor This tutorial shows how to read account data directly from the Solana web3 Javascript client so that a web app could…

Read Article
25 February 2024
6 minutes

Solana counter tutorial: reading and writing data to accounts

Solana counter tutorial: reading and writing data to accounts In our previous tutorial, we discussed how to initialize an account so that we could persist data in storage. This tutorial…

Read Article
24 February 2024
12 minutes

Initializing Accounts in Solana and Anchor

Initializing Accounts in Solana and Anchor Up until this point, none of our tutorials have used “storage variables” or stored anything permanent. In Solidity and Ethereum, a more exotic design…

Read Article
23 February 2024
10 minutes

Introduction to Solana Compute Units and Transaction Fees

Introduction to Solana Compute Units and Transaction Fees In Ethereum, the price of a transaction is computed as $\text{gasUsed} \times \text{gasPrice}$. This tells us how much Ether will be spent…

Read Article
21 February 2024
9 minutes

Tx.origin, msg.sender, and onlyOwner in Solana: identifying the caller

Tx.origin, msg.sender, and onlyOwner in Solana: identifying the caller In Solidity, the msg.sender is a global variable that represents the address that called or initiated a function call on a…

Read Article
20 February 2024
5 minutes

Solana logs, “events,” and transaction history

Solana logs, “events,” and transaction history Solana programs can emit events similar to how Ethereum emits events, though there are some differences we will discuss. Specifically, events in Solana are…

Read Article
19 February 2024
12 minutes

Solana Sysvars Explained

Solana Sysvars Explained In Solana, sysvars are read-only system accounts that give Solana programs access to the blockchain state as well as network information. They are similar to Ethereum global…

Read Article
18 February 2024
7 minutes

The Solana clock and other “block” variables

The Solana clock and other “block” variables Today we will cover the analogs of all the block variables from Solidity. Not all of them have 1-1 analogs. In Solidity, we…

Read Article
17 February 2024
9 minutes

Visibility and “inheritance” in Rust and Solana

Visibility and “inheritance” in Rust and Solana Today we will be learning how Solidity’s function visibility and contract inheritance can be conceptualized in Solana. There are four levels of function…

Read Article
16 February 2024
10 minutes

Rust Structs and Attribute-like and Custom Derive Macros

Rust Structs and Attribute-like and Custom Derive Macros Attribute-like and custom derive macros in Rust are used to take a block of Rust code and modify it in some way…

Read Article
15 February 2024
4 minutes

Rust function-like procedural Macros

Rust function-like procedural Macros This tutorial explains the distinction between functions and function like macros. For example, why does msg! have an exclamation point after it? This tutorial will explain…

Read Article
14 February 2024
10 minutes

The unusual syntax of Rust

The unusual syntax of Rust Readers coming from a Solidity or Javascript background may find Rust’s usage and syntax of &, mut, <_>, unwrap(), and ? to be weird (or…

Read Article
Load More Articles