Interact with Solana from the Internet Computer.
Note
This project is a work in progress and is not yet ready for production use. We are happy to answer questions if they are raised as issues in this GitHub repo.
IC-Solana is a solution that bridges Solana with the Internet Computer. It allows developers to build decentralized applications (dApps) on the Internet Computer with functionality comparable to traditional Solana dApps. This integration combines the capabilities of both blockchain networks, making it easier to develop cross-chain applications and expand the possibilities for decentralized solutions.
Add the following configuration to your dfx.json
file (replace the
ic
principal with any option from the list of available canisters):
{
"canisters": {
"solana_rpc": {
"type": "custom",
"candid": "https://github.com/mfactory-lab/ic-solana/blob/main/src/ic-solana-rpc/ic-solana-rpc.did",
"wasm": "https://github.com/mfactory-lab/ic-solana/blob/main/ic-solana-rpc.wasm.gz",
"init_arg": "(record {})"
},
"solana_wallet": {
"type": "custom",
"candid": "https://github.com/mfactory-lab/ic-solana/blob/main/src/ic-solana-wallet/ic-solana-wallet.did",
"wasm": "https://github.com/mfactory-lab/ic-solana/blob/main/ic-solana-wallet.wasm.gz",
"init_arg": "(record {})"
}
}
}
Make sure you have the following installed:
- Rust
- Docker (Optional for reproducible builds)
- PocketIC (Optional for testing)
- DFINITY SDK
Start a local replica listening on port 4943:
# Start a local replica
dfx start --clean --host 127.0.0.1:4943
Build and deploy canisters:
# Deploy the `solana_rpc` canister locally
dfx deploy solana_rpc --argument '(record {})'
# Deploy the `solana_wallet` canister locally
dfx deploy solana_wallet --argument '(record {})'
All the canisters will be deployed to the local
network with their fixed canister ids.
Once the build and deployment are complete, your application will be accessible at:
http://localhost:4943?canisterId={asset_canister_id}
Replace {asset_canister_id}
with the actual canister's ID generated during deployment.
# Use Solana mainnet cluster
dfx canister call solana_rpc sol_getHealth '(variant{Mainnet},null)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
# Use Solana devnet cluster
dfx canister call solana_rpc sol_getHealth '(variant{Devnet},null)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
# Use single custom RPC
dfx canister call solana_rpc sol_getHealth '(variant{Custom=vec{record{network="https://mainnet.helius-rpc.com/"}}},null)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
# Use multiple custom RPCs
dfx canister call solana_rpc sol_getHealth '(variant{Custom=vec{record{network="mainnet"},record{network="https://mainnet.helius-rpc.com/"}}},null)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
# Use single provider RPC (predefined providers: mainnet|m, devnet|d, testnet|t)
dfx canister call solana_rpc sol_getHealth '(variant{Provider=vec{"mainnet"}},null)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
The RPC Canister enables communication with the Solana blockchain, using HTTPS outcalls to transmit raw transactions and messages via on-chain APIs of Solana JSON RPC providers, for example, Helius or Quicknode.
Key functionalities include:
- Retrieving Solana-specific data, such as block details, account information, node statistics, etc.
- Managing Solana RPC providers, including registration, updates, and provider configurations.
- Calculating and managing the cost of RPC requests.
The Wallet Canister is used for managing addresses and for securely signing transactions/messages for the Solana blockchain using the threshold Schnorr API.
Key functionalities include:
- Generating a Solana public key (Ed25519) for a user on the Internet Computer (ICP).
- Signing messages using distributed keys based on the
Threshold Schnorr
protocol. - Signing and sending raw transactions to the Solana blockchain via the RPC Canister.
A Rust library that provides the necessary tools for integrating Solana with ICP canisters.
The Solana RPC canister stores a list of registered Solana JSON RPC providers, to which transactions and messages can be submitted. Access to the list is controlled by admin(s) who can assign managers with specific rights to add, remove, and update Solana JSON RPC providers.
The SOLANA RPC canister supports reproducible builds:
- Ensure Docker is installed on your machine.
- Run
./scripts/docker-build --rpc
in your terminal. - Run
sha256sum ic-solana-rpc.wasm.gz
on the generated file to view the SHA-256 hash.
Compare the generated SHA-256 hash with the hash provided in the repository to verify the build's integrity.
To learn more about the SOLANA RPC Canister and its integration with Solana and ICP, explore the following resources:
- Candid Interface
- Solana JSON RPC API
- Internet Computer Developer Docs
- DFINITY SDK Documentation
- Internet Computer HTTPS Outcalls
Contributions are welcome! Please check out the contributor guidelines for more information.
This project is licensed under the Apache License 2.0.