Setting Up Your Development Environment

To begin, ensure your development environment is set up with the necessary tools and libraries:

  1. Rust
  2. Solana CLI

Initialize Your Project

Create a new Rust project where you will integrate the Devol Accounts Kit:

cargo new devol_integration
cd devol_integration

Add Dependencies

Open your Cargo.toml file and add the necessary dependencies for working with the Solana blockchain and the Devol Accounts Kit:

[dependencies]
devol-accounts-kit = "0.2.5"

Sample Code to Interact with Devol Smart Contracts

Below is a basic example to set up your client and interact with the Devol smart contracts:

// Required imports
use std::str::FromStr;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use devol_accounts_kit::dvl_client::dvl_client::DvlClient;
use devol_accounts_kit::accounts::root::root_account::RootAccount;
use tokio;

#[tokio::main]
async fn main() {
    let rpc_url = String::from("https://api.mainnet-beta.solana.com/");
    let rpc_client = RpcClient::new(rpc_url);

    let admin_pub_key = match Pubkey::from_str("ADMIN_PUBLIC_KEY") {
        Ok(key) => key,
        Err(e) => {
            eprintln!("Failed to parse admin public key: {}", e);
            return;
        }
    };

    let program_id = match Pubkey::from_str("PROGRAM_ID") {
        Ok(id) => id,
        Err(e) => {
            eprintln!("Failed to parse program ID: {}", e);
            return;
        }
    };

    let reader = DvlClient::new(rpc_client, 1, admin_pub_key, program_id);

    match reader.get_account::<RootAccount>(()).await {
        Ok(root_account) => println!("Root Account: {:?}", root_account),
        Err(e) => eprintln!("Failed to fetch the RootAccount: {}", e),
    };
}

Run Your Application

To run your application and see the output:

cargo run

This simple setup will help you start interacting with the Devol smart contract and explore more complex transactions and interactions as you progress in your development.