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
SOLANA CPI OVERVIEW

What are cross-program invocations (CPIs) on Solana?

Learn What Cross-Program Invocations Are, How They Work, and Common Use Cases
Last Updated:
January 25, 2023
Table of Contents
Table of Contents
Table of Contents

{{get-started-solana}}

Runtime cross-program invocation on Solana enables more efficient and flexible program development, making it a key feature of the platform. Cross Program Invocations (CPIs) refer to the ability of a program on the Solana blockchain to call another program and execute its code.

This article will help you understand what cross program invocations on Solana are, their specific use cases, and how you can use them in your Solana programs.

What are cross-program invocations (CPIs)?

In a runtime cross-program invocation, a program on Solana can call another program and pass data to it, allowing for the creation of complex and modular smart contract systems.

The Solana runtime provides a secure and decentralized environment for executing these cross-program invocations. Solana’s runtime ensures that the called program is executed correctly and that the results are returned to the calling program in a verifiable manner. This allows for the creation of trustless and decentralized applications on the Solana blockchain.

What are use cases of cross-program invocations?

Cross-program invocations enable a wide range of use cases on the Solana blockchain, such as multisig transactions, token transfers, state channels, interoperability between dapps, new transaction types, and sharing common functionality. 

1. Multi-signature (Multisig) Transactions

A multi-signature program is where multiple parties must sign a transaction before it is executed on the blockchain. With cross-program invocations, the multisig program can be invoked by other programs to check if a transaction has the required number of signatures before it is processed.

2. Token Transfers

Solana has token programs and accounts for all transactions related to a token. These token programs can be invoked by other programs to transfer tokens from one account to another, allowing for the creation of applications like decentralized exchanges.

3. State Channels

Solana programs can be used to implement state channels, that allow off-chain transactions that are settled on-chain. For example, a program can be used to implement a state channel for a simple blockchain game, where the state program can be invoked by other programs when players make moves and then settle the final state on-chain.

4. Interoperability Between dapps

Cross-program invocations enable dapps to communicate with each other and share data, allowing for more seamless interactions between different dapps on the Solana network.

5. Sharing of Common Functionality

Dapps can use cross-program invocations to share common functionality, such as cryptographic functions or data storage. This can reduce the amount of code that each dapp needs to implement, and can make it easier to build dapps on Solana.

6. Enabling New Transaction Types

Cross-program invocations enable new types of interactions between dapps, such as the ability for one dapp to request data from another dapp or trigger an action in another dapp.

Whether you want to enforce complex business logic that involves multiple programs such as in decentralized exchanges, create multi-sig wallets that require multiple signatures from different programs, or build for scale with composable, reusable programs, implementing cross-program invocations is the best approach.

What are some examples of cross-program invocations?

Cross-program invocations can be used in a variety of ways including a multi-sig wallet, NFT marketplace and modular programs.

1. Solana Multisig Wallet

Using cross-program invocations, we can create a multi-sig wallet like Snowflake that requires two signatures to execute a transaction. This can be done by creating two programs: one for each signature.

When a transaction is initiated, the first program verifies the 1st signature, calls the second program to verify the 2nd signature, and if both signatures are valid, the transaction is executed.

2. Solana NFT Marketplace

Cross-program invocations also help in the development of Solana NFT marketplaces for buying and selling non-fungible tokens (NFTs). Developers can accomplish this by creating a program for managing the marketplace, and separate programs for each type of NFT that is traded on the marketplace. The marketplace program can call the appropriate NFT program to verify the uniqueness and ownership of the NFT, and then execute the trade if everything is valid.

3. Modular Programs

Cross-program invocations directly help in creating a complex program that involves multiple steps and interactions. This is done by creating multiple programs, each handling a specific step or aspect of the contract. The main contract program can then call the other programs as needed to execute the various steps of the contract.

How to Run Cross-Program Invocations

