Network
Launch Date
Consensus
Note
Sepolia
Oct 2021
PoW
Like-for-like representation of Ethereum
Görli
Jan 2019
PoA
Proof-of-Authority
Kiln
Mar 2022
PoS
Post-Merge (for ETH2), shadow fork of the mainnet
Kintsugi
Dec 2021
PoS
DEPRECATED, use Kiln; post-Merge (for ETH2)
Ropsten
Nov 2016
PoW
DEPRECATED, use Sepolia; the Merge to happen on Jun 8, 2022
Rinkeby
Apr 2017
PoA
DEPRECATED, use Görli and Görli Faucet
Kovan
Mar 2017
PoA
DEPRECATED, use Sepolia or Görli
List of active and deprecated Ethereum testnets, including Kintsugi.
Features
Optimistic rollup 
ZK-rollup 
Proof
Uses fraud proofs to prove transaction validity. 
Uses validity (zero-knowledge) proofs to prove transaction validity. 
Capital efficiency
Requires waiting through a 1-week delay (dispute period) before withdrawing funds. 
Users can withdraw funds immediately because validity proofs provide incontrovertible evidence of the authenticity of off-chain transactions. 
Data compression
Publishes full transaction data as calldata to Ethereum Mainnet, which increases rollup costs. 
Doesn't need to publish transaction data on Ethereum because ZK-SNARKs and ZK-STARKs already guarantee the accuracy of the rollup state. 
EVM compatibility
Uses a simulation of the Ethereum Virtual Machine (EVM), which allows it to run arbitrary logic and support smart contracts. 
Doesn't widely support EVM computation, although a few EVM-compatible ZK-rollups have appeared. 
Rollup costs
Reduces costs since it publishes minimal data on Ethereum and doesn't have to post proofs for transactions, except in special circumstances. 
Faces higher overhead from costs involved in generating and verifying proofs for every transaction block. ZK proofs require specialized, expensive hardware to create and have high on-chain verification costs. 
Trust assumptions
Doesn't require a trusted setup. 
Requires a trusted setup to work. 
Liveness requirements
Verifiers are needed to keep tabs on the actual rollup state and the one referenced in the state root to detect fraud. 
Users don't need someone to watch the L2 chain to detect fraud. 
Security properties 
Relies on cryptoeconomic incentives to assure users of rollup security. 
Relies on cryptographic guarantees for security. 
Start building
on Alchemy.
Sign up for free
Start building on Optimism.
Sign up for free
Start building on Arbitrum.
Sign up for free
Start building on Ethereum.
Sign up for free
Start building on Polygon.
Sign up for free
Start building on Starknet.
Sign up for free
Start building on Flow.
Sign up for free
kiln faucet
Get free Kiln ETH.
Start building today
Goerli faucet
Get free Goerli ETH.
Start building today
SEPOLIA FAUCET
Get free Sepolia ETH.
Start Building Today
mumbai faucet
Get free Mumbai Matic.
Start building today
rinkeby faucet
Get free Rinkeby
ETH.
Start building today
Start building on Ethereum.
Get started for free
Start building on Ethereum.
Get started for free
Start building on Flow.
Get started for free
Start building on Polygon.
Get started for free
Start building on Starknet.
Get started for free
Start building on Optimism.
Get started for free
Start building on Solana.
Get started for free
Start building on Solana.
Sign up for beta access
Start building on Solana.
Join the waitlist
Arbitrum logo
Start building on Arbitrum.
Get started for free
Build with Alchemy's
Gas Manager & Bundler APIs
Learn
Solidity at
Alchemy
University
Get started today
Build with Alchemy's
Gas Manager & Bundler APIs
curl 
https://release.solana.com/v1.10.32/solana-install-init-x86_64-pc-windows-msvc.exe 
--output 
C:\solana-install-tmp\solana-install-init.exe 
--create-dirs
Solana
SPL OVERVIEW

What is the Solana Program Library?

Learn How to Develop Decentralized Applications on Solana Using the Solana Program Library
Last Updated:
January 26, 2023
Table of Contents
Table of Contents
Table of Contents

{{get-started-solana}}

Solana is a high-speed programmable blockchain that allows developers to build and deploy decentralized applications. Solana maintains a dedicated documentation library known as the Solana Program Library – a collection of pre-compiled, deployed, and optimized programs (i.e. smart contracts) for use on the Solana blockchain.

In this article, we'll explore the world of Solana and understand how you can develop quickly with the Solana Program Library. Whether you are new to Solana or an experienced developer, you can easily create and deploy your own custom tokens or a decentralized exchange with SPL. 

