RareSkills Blog

ERC20 Votes: ERC5805 and ERC6372
ERC20 Votes: ERC5805 and ERC6372 ERC20 Votes Knowledge of ERC20 Snapshot is assumed, please refer to our article on ERC20 Snapshot for an introduction to the subject. ERC20 Votes does…

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…

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…

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…

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…

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…

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…

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…

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…

Basic Rust for Solidity Developers
Basic Rust for Solidity Developers This tutorial goes over the most commonly used syntax in Solidity and demonstrates the equivalent in Rust. If you want a high level overview of…

Solana programs are upgradeable and do not have constructors
Solana programs are upgradeable and do not have constructors In this tutorial we will peek behind the scenes of anchor to see how a Solana program gets deployed. Let’s look…

Require, Revert, and Custom Errors in Solana
Require, Revert, and Custom Errors in Solana In Ethereum, we often see a require statement restricting the values a function argument can have. Consider the following example: function foobar(uint256 x)…

Solana Anchor Program IDL
Solana Anchor Program IDL The IDL (Interface Definition Language) is a JSON file that describes how to interact with a Solana program. It is automatically generated by the Anchor framework.…

Arithmetic and Basic Types in Solana and Rust
Arithmetic and Basic Types in Solana and Rust Today we will learn how to create a Solana program that accomplishes the same things as the Solidity contract below. We will…

Solana Hello World (Installation and Troubleshooting)
Solana Hello World (Installation and Troubleshooting) This is a Solana hello world tutorial. We will walk you through the steps to install Solana and troubleshoot issues that may arise. If…

Layer 2 Calldata Gas Optimization
Layer 2 Calldata Gas Optimization Update for mid 2024 As of the Dencun upgrade, calldata optimization doesn’t have as much of an impact since the transactions on most L2s are…

How Chainlink Price Feeds Work
How Chainlink Price Feeds Work Chainlink price oracles are smart contracts with public view functions that return the price of a particular asset denominated in USD. Off-chain nodes collect the…

How Compound V3 Allocates COMP Rewards
How Compound V3 Allocates COMP Rewards Compound issues rewards in COMP tokens to lenders and borrowers in proportion to their share of the a market’s lending and borrowing. The algorithm…

Bulkers in Compound V3
Bulkers in Compound V3 The bulker contracts in Compound V3 are multicall-like contracts for batching several transactions. For example, if we wanted to supply Ether, LINK, and wBTC as collateral…

Understanding Collateral, Liquidations, and Reserves in Compound V3
Understanding Collateral, Liquidations, and Reserves in Compound V3 In this chapter we will examine the following topics about Compound V3: collateral valuation absorbing insufficiently collateralized loans (liquidations) selling absorbed collateral…

cUSDC V3 (Compound V3) as a non-standard Rebasing Token, CometExt.sol
cUSDC V3 (Compound V3) as a non-standard Rebasing Token, CometExt.sol The Compound V3 contract behaves like a rebasing ERC 20 token. A rebasing token is a token which has an…

DeFi Interest Rate Indexes: Principal value and Present Value in Compound V3
DeFi Interest Rate Indexes: Principal value and Present Value in Compound V3 The intuitive way to track lender deposits is to record the amount of USDC they deposited and the…

Compound V3 Interest Per Second
Compound V3 Interest Per Second The Compound V3 protocol measures interest on the scale of seconds. The Compound V3 frontend scales the number up to years for human friendliness. When we check…

The Architecture of the Compound V3 Smart Contract
The Architecture of the Compound V3 Smart Contract Introduction and prerequisites Compound is one of the most significant lending protocols in DeFi, having inspired the design of nearly every lending…

DeFi Lending: Liquidations and Collateral
DeFi Lending: Liquidations and Collateral In TradFi, when someone defaults on a loan, the creditor has the right to seize assets or garnish wages. In DeFi, when someone defaults on…

The Fallback Extension Pattern
The Fallback Extension Pattern The fallback-extension pattern is a simple way to circumvent the 24kb smart contract size limit. Suppose we have functions foo() and bar() in our primary contract…

EIP 1967 Storage Slots for Proxies
EIP 1967 Storage Slots for Proxies EIP 1967 is a standard for where to store information that proxy contracts need to execute. Both the UUPS (Universal Upgradeable Proxy Standard) and…