Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ hex = "0.4"
rand = "0.8"
async-trait = "0.1"
url = "2"
bs58 = { version = "0.5", optional = true }
solana-sdk = { version = "2", optional = true }
solana-client = { version = "2", optional = true }
spl-token = { version = "7", optional = true }

[features]
default = []
solana = ["bs58", "solana-sdk", "solana-client", "spl-token"]

[dev-dependencies]
tokio-test = "0.4"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async fn main() -> Result<()> {

## Features

- **Multi-chain** — EVM (Ethereum, Arbitrum, Optimism, Base, Avalanche, Tempo) from one agent. Solana and Cosmos planned.
- **Multi-chain** — EVM (Ethereum, Arbitrum, Optimism, Base, Avalanche, Tempo) and Solana from one agent. Cosmos planned.
- **Wallet management** — Generate, import, derive. Sign transactions. Manage multiple wallets.
- **DEX interaction** — Swap, add/remove liquidity, read pool state. Uniswap V3, Aerodrome, Trader Joe.
- **MPP payments** — Native support for Machine Payments Protocol. Agent pays for APIs, services, compute.
Expand All @@ -84,7 +84,7 @@ async fn main() -> Result<()> {
| `arka::dex` | 🚧 WIP | DEX swap execution, routing |
| `arka::mpp` | 🚧 WIP | Machine Payments Protocol client |
| `arka::oracle` | 🚧 WIP | Price feeds, TWAP |
| `arka::solana` | 📋 Planned | Solana chain connector |
| `arka::solana` | ✅ MVP | Solana chain connector, balance, transfer |
| `arka::cosmos` | 📋 Planned | Cosmos chain connector |

## Quick Start
Expand Down
29 changes: 25 additions & 4 deletions examples/multi_chain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
//! Multi-chain example — same wallet across Base, Arbitrum, and Optimism.
//! Multi-chain example — same wallet across EVM chains + Solana.
//!
//! Run with:
//! cargo run --example multi_chain
//! cargo run --example multi_chain --features solana

use arka::prelude::*;

Expand All @@ -7,11 +11,11 @@ async fn main() -> Result<()> {
tracing_subscriber::fmt::init();

let wallet = Wallet::generate()?;
println!("Wallet: {:?}\n", wallet.address());
println!("EVM Wallet: {:?}\n", wallet.address());

let chains = [Chain::Base, Chain::Arbitrum, Chain::Optimism, Chain::Tempo];
let evm_chains = [Chain::Base, Chain::Arbitrum, Chain::Optimism, Chain::Tempo];

for chain in chains {
for chain in evm_chains {
let agent = Agent::builder()
.chain(chain)
.wallet(wallet.clone())
Expand All @@ -34,5 +38,22 @@ async fn main() -> Result<()> {
);
}

#[cfg(feature = "solana")]
{
use arka::chains::solana::{SolanaConnector, SolanaWallet};
println!("\n--- Solana ---");
let sol_wallet = SolanaWallet::generate();
println!("Solana Wallet: {}", sol_wallet.address());

let connector = SolanaConnector::new("https://api.devnet.solana.com")
.expect("Solana connector");
let block = connector.block_height().unwrap_or(0);
println!(
"{:12} | block: {:>10} | balance: N/A (RPC required) | gas: native",
Chain::SolanaDevnet,
block,
);
}

Ok(())
}
21 changes: 19 additions & 2 deletions src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ pub enum Chain {
Bsc,
Tempo,
TempoTestnet,
/// Solana mainnet — uses ed25519 keypairs and a very different tx model.
/// Supported behind the ``solana`` feature flag.
Solana,
/// Solana devnet.
SolanaDevnet,
}

impl Chain {
/// Chain ID for EVM networks.
/// Chain ID. For EVM chains this is the EIP-155 chain ID; for non-EVM chains
/// (e.g. Solana) this returns 0 and is semantically meaningless.
pub fn chain_id(&self) -> u64 {
match self {
Chain::Ethereum => 1,
Expand All @@ -33,6 +39,7 @@ impl Chain {
Chain::Bsc => 56,
Chain::Tempo => 4217,
Chain::TempoTestnet => 42429,
Chain::Solana | Chain::SolanaDevnet => 0,
}
}

Expand All @@ -48,6 +55,8 @@ impl Chain {
Chain::Bsc => "https://bsc-dataseed.binance.org",
Chain::Tempo => "https://rpc.tempo.xyz",
Chain::TempoTestnet => "https://rpc.testnet.tempo.xyz",
Chain::Solana => "https://api.mainnet-beta.solana.com",
Chain::SolanaDevnet => "https://api.devnet.solana.com",
}
}

Expand All @@ -58,7 +67,8 @@ impl Chain {
Chain::Avalanche => "AVAX",
Chain::Polygon => "MATIC",
Chain::Bsc => "BNB",
Chain::Tempo | Chain::TempoTestnet => "USDC", // Tempo has no native gas token
Chain::Tempo | Chain::TempoTestnet => "USDC",
Chain::Solana | Chain::SolanaDevnet => "SOL",
}
}

Expand All @@ -67,6 +77,11 @@ impl Chain {
matches!(self, Chain::Tempo | Chain::TempoTestnet)
}

/// Whether this chain is Solana-based (non-EVM).
pub fn is_solana(&self) -> bool {
matches!(self, Chain::Solana | Chain::SolanaDevnet)
}

/// Block explorer base URL.
pub fn explorer(&self) -> &'static str {
match self {
Expand All @@ -79,6 +94,8 @@ impl Chain {
Chain::Bsc => "https://bscscan.com",
Chain::Tempo => "https://explorer.tempo.xyz",
Chain::TempoTestnet => "https://explorer.testnet.tempo.xyz",
Chain::Solana => "https://solscan.io",
Chain::SolanaDevnet => "https://solscan.io/?cluster=devnet",
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/chains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
//! deployments arka is designed to support.

pub mod arbitrum;

#[cfg(feature = "solana")]
pub mod solana;
Loading