What are programs in Solana?

Programs in Solana are executable code stored in buffer storage called an account that can be executed via transaction, similar to smart contracts on Ethereum or any other programmable blockchain. However, unlike Ethereum, where the program and state are stored together in the smart contracts, Solana has adopted a stateless program model approach where data and programs are stored in accounts.

What are accounts in Solana?

As per the Solana documentation, “An account is a record in the Solana ledger that either holds data or is an executable program.” 

Think of Solana as a database where accounts are rows, pub keys act as IDs, and the value is the information stored in the account. Now, this information can either be in the form of programs (i.e smart contracts) or data/state of the program.

Accounts can be identified by a unique Public Key (256 bytes), which typically looks something like: “DM6n1qcUCLzJ1RaAuA4gUbBZ9sfHP6KvEwX8oExQqPhk”.

Solana has a logical separation between the code and its data, which causes two types of accounts to exist — executable and non-executable accounts.

1. Executable accounts

Accounts that only store the immutable program code and are marked as ‘executables’.

2. Non-Executable accounts

These accounts store all the data that its program may use, including the variables, assets, and state of the program. Even though anyone can read the data in these accounts, only the owner of the program (the deployer) can change it.

The accounts are maintained by validator nodes that charge a maintenance cost called ’Rent’ in exchange for memory space for storing the information above. Rents are paid in lamports — the fractional denomination of SOL (Solana’s native token).

Solana’s code and program data are maintained separately due to a system known as Sealevel Parallel Runtime.

What is Sealevel Parallel Runtime?

Sealevel Parallel Runtime is Solana’s implementation of a parallel transaction processing system. Traditional single-threaded blockchains like Ethereum can process only one transaction at a time to avoid concurrency. This is because Ethereum smart contracts are stateful — meaning both the state and the code are coupled in the same contract.

With the help of Sealevel, Solana can process thousands of non-conflicting transactions in parallel. Utilizing multiple validator cores, Solana can also execute up to 50,000 Tps with a 400-millisecond block time. This is possible because transaction instructions are stateless, and they decide which account’s data they would modify beforehand. Thus, Programs that do not share the same account data can run simultaneously.

What are the types of programs in Solana?

Solana’s ecosystem constitutes two distinct types of programs — native programs and on-chain programs. Let's look at both of these.

What are native programs?

Native programs are responsible for implementing core functionalities of the Solana network, such as managing the allocation of account storage, creating new accounts, processing transactions, and enforcing the rules of the Solana network.

Native programs are an integral part of Solana’s core blockchain model. They are typically written in low-level languages like Rust and C/C++ that are optimized for performance and security. Native programs can be called by any program/user, whereas a Kernel-level program in your Operating system cannot be directly called and accessed by a user.

Updating these programs can only happen as a part of core blockchain upgrades or cluster upgrades to add features, fix bugs, or improve performance.

There are numerous native programs that help to secure the validator. Some of them are:

1. System Program

System programs are responsible for creating new accounts, transferring SOL between two accounts, assigning account ownership, and performing more such account management operations.

2. Berkeley Packet Filter (BPF): 

Berkeley Packet Filter handles the deployment, upgrades, and execution of programs on-chain.

3. Stake program

A Stake program is responsible for managing the staking of SOL tokens on the Solana blockchain.

What are on-chain programs?

On-chain programs are user-written programs (i.e. smart contracts) that are deployed directly on the blockchain. These can range from a dapp, an exchange, practice contracts, a multi-sig wallet implementation, or any other generic program.

Unlike Native programs, on-chain programs do not form the core of the Solana cluster. Instead, they are custom programs created and deployed by developers on the Solana blockchain. This means that on-chain programs are not essential in the operation of the Solana blockchain.

They are built on top of the core infrastructure provided by the Native programs and allow developers to build a wide range of applications and services on the Solana blockchain.

The data that the programs interact with are stored in separate data accounts and passed in as references via instructions. Only the account owner can upgrade the program data.

Programs in Solana

What is the Solana Program Library?

The Solana Program Library (SPL) is a collection of pre-written, modular programs that can be used to build decentralized applications (dapps) on the Solana blockchain. SPL aims to make it easier for developers to create dapps by providing a set of reusable, modular components that can be easily integrated into their applications, reducing the need for developers to write complex codes from scratch.

Therefore, SPL enables developers to build dapps using a "building block" approach, where each component can be easily integrated into the application.