Building runtime cross-program invocation on Solana would involve the following steps: writing, compiling, deploying, and invoking.

Step 1: Write Your Solana Programs

First, you would need to write the programs that you want to be able to invoke each other. These programs can be written in any native Rust, using the Anchor framework, or in Python using the Seahorse framework.

Step 2: Compile Your Programs to Wasm

Once you have written the programs, you will need to compile them to Wasm using a suitable compiler. This will produce a Wasm binary that can be executed by the Solana runtime.

Step 3: Deploy Your Programs to Solana

Next, you need to deploy the compiled Wasm binaries to the Solana blockchain. This can be done using the solana-deploy command-line tool, which is provided as part of the Solana software development kit (SDK).

Step 4: Write Transactions to Invoke Your Programs

After deploying the programs, you can use the Solana SDK to write a transaction that invokes one of the programs and pass data to it. This transaction would be submitted to the Solana blockchain, where it would be verified and executed by the runtime environment.

When the called program is executed, it can perform any computation that is possible within the Wasm runtime, including calling other programs. The results of the computation can be returned to the calling program and stored on the Solana blockchain.

Overall, building runtime cross-program invocations on Solana involves writing programs, compiling them to Wasm, deploying them to the blockchain, and using the Solana SDK to invoke and pass data between them. This allows for the creation of complex and modular smart contract systems on the Solana platform.

Note: the Solana program rent fees would vary based on how many programs are present.

Simple Example of the Implementation

As an example, suppose you have two programs in Solana, program1, and program2, and you want to invoke the function process_data in program1 from program2

Here is how you could do this:

In program1, add a new function process_data_interface that takes the input data as a parameter and returns the output data:


fn process_data_interface(input: &[u8]) -> Vec {
    let output = process_data(input);
    return output;
}

In program2, add code to invoke process_data_interface in program1, passing the input data and receiving the output data:

 
let input = ...;  // obtain input data
let output = program1::process_data_interface(&input);

You can then use the output data in program2 as needed.

Note: this is just a simple example, and the exact implementation will depend on the specific programs and functions that you are working with. You may need to add additional code to handle errors, ensure proper authorization, etc.

Get Started with Solana Runtime Cross Program Invocations

Solana has a key feature called runtime Cross Program Invocations that allows smart contracts running on its platform to invoke other programs in a secure and decentralized manner. In Solana, every program has a unique address on the blockchain, and CPIs are achieved by calling the address of the program that you want to execute. This allows programs to interact with each other and enables complex program functionality on the Solana blockchain. 

Overall, Solana runtime CPIs are an important part of the Solana developer skill set, as they allow for the creation of complex and powerful decentralized applications.

If you want to get started on your journey with Solana development and CPIs, sign up for an Alchemy account today!

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
SOLANA CPI OVERVIEW

What are cross-program invocations on Solana?

Learn What Cross-Program Invocations Are, How They Work, and Common Use Cases
Last Updated:
January 25, 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

Runtime cross-program invocation on Solana enables more efficient and flexible program development, making it a key feature of the platform. Cross Program Invocations (CPIs) refer to the ability of a program on the Solana blockchain to call another program and execute its code.

This article will help you understand what cross program invocations on Solana are, their specific use cases, and how you can use them in your Solana programs.

What are cross-program invocations (CPIs)?

In a runtime cross-program invocation, a program on Solana can call another program and pass data to it, allowing for the creation of complex and modular smart contract systems.

The Solana runtime provides a secure and decentralized environment for executing these cross-program invocations. Solana’s runtime ensures that the called program is executed correctly and that the results are returned to the calling program in a verifiable manner. This allows for the creation of trustless and decentralized applications on the Solana blockchain.

What are use cases of cross-program invocations?

Cross-program invocations enable a wide range of use cases on the Solana blockchain, such as multisig transactions, token transfers, state channels, interoperability between dapps, new transaction types, and sharing common functionality. 

