Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Native Framework (solana-program)

Pre-Alpha Disclaimer: This is an early pre-alpha release for exploring the SDK and starting development only. There is no real MPC signing — all signatures are generated by a single mock signer, not a distributed network. Do not submit any real transactions for signing or rely on any security guarantees. The dWallet keys, trust model, and signing protocol are not final; do not rely on any key material until mainnet. All interfaces, APIs, and data formats are subject to change without notice. The Solana program and all on-chain data will be wiped periodically and everything will be deleted when we transition to Ika Alpha 1. This software is provided “as is” without warranty of any kind; use is entirely at your own risk and dWallet Labs assumes no liability for any damages arising from its use.

The ika-dwallet-native crate provides a CPI SDK using Solana’s standard solana-program crate. No framework lock-in — just raw AccountInfo and invoke_signed.

Dependencies

[dependencies]
ika-dwallet-native = { git = "https://github.com/dwallet-labs/ika-pre-alpha" }
solana-program = "2.2"
solana-system-interface = "1"

[lib]
crate-type = ["cdylib", "lib"]

DWalletContext

#![allow(unused)]
fn main() {
use ika_dwallet_native::DWalletContext;

let ctx = DWalletContext {
    dwallet_program: &accounts.dwallet_program,
    cpi_authority: &accounts.cpi_authority,
    caller_program: &accounts.program,
    cpi_authority_bump: bump,
};
}
FieldTypeDescription
dwallet_program&AccountInfo<'info>The dWallet program account
cpi_authority&AccountInfo<'info>Your program’s CPI authority PDA
caller_program&AccountInfo<'info>Your program’s account (must be executable)
cpi_authority_bumpu8Bump seed for the CPI authority PDA

CPI Authority PDA

#![allow(unused)]
fn main() {
use ika_dwallet_native::CPI_AUTHORITY_SEED;
use solana_program::pubkey::Pubkey;

let (cpi_authority, bump) = Pubkey::find_program_address(
    &[CPI_AUTHORITY_SEED],
    &your_program_id,
);
}

Methods

approve_message

#![allow(unused)]
fn main() {
ctx.approve_message(
    &message_approval,  // &AccountInfo — PDA to create
    &dwallet,           // &AccountInfo — the dWallet
    &payer,             // &AccountInfo — pays rent
    &system_program,    // &AccountInfo
    message_hash,       // [u8; 32]
    user_pubkey,        // [u8; 32]
    signature_scheme,   // u8
    bump,               // u8 — MessageApproval PDA bump
)?;
}

transfer_dwallet

#![allow(unused)]
fn main() {
ctx.transfer_dwallet(&dwallet, &new_authority)?;
}

transfer_future_sign

#![allow(unused)]
fn main() {
ctx.transfer_future_sign(&partial_user_sig, &new_authority)?;
}

Example: Voting dWallet

Source: chains/solana/examples/voting/native/

#![allow(unused)]
fn main() {
use solana_program::{
    account_info::{next_account_info, AccountInfo},
    entrypoint,
    entrypoint::ProgramResult,
    program::invoke_signed,
    program_error::ProgramError,
    pubkey::Pubkey,
    rent::Rent,
    sysvar::Sysvar,
};
use ika_dwallet_native::DWalletContext;

entrypoint!(process_instruction);

fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    match instruction_data[0] {
        0 => create_proposal(program_id, accounts, &instruction_data[1..]),
        1 => cast_vote(program_id, accounts, &instruction_data[1..]),
        _ => Err(ProgramError::InvalidInstructionData),
    }
}
}

Uses next_account_info() for account iteration, Rent::get()?.minimum_balance() for rent, and system_instruction::create_account + invoke_signed for PDA creation.

When quorum is reached, the program constructs a DWalletContext and calls approve_message.

When to Use Native

ConsiderationPinocchioNativeAnchor
CU efficiencyBestGoodGood
std libraryNo (no_std)YesYes
Framework dependencypinocchiosolana-programanchor-lang
Account validationManualManualDeclarative
Migration from existingRewriteMinimalRewrite

Choose Native when you have an existing solana-program codebase, want std library access, or prefer no framework lock-in beyond Solana’s standard SDK.

Differences from Pinocchio

PinocchioNative
Account type&AccountView&AccountInfo<'info>
Entrypointpinocchio::entrypoint!()solana_program::entrypoint!()
CPIpinocchio::cpi::invoke_signedsolana_program::program::invoke_signed
PDA creationpinocchio_system::CreateAccountsystem_instruction::create_account + invoke_signed
Rentminimum_balance() helperRent::get()?.minimum_balance()
std#![no_std]Full std
Account iterationArray indexingnext_account_info()

Both SDKs use the same CPI authority seed, instruction discriminators, and account layouts. Programs built with either are fully interoperable.