The SPL contains multiple on-chain generic programs, the Token program, and its variations being the most popular. which can help incorporate them into your project without implementing them from scratch.

SPL prerequisites

To interact with SPL, you can choose between the CLI approach or the commonly used JS approach, which inculcates solana/web3.js for interacting your Javascript code with the Solana blockchain. 

To interact with any Solana cluster, you must also set up the Solana CLI (Command Line Interface). The CLI might not be the most friendly to use for novice developers, but it provides the most direct and secure access to your Solana accounts. Moreover, the CLI is the first place the Solana Core Developers deploy newer functionalities.

What is the SPL Token Program?

The SPL Token program is a generic implementation for fungible and non-fungible tokens on the Solana blockchain. It provides an interface and detailed implementation which allows developers to create their own token. The code is natively written in Rust, and its auto-generated bindings are available in C and JavaScript. The source code is available in the SPL GitHub repo.

In Ethereum, the ERC20 Token program works differently than an Ethereum ERC-20 contract. Let’s take an example to understand the difference:

Suppose you want to publish three different tokens on the Ethereum blockchain. To do so, you must deploy 3 separate contracts for each token. And every token contract will keep track of its respective state (e.g. balances and transfers).

When it comes to Solana, there is no need to deploy three separate token programs. Instead, you can deploy one generic token program that can operate on a multitude of accounts (e.g. minting and receiving accounts).

The mint address will uniquely identify the token type. This information can be passed as arguments to a singular static ERC20 program instance that is already deployed on the Solana chain.

How to Use SPL Token Program to Create A Fungible Token

With SPL Token Program, you can create your fungible token in a few steps. Before diving right into the Token program, make sure you have set up your CLI wallet, or connected your Phantom wallet to Solana's Devnet, and airdropped enough devnet SOL into your wallet.

Step 1: Create Your Fungible Token 

The create token command is an instruction to the on-chain SPL Token Program to create a new Token. On successful creation of the token, we will receive a Token ID along with the transaction signature. But yes, we still have to mint them.

This is the token command: spl-token create-token

Results from running the spl-token create-token command

Step 2: Create a Token Account

To store the information related to our token in a separate data account. The token account is owned by the SPL-Token Program, which controls the access to these tokens along with the owner field (which is our Token-ID that can spend/transfer the tokens). 

Since this is a data account, its data can be modified by the Token Program by adding/minting, transferring, or burning the tokens. 

This is the token account creation command: spl-token create-account <TOKEN-ID>

As you can see below, we lost some minimal SOL as transaction fees by creating our token and its associated account. Also, notice that the initial supply is zero. This means we have to add a desirable amount of supply by minting out tokens.

Balance after running an spl-token create-account command.

Step 3: Mint a Desirable Amount of Tokens.

To mint a given number of tokens, run the following command:

spl-token mint <TOKEN-ID> <AMOUNT>

Once the command is executed, the said number of tokens will be minted into your file system wallet, and the token supply will get updated. 

Results after minting 2,000 tokens.


You can check the current token supply and the account associated with the token by running the following command:

spl-token supply <TOKEN-ID>

spl-token accounts

 

Results from checking the spl-token supply and accounts balance.

Now, let’s transfer our tokens to our Phantom wallet — a popular wallet on Solana.

Step 4: Transfer Tokens 

The plan is to transfer ‘x’ amount of tokens to the recipient — our Phantom wallet. The ‘fund recipient is responsible for creating a token account for the recipient if it does not exist. This is called creating an Associated Token Account.

Here's the command to transfer tokens:

spl-token transfer --fund-recipient <TOKEN-ID> <TRANSFER AMOUNT> <RECIPIENT ADDRESS or RECIPIENT TOKEN ACCOUNT ADDRESS> 

Token transfer results.

You’ll receive a success message once the transfer is successful.

Phantom wallet transfer success message.

You can verify the transfer by running this command: spl-token accounts

Note: if you run the token supply command, it will still show 2,000 tokens because supply indicates the number of tokens in circulation in the network, whereas balance refers to the number of tokens that your token account has.

Token Balance vs. Token Supply

Step 5: Limit token supply

One of the crucial aspects of contract security and demand is to restrict token supply. To disable mint functionality, set the mint authority to ‘None’.

Command to disable the token mint authority: spl-token authorize <TOKEN-ID> mint --disable

Minting an extra 3000 tokens before minting is disabled.

Mint authority disabled results.

Step 6: Burn tokens

If you want to reduce the supply of a token, you can choose to burn it.