1. Multi-signature (Multisig) Transactions

A multi-signature program is where multiple parties must sign a transaction before it is executed on the blockchain. With cross-program invocations, the multisig program can be invoked by other programs to check if a transaction has the required number of signatures before it is processed.

2. Token Transfers

Solana has token programs and accounts for all transactions related to a token. These token programs can be invoked by other programs to transfer tokens from one account to another, allowing for the creation of applications like decentralized exchanges.

3. State Channels

Solana programs can be used to implement state channels, that allow off-chain transactions that are settled on-chain. For example, a program can be used to implement a state channel for a simple blockchain game, where the state program can be invoked by other programs when players make moves and then settle the final state on-chain.

4. Interoperability Between dapps

Cross-program invocations enable dapps to communicate with each other and share data, allowing for more seamless interactions between different dapps on the Solana network.

5. Sharing of Common Functionality

Dapps can use cross-program invocations to share common functionality, such as cryptographic functions or data storage. This can reduce the amount of code that each dapp needs to implement, and can make it easier to build dapps on Solana.

6. Enabling New Transaction Types

Cross-program invocations enable new types of interactions between dapps, such as the ability for one dapp to request data from another dapp or trigger an action in another dapp.

Whether you want to enforce complex business logic that involves multiple programs such as in decentralized exchanges, create multi-sig wallets that require multiple signatures from different programs, or build for scale with composable, reusable programs, implementing cross-program invocations is the best approach.

What are some examples of cross-program invocations?

Cross-program invocations can be used in a variety of ways including a multi-sig wallet, NFT marketplace and modular programs.

1. Solana Multisig Wallet

Using cross-program invocations, we can create a multi-sig wallet like Snowflake that requires two signatures to execute a transaction. This can be done by creating two programs: one for each signature.

When a transaction is initiated, the first program verifies the 1st signature, calls the second program to verify the 2nd signature, and if both signatures are valid, the transaction is executed.

2. Solana NFT Marketplace

Cross-program invocations also help in the development of Solana NFT marketplaces for buying and selling non-fungible tokens (NFTs). Developers can accomplish this by creating a program for managing the marketplace, and separate programs for each type of NFT that is traded on the marketplace. The marketplace program can call the appropriate NFT program to verify the uniqueness and ownership of the NFT, and then execute the trade if everything is valid.

3. Modular Programs

Cross-program invocations directly help in creating a complex program that involves multiple steps and interactions. This is done by creating multiple programs, each handling a specific step or aspect of the contract. The main contract program can then call the other programs as needed to execute the various steps of the contract.

How to Run Cross-Program Invocations

Building runtime cross-program invocation on Solana would involve the following steps: writing, compiling, deploying, and invoking.

Step 1: Write Your Solana Programs

First, you would need to write the programs that you want to be able to invoke each other. These programs can be written in any native Rust, using the Anchor framework, or in Python using the Seahorse framework.

Step 2: Compile Your Programs to Wasm

Once you have written the programs, you will need to compile them to Wasm using a suitable compiler. This will produce a Wasm binary that can be executed by the Solana runtime.

Step 3: Deploy Your Programs to Solana

Next, you need to deploy the compiled Wasm binaries to the Solana blockchain. This can be done using the solana-deploy command-line tool, which is provided as part of the Solana software development kit (SDK).

Step 4: Write Transactions to Invoke Your Programs

After deploying the programs, you can use the Solana SDK to write a transaction that invokes one of the programs and pass data to it. This transaction would be submitted to the Solana blockchain, where it would be verified and executed by the runtime environment.

When the called program is executed, it can perform any computation that is possible within the Wasm runtime, including calling other programs. The results of the computation can be returned to the calling program and stored on the Solana blockchain.

Overall, building runtime cross-program invocations on Solana involves writing programs, compiling them to Wasm, deploying them to the blockchain, and using the Solana SDK to invoke and pass data between them. This allows for the creation of complex and modular smart contract systems on the Solana platform.

