Pinocchio Framework
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-pinocchio crate provides a Pinocchio-native CPI SDK for the dWallet program. Pinocchio is the highest-performance Solana program framework — #![no_std], zero-copy, minimal CU overhead.
Dependencies
[dependencies]
ika-dwallet-pinocchio = { git = "https://github.com/dwallet-labs/ika-pre-alpha" }
pinocchio = "0.10"
pinocchio-system = "0.5"
[lib]
crate-type = ["cdylib", "lib"]
DWalletContext
#![allow(unused)]
fn main() {
use ika_dwallet_pinocchio::DWalletContext;
let ctx = DWalletContext {
dwallet_program: &dwallet_program_account,
cpi_authority: &cpi_authority_account,
caller_program: &my_program_account,
cpi_authority_bump: bump,
};
}
| Field | Type | Description |
|---|---|---|
dwallet_program | &AccountView | The dWallet program account |
cpi_authority | &AccountView | Your program’s CPI authority PDA |
caller_program | &AccountView | Your program’s account (must be executable) |
cpi_authority_bump | u8 | Bump seed for the CPI authority PDA |
CPI Authority PDA
Every program that controls a dWallet derives a single CPI authority PDA:
#![allow(unused)]
fn main() {
use ika_dwallet_pinocchio::CPI_AUTHORITY_SEED;
// Derive at runtime:
let (cpi_authority, bump) = pinocchio::Address::find_program_address(
&[CPI_AUTHORITY_SEED],
program_id,
);
}
Methods
approve_message
Creates a MessageApproval PDA requesting a signature from the Ika network.
#![allow(unused)]
fn main() {
ctx.approve_message(
message_approval, // &AccountView — PDA to create
dwallet, // &AccountView — the dWallet
payer, // &AccountView — pays rent
system_program, // &AccountView
message_hash, // [u8; 32]
user_pubkey, // [u8; 32]
signature_scheme, // u8: 0=Ed25519, 1=Secp256k1, 2=Secp256r1
bump, // u8 — MessageApproval PDA bump
)?;
}
transfer_dwallet
Transfers dWallet authority to a new pubkey (or another program’s CPI PDA).
#![allow(unused)]
fn main() {
ctx.transfer_dwallet(dwallet, &new_authority_bytes)?;
}
transfer_future_sign
Transfers the completion authority of a PartialUserSignature.
#![allow(unused)]
fn main() {
ctx.transfer_future_sign(partial_user_sig, &new_authority_bytes)?;
}
Example: Voting dWallet
Source: chains/solana/examples/voting/pinocchio/
#![allow(unused)]
#![no_std]
fn main() {
extern crate alloc;
use pinocchio::{entrypoint, AccountView, Address, ProgramResult};
use ika_dwallet_pinocchio::DWalletContext;
entrypoint!(process_instruction);
pinocchio::nostd_panic_handler!();
fn process_instruction(
program_id: &Address,
accounts: &[AccountView],
data: &[u8],
) -> ProgramResult {
match data[0] {
0 => create_proposal(program_id, accounts, &data[1..]),
1 => cast_vote(program_id, accounts, &data[1..]),
_ => Err(pinocchio::error::ProgramError::InvalidInstructionData),
}
}
}
When quorum is reached in cast_vote, the program constructs a DWalletContext and calls approve_message — authorizing the Ika network to sign.
When to Use Pinocchio
| Consideration | Pinocchio | Native | Anchor |
|---|---|---|---|
| CU efficiency | Best | Good | Good |
| Binary size | Smallest | Medium | Largest |
no_std support | Yes | No | No |
| Account validation | Manual | Manual | Declarative |
| Learning curve | Steepest | Medium | Easiest |
Choose Pinocchio when you need maximum CU efficiency, smallest binary size, or no_std compatibility.