Here’s the command for it: spl-token burn <TOKEN-ACCOUNT ADDRESS> <AMOUNT>

Burning SPL Tokens

Once burned, both the supply, as well as balance, will get reduced. As you can see in the example, our balance dropped from 4,978 to 3,978, and the supply got reduced to 4,000.

SPL Token Burn Results

SPL provides a complete reference guide on how you can use the Token program to perform more operations like:

  • Wrapping SOL in a token.
  • Transferring tokens to an explicit recipient token account.
  • Creating a non-fungible token.

Kickstart Your Solana Development Journey with SPL

The Solana Program Library features a host of pre-published on-chain programs that can be easily interacted with. With SPL, developers can focus on the unique features and functionality of their dapps — rather than spending time on basic, boilerplate token creation code.

If you’re a beginner and want to get started with your Solana development journey, your first step is to explore SPL and Alchemy’s Solana API. and a free Solana RPC node account. These will help you get your program running in no time.

ALCHEMY SUPERNODE - ETHEREUM NODE API

Scale to any size, without any errors

Alchemy Supernode finally makes it possible to scale blockchain applications without all the headaches. Plus, our legendary support will guide you every step of the way.

Get started for free
Supernode footer
Solana
SPL OVERVIEW

What is the Solana Program Library?

Learn How to Develop Decentralized Applications on Solana Using the Solana Program Library
Last Updated:
January 26, 2023
Last Updated:
March 14, 2023
Don't miss an update
Sign up for our newsletter to get alpha, key insights, and killer resources.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Table of Contents

Talk to an Expert

Learn how Alchemy's blockchain developer tools can help your business succeed in web3!
Valid number
Thank you! An Alchemy expert will be in touch with you shortly!
Oops! Something went wrong while submitting the form.

{{get-started-solana}}

Table of Contents

Solana is a high-speed programmable blockchain that allows developers to build and deploy decentralized applications. Solana maintains a dedicated documentation library known as the Solana Program Library – a collection of pre-compiled, deployed, and optimized programs (i.e. smart contracts) for use on the Solana blockchain.

In this article, we'll explore the world of Solana and understand how you can develop quickly with the Solana Program Library. Whether you are new to Solana or an experienced developer, you can easily create and deploy your own custom tokens or a decentralized exchange with SPL. 

What are programs in Solana?

Programs in Solana are executable code stored in buffer storage called an account that can be executed via transaction, similar to smart contracts on Ethereum or any other programmable blockchain. However, unlike Ethereum, where the program and state are stored together in the smart contracts, Solana has adopted a stateless program model approach where data and programs are stored in accounts.

What are accounts in Solana?

As per the Solana documentation, “An account is a record in the Solana ledger that either holds data or is an executable program.” 

Think of Solana as a database where accounts are rows, pub keys act as IDs, and the value is the information stored in the account. Now, this information can either be in the form of programs (i.e smart contracts) or data/state of the program.

Accounts can be identified by a unique Public Key (256 bytes), which typically looks something like: “DM6n1qcUCLzJ1RaAuA4gUbBZ9sfHP6KvEwX8oExQqPhk”.

Solana has a logical separation between the code and its data, which causes two types of accounts to exist — executable and non-executable accounts.

1. Executable accounts

Accounts that only store the immutable program code and are marked as ‘executables’.

2. Non-Executable accounts

These accounts store all the data that its program may use, including the variables, assets, and state of the program. Even though anyone can read the data in these accounts, only the owner of the program (the deployer) can change it.

The accounts are maintained by validator nodes that charge a maintenance cost called ’Rent’ in exchange for memory space for storing the information above. Rents are paid in lamports — the fractional denomination of SOL (Solana’s native token).

Solana’s code and program data are maintained separately due to a system known as Sealevel Parallel Runtime.

What is Sealevel Parallel Runtime?

Sealevel Parallel Runtime is Solana’s implementation of a parallel transaction processing system. Traditional single-threaded blockchains like Ethereum can process only one transaction at a time to avoid concurrency. This is because Ethereum smart contracts are stateful — meaning both the state and the code are coupled in the same contract.

With the help of Sealevel, Solana can process thousands of non-conflicting transactions in parallel. Utilizing multiple validator cores, Solana can also execute up to 50,000 Tps with a 400-millisecond block time. This is possible because transaction instructions are stateless, and they decide which account’s data they would modify beforehand. Thus, Programs that do not share the same account data can run simultaneously.

What are the types of programs in Solana?

Solana’s ecosystem constitutes two distinct types of programs — native programs and on-chain programs. Let's look at both of these.