Note: the Solana program rent fees would vary based on how many programs are present.

Simple Example of the Implementation

As an example, suppose you have two programs in Solana, program1, and program2, and you want to invoke the function process_data in program1 from program2

Here is how you could do this:

In program1, add a new function process_data_interface that takes the input data as a parameter and returns the output data:


fn process_data_interface(input: &[u8]) -> Vec {
    let output = process_data(input);
    return output;
}

In program2, add code to invoke process_data_interface in program1, passing the input data and receiving the output data:

 
let input = ...;  // obtain input data
let output = program1::process_data_interface(&input);

You can then use the output data in program2 as needed.

Note: this is just a simple example, and the exact implementation will depend on the specific programs and functions that you are working with. You may need to add additional code to handle errors, ensure proper authorization, etc.

Get Started with Solana Runtime Cross Program Invocations

Solana has a key feature called runtime Cross Program Invocations that allows smart contracts running on its platform to invoke other programs in a secure and decentralized manner. In Solana, every program has a unique address on the blockchain, and CPIs are achieved by calling the address of the program that you want to execute. This allows programs to interact with each other and enables complex program functionality on the Solana blockchain. 

Overall, Solana runtime CPIs are an important part of the Solana developer skill set, as they allow for the creation of complex and powerful decentralized applications.

If you want to get started on your journey with Solana development and CPIs, sign up for an Alchemy account today!

Runtime cross-program invocation on Solana enables more efficient and flexible program development, making it a key feature of the platform. Cross Program Invocations (CPIs) refer to the ability of a program on the Solana blockchain to call another program and execute its code.

This article will help you understand what cross program invocations on Solana are, their specific use cases, and how you can use them in your Solana programs.

What are cross-program invocations (CPIs)?

In a runtime cross-program invocation, a program on Solana can call another program and pass data to it, allowing for the creation of complex and modular smart contract systems.

The Solana runtime provides a secure and decentralized environment for executing these cross-program invocations. Solana’s runtime ensures that the called program is executed correctly and that the results are returned to the calling program in a verifiable manner. This allows for the creation of trustless and decentralized applications on the Solana blockchain.

What are use cases of cross-program invocations?

Cross-program invocations enable a wide range of use cases on the Solana blockchain, such as multisig transactions, token transfers, state channels, interoperability between dapps, new transaction types, and sharing common functionality. 

1. Multi-signature (Multisig) Transactions

A multi-signature program is where multiple parties must sign a transaction before it is executed on the blockchain. With cross-program invocations, the multisig program can be invoked by other programs to check if a transaction has the required number of signatures before it is processed.

2. Token Transfers

Solana has token programs and accounts for all transactions related to a token. These token programs can be invoked by other programs to transfer tokens from one account to another, allowing for the creation of applications like decentralized exchanges.

3. State Channels

Solana programs can be used to implement state channels, that allow off-chain transactions that are settled on-chain. For example, a program can be used to implement a state channel for a simple blockchain game, where the state program can be invoked by other programs when players make moves and then settle the final state on-chain.

4. Interoperability Between dapps

Cross-program invocations enable dapps to communicate with each other and share data, allowing for more seamless interactions between different dapps on the Solana network.

5. Sharing of Common Functionality

Dapps can use cross-program invocations to share common functionality, such as cryptographic functions or data storage. This can reduce the amount of code that each dapp needs to implement, and can make it easier to build dapps on Solana.

6. Enabling New Transaction Types

Cross-program invocations enable new types of interactions between dapps, such as the ability for one dapp to request data from another dapp or trigger an action in another dapp.

Whether you want to enforce complex business logic that involves multiple programs such as in decentralized exchanges, create multi-sig wallets that require multiple signatures from different programs, or build for scale with composable, reusable programs, implementing cross-program invocations is the best approach.

What are some examples of cross-program invocations?

