Cambrian Rust SDK
A Rust library for building payload containers that integrate with the Cambrian platform's Actively Validated Services (AVS) ecosystem.
Overview
This SDK provides the core types and utilities needed to create Rust-based Cambrian payload containers. It simplifies the process of:
- Parsing the
CAMB_INPUTenvironment variable - Converting between Solana instructions and Cambrian payload formats
- Handling account roles with proper bitflag encoding
- Serializing output in the required JSON format
Installation
Add this crate to your Cargo.toml:
[]
= "0.1.0"
Quick Example
use env;
use FromStr;
use ;
use ;
use ;
use Pubkey;
Key Features
Type Definitions
The SDK provides Rust types that match the Cambrian payload input/output formats:
Input: Parses the JSON structure fromCAMB_INPUTenvironment variableResponse: The complete output format with proposal instructionsProposalInstruction: Represents a single instruction in the outputAccountMeta: Account metadata with address and role informationAccountRole: Enum representing the account role bitflags
Conversion Utilities
The SDK includes conversions between Solana types and Cambrian payload formats:
From<Instruction>forProposalInstructionFrom<&Instruction>forProposalInstructionFrom<Instruction>forResponseFrom<&Instruction>forResponseFrom<Vec<Instruction>>forResponseFrom<&[Instruction]>forResponse
Account Role Handling
Account roles are represented using a bitflag system:
0b00 = READONLY (not a signer, not writable)
0b01 = WRITABLE (not a signer, writable)
0b10 = READONLY_SIGNER (signer, not writable)
0b11 = WRITABLE_SIGNER (signer, writable)
The SDK handles this conversion for you with From<(bool, bool)> for AccountRole.
Complete Usage Example
For a complete example of using this SDK, see the check-oracle-rust payload in the Cambrian payload images repository.
Related Resources
License
This project is licensed under the MIT License - see the LICENSE file for details.