What are native programs?

Native programs are responsible for implementing core functionalities of the Solana network, such as managing the allocation of account storage, creating new accounts, processing transactions, and enforcing the rules of the Solana network.

Native programs are an integral part of Solana’s core blockchain model. They are typically written in low-level languages like Rust and C/C++ that are optimized for performance and security. Native programs can be called by any program/user, whereas a Kernel-level program in your Operating system cannot be directly called and accessed by a user.

Updating these programs can only happen as a part of core blockchain upgrades or cluster upgrades to add features, fix bugs, or improve performance.

There are numerous native programs that help to secure the validator. Some of them are:

1. System Program

System programs are responsible for creating new accounts, transferring SOL between two accounts, assigning account ownership, and performing more such account management operations.

2. Berkeley Packet Filter (BPF): 

Berkeley Packet Filter handles the deployment, upgrades, and execution of programs on-chain.

3. Stake program

A Stake program is responsible for managing the staking of SOL tokens on the Solana blockchain.

What are on-chain programs?

On-chain programs are user-written programs (i.e. smart contracts) that are deployed directly on the blockchain. These can range from a dapp, an exchange, practice contracts, a multi-sig wallet implementation, or any other generic program.

Unlike Native programs, on-chain programs do not form the core of the Solana cluster. Instead, they are custom programs created and deployed by developers on the Solana blockchain. This means that on-chain programs are not essential in the operation of the Solana blockchain.

They are built on top of the core infrastructure provided by the Native programs and allow developers to build a wide range of applications and services on the Solana blockchain.

The data that the programs interact with are stored in separate data accounts and passed in as references via instructions. Only the account owner can upgrade the program data.

Programs in Solana

What is the Solana Program Library?

The Solana Program Library (SPL) is a collection of pre-written, modular programs that can be used to build decentralized applications (dapps) on the Solana blockchain. SPL aims to make it easier for developers to create dapps by providing a set of reusable, modular components that can be easily integrated into their applications, reducing the need for developers to write complex codes from scratch.

Therefore, SPL enables developers to build dapps using a "building block" approach, where each component can be easily integrated into the application.

The SPL contains multiple on-chain generic programs, the Token program, and its variations being the most popular. which can help incorporate them into your project without implementing them from scratch.

SPL prerequisites

To interact with SPL, you can choose between the CLI approach or the commonly used JS approach, which inculcates solana/web3.js for interacting your Javascript code with the Solana blockchain. 

To interact with any Solana cluster, you must also set up the Solana CLI (Command Line Interface). The CLI might not be the most friendly to use for novice developers, but it provides the most direct and secure access to your Solana accounts. Moreover, the CLI is the first place the Solana Core Developers deploy newer functionalities.

What is the SPL Token Program?

The SPL Token program is a generic implementation for fungible and non-fungible tokens on the Solana blockchain. It provides an interface and detailed implementation which allows developers to create their own token. The code is natively written in Rust, and its auto-generated bindings are available in C and JavaScript. The source code is available in the SPL GitHub repo.

In Ethereum, the ERC20 Token program works differently than an Ethereum ERC-20 contract. Let’s take an example to understand the difference:

Suppose you want to publish three different tokens on the Ethereum blockchain. To do so, you must deploy 3 separate contracts for each token. And every token contract will keep track of its respective state (e.g. balances and transfers).

When it comes to Solana, there is no need to deploy three separate token programs. Instead, you can deploy one generic token program that can operate on a multitude of accounts (e.g. minting and receiving accounts).

The mint address will uniquely identify the token type. This information can be passed as arguments to a singular static ERC20 program instance that is already deployed on the Solana chain.

How to Use SPL Token Program to Create A Fungible Token

With SPL Token Program, you can create your fungible token in a few steps. Before diving right into the Token program, make sure you have set up your CLI wallet, or connected your Phantom wallet to Solana's Devnet, and airdropped enough devnet SOL into your wallet.

Step 1: Create Your Fungible Token 

The create token command is an instruction to the on-chain SPL Token Program to create a new Token. On successful creation of the token, we will receive a Token ID along with the transaction signature. But yes, we still have to mint them.

This is the token command: spl-token create-token

Results from running the spl-token create-token command

Step 2: Create a Token Account

To store the information related to our token in a separate data account. The token account is owned by the SPL-Token Program, which controls the access to these tokens along with the owner field (which is our Token-ID that can spend/transfer the tokens). 

Since this is a data account, its data can be modified by the Token Program by adding/minting, transferring, or burning the tokens. 