Cross-program invocations can be used in a variety of ways including a multi-sig wallet, NFT marketplace and modular programs.

1. Solana Multisig Wallet

Using cross-program invocations, we can create a multi-sig wallet like Snowflake that requires two signatures to execute a transaction. This can be done by creating two programs: one for each signature.

When a transaction is initiated, the first program verifies the 1st signature, calls the second program to verify the 2nd signature, and if both signatures are valid, the transaction is executed.

2. Solana NFT Marketplace

Cross-program invocations also help in the development of Solana NFT marketplaces for buying and selling non-fungible tokens (NFTs). Developers can accomplish this by creating a program for managing the marketplace, and separate programs for each type of NFT that is traded on the marketplace. The marketplace program can call the appropriate NFT program to verify the uniqueness and ownership of the NFT, and then execute the trade if everything is valid.

3. Modular Programs

Cross-program invocations directly help in creating a complex program that involves multiple steps and interactions. This is done by creating multiple programs, each handling a specific step or aspect of the contract. The main contract program can then call the other programs as needed to execute the various steps of the contract.

How to Run Cross-Program Invocations

Building runtime cross-program invocation on Solana would involve the following steps: writing, compiling, deploying, and invoking.

Step 1: Write Your Solana Programs

First, you would need to write the programs that you want to be able to invoke each other. These programs can be written in any native Rust, using the Anchor framework, or in Python using the Seahorse framework.

Step 2: Compile Your Programs to Wasm

Once you have written the programs, you will need to compile them to Wasm using a suitable compiler. This will produce a Wasm binary that can be executed by the Solana runtime.

Step 3: Deploy Your Programs to Solana

Next, you need to deploy the compiled Wasm binaries to the Solana blockchain. This can be done using the solana-deploy command-line tool, which is provided as part of the Solana software development kit (SDK).

Step 4: Write Transactions to Invoke Your Programs

After deploying the programs, you can use the Solana SDK to write a transaction that invokes one of the programs and pass data to it. This transaction would be submitted to the Solana blockchain, where it would be verified and executed by the runtime environment.

When the called program is executed, it can perform any computation that is possible within the Wasm runtime, including calling other programs. The results of the computation can be returned to the calling program and stored on the Solana blockchain.

Overall, building runtime cross-program invocations on Solana involves writing programs, compiling them to Wasm, deploying them to the blockchain, and using the Solana SDK to invoke and pass data between them. This allows for the creation of complex and modular smart contract systems on the Solana platform.

Note: the Solana program rent fees would vary based on how many programs are present.

Simple Example of the Implementation

As an example, suppose you have two programs in Solana, program1, and program2, and you want to invoke the function process_data in program1 from program2

Here is how you could do this:

In program1, add a new function process_data_interface that takes the input data as a parameter and returns the output data:


fn process_data_interface(input: &[u8]) -> Vec {
    let output = process_data(input);
    return output;
}

In program2, add code to invoke process_data_interface in program1, passing the input data and receiving the output data:

 
let input = ...;  // obtain input data
let output = program1::process_data_interface(&input);

You can then use the output data in program2 as needed.

Note: this is just a simple example, and the exact implementation will depend on the specific programs and functions that you are working with. You may need to add additional code to handle errors, ensure proper authorization, etc.

Get Started with Solana Runtime Cross Program Invocations

Solana has a key feature called runtime Cross Program Invocations that allows smart contracts running on its platform to invoke other programs in a secure and decentralized manner. In Solana, every program has a unique address on the blockchain, and CPIs are achieved by calling the address of the program that you want to execute. This allows programs to interact with each other and enables complex program functionality on the Solana blockchain. 

Overall, Solana runtime CPIs are an important part of the Solana developer skill set, as they allow for the creation of complex and powerful decentralized applications.

If you want to get started on your journey with Solana development and CPIs, sign up for an Alchemy account today!

{{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