Skip to main content

Crate ifx_sdk

Crate ifx_sdk 

Source
Expand description

Off-chain Ifx SDK — build ifx_create_frame, ifx_let, ifx_assert, ifx_patched_cpi, ifx_if_else, and related instructions as solana_sdk::instruction::Instruction values.

Same layer as @ifx-run/sdk and go-sdk: wire encoding and planner helpers only — no RPC, wallet, or transaction submission wrapper.

§Example

Typical business tx on an existing Frame (create Frame is a separate one-time tx): read a token balance mid-flow, then close the ATA only when amount is zero — otherwise Skip so the rest of the transaction still succeeds.

use ifx_sdk::expr;
use ifx_sdk::if_else::{args, cpi, skip};
use ifx_sdk::patched_cpi::{build_static_cpi, with_owner_signer};
use ifx_sdk::scratch::FrameScratch;

scratch.ix_reset();

let mut b = scratch.let_builder();
let amount = b.spl_token_amount(token_account)?;
b.build_ix()?;

let close_ix = with_owner_signer(&close_tpl, owner, true);
let close_built = build_static_cpi(&close_ix)?;

scratch.ix_if_else(
    &args(
        expr::is_zero(expr::r(&amount)),
        cpi(close_built.cpi.clone()),
        skip(),
    ),
    &close_built.remaining,
)?;

Full guide, examples, and integration tests: https://github.com/ifx-run/ifx/tree/main/rust-sdk.

Re-exports§

pub use binding::eval_const_bool;
pub use binding::eval_const_u64;
pub use binding::infer_binding_ty;
pub use binding::remap_account_index;
pub use cpi::encode_cpi;
pub use cpi::normalize_remaining;
pub use cpi::normalize_remaining_metas;
pub use cpi::resolve_cpi_remaining;
pub use cpi::CpiWireBuildResult;
pub use decode::decode_frame_account;
pub use decode::DecodedFrame;
pub use decode_ix::decode_ifx_instruction;
pub use decode_ix::ifx_ix_hint;
pub use decode_ix::DecodedIfxInstruction;
pub use decode_ix::IfxIxName;
pub use error::ScratchError;
pub use frame::encode_create_frame_args;
pub use frame::frame_pda;
pub use frame_authority::frame_authority_requires_signer;
pub use frame_authority::frame_write_authority_meta;
pub use frame_authority::prepend_write_authority_remaining;
pub use frame_authority::public_frame_authority;
pub use if_else::args as if_else_args;
pub use if_else::cpi as if_else_cpi;
pub use if_else::revert as if_else_revert;
pub use if_else::skip as if_else_skip;
pub use ix::build_ix_assert;
pub use ix::build_ix_assert_multi;
pub use ix::build_ix_close_frame;
pub use ix::build_ix_create_frame;
pub use ix::build_ix_cpi;
pub use ix::build_ix_if_else;
pub use ix::build_ix_let;
pub use ix::build_ix_reset_frame;
pub use ix::if_else_args_skip_skip;
pub use ix::let_args_from_bindings;
pub use ix::CreateFrameParams;
pub use ix::CreateFrameResult;
pub use ix::IxOpts;
pub use let_builder::LetBuilder;
pub use let_builder::LetBuilderFinish;
pub use parse_logs::first_ifx_error_in_logs;
pub use parse_logs::parse_ifx_logs;
pub use parse_logs::ParsedIfxLog;
pub use parse_logs::ParsedIfxLogKind;
pub use patched_cpi::build_raw_cpi;
pub use patched_cpi::build_static_cpi;
pub use patched_cpi::build_structured_cpi;
pub use patched_cpi::frame_value;
pub use patched_cpi::raw_cpi_patch;
pub use patched_cpi::structured_system_transfer;
pub use patched_cpi::structured_token_transfer;
pub use patched_cpi::system_transfer_template;
pub use patched_cpi::with_owner_signer;
pub use scratch::FrameScratch;
pub use scratch::PlanNewFrameParams;
pub use scratch::PlanNewFrameResult;
pub use typed::ScratchValue;
pub use wire_ix::AssertMultiArgs;
pub use wire_ix::IfElseArgs;
pub use ifx_core as core;
pub use constants::*;

Modules§

binding
LetBinding account-index remap and eval helpers.
constants
Program ids and re-exports of shared on-chain limits.
cpi
CPI wire encoding and remaining-account layout for ifx_patched_cpi.
decode
On-chain Frame account decode and tape readback (tests / local debug only).
decode_ix
Ifx instruction discriminator decode (inspection / debugging).
error
Planner / ix builder errors.
expr
Wire Expr builders (1:1 with on-chain / @ifx-run/sdk expr).
frame
Frame PDA derivation and create-frame payload encoding.
frame_authority
Frame write authority gate (remaining_accounts[0] for private Frames).
if_else
ifx_if_else arm and args builders.
ix
Solana Instruction builders for Ifx frame instructions.
let_bindings
FrameScratch typed let_* planners (SPL, clock, stake, …).
let_builder
Multi-binding ifx_let batch with deduped remaining accounts.
parse_logs
Parse simulation / RPC logs for Ifx error codes.
patched_cpi
Patched / structured / static CPI builders for ifx_patched_cpi and ifx_if_else.
scratch
Off-chain Frame tape planner (cursor + binding indices).
typed
Scratch planner value handles.
wire_ix
Instruction argument structs not yet in ifx-core (program-local IDL types).