This is the token account creation command: spl-token create-account <TOKEN-ID>

As you can see below, we lost some minimal SOL as transaction fees by creating our token and its associated account. Also, notice that the initial supply is zero. This means we have to add a desirable amount of supply by minting out tokens.

Balance after running an spl-token create-account command.

Step 3: Mint a Desirable Amount of Tokens.

To mint a given number of tokens, run the following command:

spl-token mint <TOKEN-ID> <AMOUNT>

Once the command is executed, the said number of tokens will be minted into your file system wallet, and the token supply will get updated. 

Results after minting 2,000 tokens.


You can check the current token supply and the account associated with the token by running the following command:

spl-token supply <TOKEN-ID>

spl-token accounts

 

Results from checking the spl-token supply and accounts balance.

Now, let’s transfer our tokens to our Phantom wallet — a popular wallet on Solana.

Step 4: Transfer Tokens 

The plan is to transfer ‘x’ amount of tokens to the recipient — our Phantom wallet. The ‘fund recipient is responsible for creating a token account for the recipient if it does not exist. This is called creating an Associated Token Account.

Here's the command to transfer tokens:

spl-token transfer --fund-recipient <TOKEN-ID> <TRANSFER AMOUNT> <RECIPIENT ADDRESS or RECIPIENT TOKEN ACCOUNT ADDRESS> 

Token transfer results.

You’ll receive a success message once the transfer is successful.

Phantom wallet transfer success message.

You can verify the transfer by running this command: spl-token accounts

Note: if you run the token supply command, it will still show 2,000 tokens because supply indicates the number of tokens in circulation in the network, whereas balance refers to the number of tokens that your token account has.

Token Balance vs. Token Supply

Step 5: Limit token supply

One of the crucial aspects of contract security and demand is to restrict token supply. To disable mint functionality, set the mint authority to ‘None’.

Command to disable the token mint authority: spl-token authorize <TOKEN-ID> mint --disable

Minting an extra 3000 tokens before minting is disabled.

Mint authority disabled results.

Step 6: Burn tokens

If you want to reduce the supply of a token, you can choose to burn it.

Here’s the command for it: spl-token burn <TOKEN-ACCOUNT ADDRESS> <AMOUNT>

Burning SPL Tokens

Once burned, both the supply, as well as balance, will get reduced. As you can see in the example, our balance dropped from 4,978 to 3,978, and the supply got reduced to 4,000.

SPL Token Burn Results

SPL provides a complete reference guide on how you can use the Token program to perform more operations like:

  • Wrapping SOL in a token.
  • Transferring tokens to an explicit recipient token account.
  • Creating a non-fungible token.

Kickstart Your Solana Development Journey with SPL

The Solana Program Library features a host of pre-published on-chain programs that can be easily interacted with. With SPL, developers can focus on the unique features and functionality of their dapps — rather than spending time on basic, boilerplate token creation code.

If you’re a beginner and want to get started with your Solana development journey, your first step is to explore SPL and Alchemy’s Solana API. and a free Solana RPC node account. These will help you get your program running in no time.

Solana is a high-speed programmable blockchain that allows developers to build and deploy decentralized applications. Solana maintains a dedicated documentation library known as the Solana Program Library – a collection of pre-compiled, deployed, and optimized programs (i.e. smart contracts) for use on the Solana blockchain.

In this article, we'll explore the world of Solana and understand how you can develop quickly with the Solana Program Library. Whether you are new to Solana or an experienced developer, you can easily create and deploy your own custom tokens or a decentralized exchange with SPL. 

What are programs in Solana?

Programs in Solana are executable code stored in buffer storage called an account that can be executed via transaction, similar to smart contracts on Ethereum or any other programmable blockchain. However, unlike Ethereum, where the program and state are stored together in the smart contracts, Solana has adopted a stateless program model approach where data and programs are stored in accounts.

What are accounts in Solana?

As per the Solana documentation, “An account is a record in the Solana ledger that either holds data or is an executable program.” 

Think of Solana as a database where accounts are rows, pub keys act as IDs, and the value is the information stored in the account. Now, this information can either be in the form of programs (i.e smart contracts) or data/state of the program.

Accounts can be identified by a unique Public Key (256 bytes), which typically looks something like: “DM6n1qcUCLzJ1RaAuA4gUbBZ9sfHP6KvEwX8oExQqPhk”.

Solana has a logical separation between the code and its data, which causes two types of accounts to exist — executable and non-executable accounts.

1. Executable accounts

Accounts that only store the immutable program code and are marked as ‘executables’.

2. Non-Executable accounts

These accounts store all the data that its program may use, including the variables, assets, and state of the program. Even though anyone can read the data in these accounts, only the owner of the program (the deployer) can change it.

The accounts are maintained by validator nodes that charge a maintenance cost called ’Rent’ in exchange for memory space for storing the information above. Rents are paid in lamports — the fractional denomination of SOL (Solana’s native token).

Solana’s code and program data are maintained separately due to a system known as Sealevel Parallel Runtime.

What is Sealevel Parallel Runtime?

Sealevel Parallel Runtime is Solana’s implementation of a parallel transaction processing system. Traditional single-threaded blockchains like Ethereum can process only one transaction at a time to avoid concurrency. This is because Ethereum smart contracts are stateful — meaning both the state and the code are coupled in the same contract.

With the help of Sealevel, Solana can process thousands of non-conflicting transactions in parallel. Utilizing multiple validator cores, Solana can also execute up to 50,000 Tps with a 400-millisecond block time. This is possible because transaction instructions are stateless, and they decide which account’s data they would modify beforehand. Thus, Programs that do not share the same account data can run simultaneously.

What are the types of programs in Solana?

Solana’s ecosystem constitutes two distinct types of programs — native programs and on-chain programs. Let's look at both of these.

What are native programs?

Native programs are responsible for implementing core functionalities of the Solana network, such as managing the allocation of account storage, creating new accounts, processing transactions, and enforcing the rules of the Solana network.

Native programs are an integral part of Solana’s core blockchain model. They are typically written in low-level languages like Rust and C/C++ that are optimized for performance and security. Native programs can be called by any program/user, whereas a Kernel-level program in your Operating system cannot be directly called and accessed by a user.

Updating these programs can only happen as a part of core blockchain upgrades or cluster upgrades to add features, fix bugs, or improve performance.

There are numerous native programs that help to secure the validator. Some of them are:

1. System Program

System programs are responsible for creating new accounts, transferring SOL between two accounts, assigning account ownership, and performing more such account management operations.

2. Berkeley Packet Filter (BPF): 

Berkeley Packet Filter handles the deployment, upgrades, and execution of programs on-chain.

3. Stake program

A Stake program is responsible for managing the staking of SOL tokens on the Solana blockchain.

What are on-chain programs?

On-chain programs are user-written programs (i.e. smart contracts) that are deployed directly on the blockchain. These can range from a dapp, an exchange, practice contracts, a multi-sig wallet implementation, or any other generic program.

Unlike Native programs, on-chain programs do not form the core of the Solana cluster. Instead, they are custom programs created and deployed by developers on the Solana blockchain. This means that on-chain programs are not essential in the operation of the Solana blockchain.

They are built on top of the core infrastructure provided by the Native programs and allow developers to build a wide range of applications and services on the Solana blockchain.

The data that the programs interact with are stored in separate data accounts and passed in as references via instructions. Only the account owner can upgrade the program data.

Programs in Solana

What is the Solana Program Library?

The Solana Program Library (SPL) is a collection of pre-written, modular programs that can be used to build decentralized applications (dapps) on the Solana blockchain. SPL aims to make it easier for developers to create dapps by providing a set of reusable, modular components that can be easily integrated into their applications, reducing the need for developers to write complex codes from scratch.

Therefore, SPL enables developers to build dapps using a "building block" approach, where each component can be easily integrated into the application.

The SPL contains multiple on-chain generic programs, the Token program, and its variations being the most popular. which can help incorporate them into your project without implementing them from scratch.

SPL prerequisites

To interact with SPL, you can choose between the CLI approach or the commonly used JS approach, which inculcates solana/web3.js for interacting your Javascript code with the Solana blockchain. 

To interact with any Solana cluster, you must also set up the Solana CLI (Command Line Interface). The CLI might not be the most friendly to use for novice developers, but it provides the most direct and secure access to your Solana accounts. Moreover, the CLI is the first place the Solana Core Developers deploy newer functionalities.

What is the SPL Token Program?

The SPL Token program is a generic implementation for fungible and non-fungible tokens on the Solana blockchain. It provides an interface and detailed implementation which allows developers to create their own token. The code is natively written in Rust, and its auto-generated bindings are available in C and JavaScript. The source code is available in the SPL GitHub repo.

In Ethereum, the ERC20 Token program works differently than an Ethereum ERC-20 contract. Let’s take an example to understand the difference:

Suppose you want to publish three different tokens on the Ethereum blockchain. To do so, you must deploy 3 separate contracts for each token. And every token contract will keep track of its respective state (e.g. balances and transfers).

When it comes to Solana, there is no need to deploy three separate token programs. Instead, you can deploy one generic token program that can operate on a multitude of accounts (e.g. minting and receiving accounts).

The mint address will uniquely identify the token type. This information can be passed as arguments to a singular static ERC20 program instance that is already deployed on the Solana chain.

How to Use SPL Token Program to Create A Fungible Token

With SPL Token Program, you can create your fungible token in a few steps. Before diving right into the Token program, make sure you have set up your CLI wallet, or connected your Phantom wallet to Solana's Devnet, and airdropped enough devnet SOL into your wallet.

Step 1: Create Your Fungible Token 

The create token command is an instruction to the on-chain SPL Token Program to create a new Token. On successful creation of the token, we will receive a Token ID along with the transaction signature. But yes, we still have to mint them.

This is the token command: spl-token create-token

Results from running the spl-token create-token command

Step 2: Create a Token Account

To store the information related to our token in a separate data account. The token account is owned by the SPL-Token Program, which controls the access to these tokens along with the owner field (which is our Token-ID that can spend/transfer the tokens). 

Since this is a data account, its data can be modified by the Token Program by adding/minting, transferring, or burning the tokens. 

This is the token account creation command: spl-token create-account <TOKEN-ID>

As you can see below, we lost some minimal SOL as transaction fees by creating our token and its associated account. Also, notice that the initial supply is zero. This means we have to add a desirable amount of supply by minting out tokens.

Balance after running an spl-token create-account command.

Step 3: Mint a Desirable Amount of Tokens.

To mint a given number of tokens, run the following command:

spl-token mint <TOKEN-ID> <AMOUNT>

Once the command is executed, the said number of tokens will be minted into your file system wallet, and the token supply will get updated. 

Results after minting 2,000 tokens.


You can check the current token supply and the account associated with the token by running the following command:

spl-token supply <TOKEN-ID>

spl-token accounts

 

Results from checking the spl-token supply and accounts balance.

Now, let’s transfer our tokens to our Phantom wallet — a popular wallet on Solana.

Step 4: Transfer Tokens 

The plan is to transfer ‘x’ amount of tokens to the recipient — our Phantom wallet. The ‘fund recipient is responsible for creating a token account for the recipient if it does not exist. This is called creating an Associated Token Account.

Here's the command to transfer tokens:

spl-token transfer --fund-recipient <TOKEN-ID> <TRANSFER AMOUNT> <RECIPIENT ADDRESS or RECIPIENT TOKEN ACCOUNT ADDRESS> 

Token transfer results.

You’ll receive a success message once the transfer is successful.

Phantom wallet transfer success message.

You can verify the transfer by running this command: spl-token accounts

Note: if you run the token supply command, it will still show 2,000 tokens because supply indicates the number of tokens in circulation in the network, whereas balance refers to the number of tokens that your token account has.

Token Balance vs. Token Supply

Step 5: Limit token supply

One of the crucial aspects of contract security and demand is to restrict token supply. To disable mint functionality, set the mint authority to ‘None’.

Command to disable the token mint authority: spl-token authorize <TOKEN-ID> mint --disable

Minting an extra 3000 tokens before minting is disabled.

Mint authority disabled results.

Step 6: Burn tokens

If you want to reduce the supply of a token, you can choose to burn it.

Here’s the command for it: spl-token burn <TOKEN-ACCOUNT ADDRESS> <AMOUNT>

Burning SPL Tokens

Once burned, both the supply, as well as balance, will get reduced. As you can see in the example, our balance dropped from 4,978 to 3,978, and the supply got reduced to 4,000.

SPL Token Burn Results

SPL provides a complete reference guide on how you can use the Token program to perform more operations like:

  • Wrapping SOL in a token.
  • Transferring tokens to an explicit recipient token account.
  • Creating a non-fungible token.

Kickstart Your Solana Development Journey with SPL

The Solana Program Library features a host of pre-published on-chain programs that can be easily interacted with. With SPL, developers can focus on the unique features and functionality of their dapps — rather than spending time on basic, boilerplate token creation code.

If you’re a beginner and want to get started with your Solana development journey, your first step is to explore SPL and Alchemy’s Solana API. and a free Solana RPC node account. These will help you get your program running in no time.

{{get-started-solana}}

Contact Us

Talk to an expert at Alchemy to answer all of your product questions.
Valid number
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Build blockchain magic with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get started for free