### Path Example Source: https://docs.arcium.com/developers/arcis/operations Shows a supported path syntax. ```rust Foo::bar ``` -------------------------------- ### Complete example: Before v0.4.0 Source: https://docs.arcium.com/developers/migration/migration-v0.3-to-v0.4 This section provides a complete code example of a typical computation function before migrating to v0.4.0, including Rust toolchain, Cargo.toml, and program source files. ```rust // rust-toolchain file (plain text) 1.88.0 ``` ```toml [workspace] members = ["programs/*", "encrypted-ixs"] resolver = "2" [patch.crates-io] proc-macro2 = { git = 'https://github.com/arcium-hq/proc-macro2.git' } ``` ```toml [dependencies] anchor-lang = { version = "0.31.1", features = ["init-if-needed"] } arcium-client = { version = "0.3.0", default-features = false } arcium-macros = { version = "0.3.0" } arcium-anchor = { version = "0.3.0" } [features] idl-build = ["anchor-lang/idl-build"] ``` ```rust pub fn init_flip_comp_def(ctx: Context) -> Result<()> { init_comp_def(ctx.accounts, true, 0, None, None)?; Ok(()) } pub fn flip( ctx: Context, computation_offset: u64, user_choice: [u8; 32], pub_key: [u8; 32], nonce: u128, ) -> Result<()> { let args = vec![ Argument::ArcisPubkey(pub_key), Argument::PlaintextU128(nonce), Argument::EncryptedU8(user_choice), ]; ctx.accounts.sign_pda_account.bump = ctx.bumps.sign_pda_account; queue_computation( ctx.accounts, computation_offset, args, None, vec![FlipCallback::callback_ix(&[])], )?; Ok(()) } #[queue_computation_accounts("flip", payer)] #[derive(Accounts)] #[instruction(computation_offset: u64)] pub struct Flip<'info> { #[account(mut)] pub payer: Signer<'info>, #[account( init_if_needed, space = 9, payer = payer, seeds = [&SIGN_PDA_SEED], bump, address = derive_sign_pda!(), )] pub sign_pda_account: Account<'info, SignerAccount>, #[account( address = derive_mxe_pda!() )] pub mxe_account: Account<'info, MXEAccount>, #[account( mut, address = derive_cluster_pda!(mxe_account) )] pub cluster_account: Account<'info, Cluster>, // ... other accounts } ``` -------------------------------- ### Reference Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates a supported reference syntax. ```rust &mut foo ``` -------------------------------- ### Quick Start: Callback Implementation Source: https://docs.arcium.com/developers/program/callback-type-generation Implement the callback function using the `#[arcium_callback]` macro. This example shows how to verify and access the output from the `my_calc` instruction. ```rust #[arcium_callback(encrypted_ix = "my_calc")] pub fn my_calc_callback( ctx: Context, output: SignedComputationOutputs, ) -> Result<()> { let o = match output.verify_output( &ctx.accounts.cluster_account, &ctx.accounts.computation_account ) { Ok(MyCalcOutput { field_0 }) => field_0, Err(_) => return Err(ErrorCode::AbortedComputation.into()), }; let encrypted_value = o.ciphertexts[0]; // Your logic here Ok(()) } ``` -------------------------------- ### Complete example: v0.4.0 Source: https://docs.arcium.com/developers/migration/migration-v0.3-to-v0.4 This section provides a complete code example of a typical computation function after migrating to v0.4.0, including Rust toolchain, Cargo.toml, and program source files. ```toml [toolchain] channel = "1.89.0" components = ["rustfmt","clippy"] profile = "minimal" ``` ```toml [workspace] members = ["programs/*", "encrypted-ixs"] resolver = "2" ``` ```toml # No [patch.crates-io] section ``` ```toml [dependencies] anchor-lang = { version = "0.32.1", features = ["init-if-needed"] } arcium-client = { version = "0.4.0", default-features = false } arcium-macros = { version = "0.4.0" } arcium-anchor = { version = "0.4.0" } [features] idl-build = ["anchor-lang/idl-build", "arcium-anchor/idl-build"] ``` -------------------------------- ### Quick Install Arcium Toolchain Source: https://docs.arcium.com/developers/installation Run this command on Mac and Linux to install Arcium, including Rust, Solana CLI, and Anchor prerequisites. This script handles dependency checks and installs arcup, the Arcium CLI, and the Arx Node. ```bash curl --proto '=https' --tlsv1.2 -sSfL https://install.arcium.com/ | bash ``` -------------------------------- ### Quick Start: Circuit Definition Source: https://docs.arcium.com/developers/program/callback-type-generation Define your confidential computation circuit using the `#[instruction]` macro. This example defines a simple calculation returning a u64. ```rust #[instruction] pub fn my_calc() -> Enc { /* ... */ } ``` -------------------------------- ### Install Solana CLI v3.1.10 Source: https://docs.arcium.com/developers/migration/migration-v0.9.0-to-v0.10.0 Install the specified version of the Solana CLI. This is a major version bump from v2.3.0. ```bash sh -c "$(curl -sSfL https://release.anza.xyz/v3.1.10/install)" solana --version ``` -------------------------------- ### Closure Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates the syntax for a closure. ```plaintext |a, b | a + b ``` -------------------------------- ### Method Call Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates a supported method call syntax. ```rust x.foo(a, b) ``` -------------------------------- ### Resume MXE Initialization and Key Recovery Setup Source: https://docs.arcium.com/developers/migration/migration-v0.9.0-to-v0.10.0 The `arcium init-mxe --resume` command now handles both interrupted MXE initialization and key recovery material setup. Pass the `--recovery-set-size` argument, ensuring it matches the on-chain state. ```bash arcium init-mxe \ --keypair-path ~/.config/solana/id.json \ --callback-program \ --cluster-offset \ --recovery-set-size 8 \ --rpc-url \ --resume ``` -------------------------------- ### Binary Expression Example Source: https://docs.arcium.com/developers/arcis/operations Provides an example of a binary expression. Refer to the documentation for supported operators. ```plaintext a + b ``` -------------------------------- ### Struct Literal Example Source: https://docs.arcium.com/developers/arcis/operations Example of creating a struct literal. ```rust MyStruct { a: 12, b } ``` -------------------------------- ### Return Statement Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates an unsupported return statement. ```rust return false; ``` -------------------------------- ### Macro Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for using a macro. Refer to the documentation for supported macros. ```plaintext println!("{}", q) ``` -------------------------------- ### Async Block Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates the syntax for an async block, which is currently unsupported. ```plaintext async { ... } ``` -------------------------------- ### Function Call Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates the syntax for calling a function with arguments. Refer to the documentation for supported functions. ```plaintext f(a, b) ``` -------------------------------- ### Install @arcium-hq/client with npm Source: https://docs.arcium.com/developers/js-client-library Install the Arcium client library using npm. This library handles secret sharing, confidential transactions, and computation result callbacks. ```bash npm install @arcium-hq/client ``` -------------------------------- ### Await Expression Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for an await expression, which is currently unsupported. ```plaintext foo().await ``` -------------------------------- ### Continue Statement Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates the syntax for a continue statement, which is currently unsupported. ```plaintext continue; ``` -------------------------------- ### Parentheses Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates the use of parentheses for grouping expressions. ```rust (a + b) ``` -------------------------------- ### Range Example Source: https://docs.arcium.com/developers/arcis/operations Example of a range expression. Note that this is not supported within array indexing. ```rust 4..5 ``` -------------------------------- ### Install Latest Arcium Components Source: https://docs.arcium.com/developers/installation/arcup Installs the latest releases of the Arcium CLI and Arx Node components using arcup. Ensure arcup is installed first by following the manual installation steps. ```bash arcup install # Will install the latest releases of the Arcium components ``` -------------------------------- ### Tuple Literal Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates the syntax for a tuple literal. ```rust (a, 4, c) ``` -------------------------------- ### Loop Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates the syntax for a loop, which is unsupported due to MPC circuit constraints. ```plaintext loop { ... } ``` -------------------------------- ### Install Latest Arcium CLI with arcup Source: https://docs.arcium.com/developers/installation Use the arcup tool to install the latest version of the Arcium CLI after manual installation. ```bash arcup install ``` -------------------------------- ### Raw Address Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates an unsupported raw address syntax. ```rust &raw const foo ``` -------------------------------- ### Install Linux Build Dependencies Source: https://docs.arcium.com/developers/installation On Ubuntu/Debian systems, install necessary dependencies for building Arcium, including pkg-config, build-essential, libudev-dev, and libssl-dev. ```bash sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev libssl-dev ``` -------------------------------- ### Create Workspace Directory Source: https://docs.arcium.com/developers/node-setup Creates a dedicated directory for node setup and navigates into it. This directory is assumed for all subsequent commands. ```bash mkdir arcium-node-setup cd arcium-node-setup ``` -------------------------------- ### Install @arcium-hq/client with yarn Source: https://docs.arcium.com/developers/js-client-library Install the Arcium client library using yarn. This library handles secret sharing, confidential transactions, and computation result callbacks. ```bash yarn add @arcium-hq/client ``` -------------------------------- ### Cast Expression Example Source: https://docs.arcium.com/developers/arcis/operations Provides an example of a cast expression. Refer to the documentation for supported conversions. ```plaintext a as u16 ``` -------------------------------- ### Verify Arcium Installation Source: https://docs.arcium.com/developers/installation Check if the Arcium CLI is installed correctly by verifying its version. ```bash arcium --version ``` -------------------------------- ### Install @arcium-hq/client with pnpm Source: https://docs.arcium.com/developers/js-client-library Install the Arcium client library using pnpm. This library handles secret sharing, confidential transactions, and computation result callbacks. ```bash pnpm add @arcium-hq/client ``` -------------------------------- ### Repeat Array Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for creating a repeated array. ```rust [4u8; 128] ``` -------------------------------- ### Manual Install arcup for x86 Linux Source: https://docs.arcium.com/developers/installation Manually install the arcup tool for x86_64 Linux systems. This command downloads the arcup binary and makes it executable. ```bash TARGET=x86_64_linux && curl "https://bin.arcium.com/download/arcup_${TARGET}_0.10.3" -o ~/.cargo/bin/arcup && chmod +x ~/.cargo/bin/arcup ``` -------------------------------- ### Const Block Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for a const block. ```plaintext const { ... } ``` -------------------------------- ### Install @arcium-hq/reader with yarn Source: https://docs.arcium.com/developers/js-client-library Install the Arcium reader library using yarn. This library is used to read MXE data and view computations. ```bash yarn add @arcium-hq/reader ``` -------------------------------- ### Field Access/Set Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates accessing or setting a field on an object. ```plaintext obj.field ``` -------------------------------- ### Break Statement Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for a break statement, which is currently unsupported. ```plaintext break; ``` -------------------------------- ### Array Literal Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates the syntax for an array literal. ```plaintext [a, b] ``` -------------------------------- ### Block Expression Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates the syntax for a block expression. ```plaintext { ... } ``` -------------------------------- ### Install and Use Anchor CLI v1.0.2 Source: https://docs.arcium.com/developers/migration/migration-v0.9.0-to-v0.10.0 Install Anchor CLI version 1.0.2 using cargo and set it as the active version. This is a major version bump from v0.32.1. ```bash cargo install --git https://github.com/solana-foundation/anchor avm --locked --force avm install 1.0.2 avm use 1.0.2 anchor --version ``` -------------------------------- ### Match Expression Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates the syntax for a match expression. Note that last arms cannot have guards. ```plaintext match n { ... } ``` -------------------------------- ### Manual Install arcup for Apple Silicon Source: https://docs.arcium.com/developers/installation Manually install the arcup tool for Apple Silicon (aarch64_macos) systems. This command downloads the arcup binary and makes it executable. ```bash TARGET=aarch64_macos && curl "https://bin.arcium.com/download/arcup_${TARGET}_0.10.3" -o ~/.cargo/bin/arcup && chmod +x ~/.cargo/bin/arcup ``` -------------------------------- ### Indexing Example Source: https://docs.arcium.com/developers/arcis/operations Demonstrates accessing an element by index. Performance implications exist if the index is not known at compile-time. ```plaintext a[idx] ``` -------------------------------- ### Debugging with println! and debug_assert! Source: https://docs.arcium.com/developers/arcis/quick-reference Provides examples of using `println!` for output and `debug_assert!` for conditional checks during development. ```rust println!("value = {}", x); debug_assert!(x > 0, "x must be positive"); ``` -------------------------------- ### For Loop Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for a for loop. The expression for iteration has its length known at compile-time. ```plaintext for i in expr { ... } ``` -------------------------------- ### While Loop Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates an unsupported while loop. This is due to the inability to determine the number of iterations. ```rust while x < 64 { ... } ``` -------------------------------- ### Unsafe Block Example Source: https://docs.arcium.com/developers/arcis/operations Shows an unsupported unsafe block syntax. ```rust unsafe { ... } ``` -------------------------------- ### Try Expression Example Source: https://docs.arcium.com/developers/arcis/operations Shows an unsupported try expression syntax. ```rust this_call_can_err()?; ``` -------------------------------- ### Prepare Node Environment Source: https://docs.arcium.com/developers/node-setup Create necessary directories and verify required key files are present before deploying the node. ```bash mkdir -p arx-node-logs private-shares public-inputs ls node-keypair.json callback-kp.json identity.pem bls-keypair.json x25519-keypair.json node-config.toml ``` -------------------------------- ### Skip Key Recovery Initialization with Environment Variable Source: https://docs.arcium.com/developers/migration/migration-v0.9.0-to-v0.10.0 When using `arcium test --skip-keygen` or `arcium localnet --skip-keygen`, the environment variable `ARCIUM_SKIP_KEY_RECOVERY_INIT=1` is set. Use this to bypass legacy key recovery setup when MXE starts in a post-keygen state. ```bash # Example of how the environment variable might be used in a test script if [ "$ARCIUM_SKIP_KEY_RECOVERY_INIT" = "1" ]; then echo "Skipping key recovery init..." else echo "Performing key recovery init..." # ... actual key recovery init logic ... fi ``` -------------------------------- ### Check for Existing Arcium Installations Source: https://docs.arcium.com/developers/installation/arcup Before installing with arcup, check if you have a manually installed CLI or Arx Node image. This helps in deciding whether to remove old installations. ```bash command -v arcium || true docker image ls "arcium/*" ``` -------------------------------- ### Build Project Source: https://docs.arcium.com/developers/migration/migration-v0.2-to-v0.3 Run this command from your workspace root to build your project after migration. ```bash # From your workspace root arcium build ``` -------------------------------- ### Verify Arcium Installation Source: https://docs.arcium.com/developers/installation/arcup After installation, verify that the Arcium CLI and Arx Node are correctly installed and accessible. This command checks the CLI version and lists all installed Arcium components. ```bash arcium --version # Should show the latest CLI version arcup version # Shows the currently installed versions of all of the Arcium components docker images # Should list the image for the Arx Node ``` -------------------------------- ### Rust Computation Function Before v0.3.0 Source: https://docs.arcium.com/developers/migration/migration-v0.2-to-v0.3 Example of a computation function before the v0.3.0 migration. Note the absence of the sign_pda_account. ```rust #[queue_computation_accounts] #[derive(Accounts)] pub struct Flip<'info> { #[account(mut)] pub payer: Signer<'info>, // ... other accounts (no sign_pda_account) } pub fn flip( ctx: Context, computation_offset: u64, user_choice: [u8; 32], pub_key: [u8; 32], nonce: u128, ) -> Result<()> { let args = vec![ Argument::ArcisPubkey(pub_key), Argument::PlaintextU128(nonce), Argument::EncryptedU8(user_choice), ]; queue_computation(ctx.accounts, computation_offset, args, None, None)?; Ok(()) } ``` -------------------------------- ### Rust Computation Function v0.3.0 Source: https://docs.arcium.com/developers/migration/migration-v0.2-to-v0.3 Example of a computation function after migrating to v0.3.0. Includes the new sign_pda_account and updated queue_computation call. ```rust #[queue_computation_accounts] #[derive(Accounts)] pub struct Flip<'info> { #[account(mut)] pub payer: Signer<'info>, #[account( init_if_needed, space = 9, payer = payer, seeds = [&SIGN_PDA_SEED], bump, address = derive_sign_pda!(), )] pub sign_pda_account: Account<'info, SignerAccount>, // ... other existing accounts } pub fn flip( ctx: Context, computation_offset: u64, user_choice: [u8; 32], pub_key: [u8; 32], nonce: u128, ) -> Result<()> { let args = vec![ Argument::ArcisPubkey(pub_key), Argument::PlaintextU128(nonce), Argument::EncryptedU8(user_choice), ]; ctx.accounts.sign_pda_account.bump = ctx.bumps.sign_pda_account; queue_computation( ctx.accounts, computation_offset, args, None, vec![FlipCallback::callback_ix(&[])], )?; Ok(()) } ``` -------------------------------- ### Literal Expression Example Source: https://docs.arcium.com/developers/arcis/operations Provides an example of a literal expression. Refer to the documentation for supported literal types. ```plaintext 1u128 ``` -------------------------------- ### Example Confidential Instruction Source: https://docs.arcium.com/developers/program/callback-type-generation This is an example of a confidential instruction function within an Arcium circuit. It defines the input and return types for a computation. ```rust pub fn add_together(input: Enc) -> Enc { // Your function code here } ``` -------------------------------- ### Initialize a new Arcium project Source: https://docs.arcium.com/developers/hello-world Use this command to create a new project with the given name and initialize it with a basic structure. ```bash arcium init ``` -------------------------------- ### Verify Migration Commands Source: https://docs.arcium.com/developers/migration/migration-v0.6.3-to-v0.7.0 Run these commands to build, check, and test your project after migration to ensure everything is working correctly. ```bash arcium build cargo check --all arcium test ``` -------------------------------- ### Verify Arcium Tool Installation Source: https://docs.arcium.com/developers/node-setup Checks if the Arcium CLI and arcup (Arcium's version manager) have been installed correctly by displaying their versions. ```bash arcium --version && arcup --version ``` -------------------------------- ### Install @arcium-hq/reader with pnpm Source: https://docs.arcium.com/developers/js-client-library Install the Arcium reader library using pnpm. This library is used to read MXE data and view computations. ```bash pnpm add @arcium-hq/reader ``` -------------------------------- ### Install @arcium-hq/reader with npm Source: https://docs.arcium.com/developers/js-client-library Install the Arcium reader library using npm. This library is used to read MXE data and view computations. ```bash npm install @arcium-hq/reader ``` -------------------------------- ### Build Test Command Source: https://docs.arcium.com/developers/migration/migration-v0.4-to-v0.5 Compiles the project to ensure all components build correctly. Run this from your workspace root. ```bash ```bash theme={null} # From your workspace root arcium build ``` ``` -------------------------------- ### Full Arcium.toml Example Source: https://docs.arcium.com/developers/arcium-toml This TOML snippet demonstrates a complete Arcium.toml configuration, including settings for localnet and cluster definitions. It shows how to specify the number of nodes, their IP addresses, timeout, backends, and cluster offsets. ```toml [localnet] nodes = 2 nodes_ips = [ [172, 20, 0, 100], [172, 20, 0, 101] ] localnet_timeout_secs = 60 backends = ["Cerberus"] [clusters.devnet] offset = 456 [clusters.mainnet] offset = 2026 ``` -------------------------------- ### Start and Monitor Arcium Node Source: https://docs.arcium.com/developers/node-setup Commands to start the Docker Compose service in detached mode, check container status, and view live logs. ```bash docker compose up -d docker compose ps docker compose logs -f arx-node ``` -------------------------------- ### Run Arcium Node with Docker Direct Command Source: https://docs.arcium.com/developers/node-setup Alternative method to start the Arcium node using `docker run` with environment variables, volume mounts, and port mappings. ```bash docker run -d \ --name arx-node \ -e NODE_IDENTITY_FILE=/usr/arx-node/node-keys/node_identity.pem \ -e NODE_KEYPAIR_FILE=/usr/arx-node/node-keys/node_keypair.json \ -e CALLBACK_AUTHORITY_KEYPAIR_FILE=/usr/arx-node/node-keys/callback_authority_keypair.json \ -e BLS_PRIVATE_KEY_FILE=/usr/arx-node/node-keys/bls_keypair.json \ -e X25519_PRIVATE_KEY_FILE=/usr/arx-node/node-keys/x25519_keypair.json \ -e ARX_METRICS_HOST=0.0.0.0 \ -e ARX_METRICS_PORT=9091 \ -v "$(pwd)/node-config.toml:/usr/arx-node/arx/node_config.toml" \ -v "$(pwd)/node-keypair.json:/usr/arx-node/node-keys/node_keypair.json:ro" \ -v "$(pwd)/callback-kp.json:/usr/arx-node/node-keys/callback_authority_keypair.json:ro" \ -v "$(pwd)/identity.pem:/usr/arx-node/node-keys/node_identity.pem:ro" \ -v "$(pwd)/bls-keypair.json:/usr/arx-node/node-keys/bls_keypair.json:ro" \ -v "$(pwd)/x25519-keypair.json:/usr/arx-node/node-keys/x25519_keypair.json:ro" \ -v "$(pwd)/arx-node-logs:/usr/arx-node/logs" \ -v "$(pwd)/private-shares:/usr/arx-node/private-shares" \ -v "$(pwd)/public-inputs:/usr/arx-node/public-inputs" \ -p 8001:8001/tcp -p 8001:8001/udp \ -p 8002:8002/tcp -p 8002:8002/udp \ -p 8012:8012/tcp -p 8012:8012/udp \ -p 8013:8013/tcp -p 8013:8013/udp \ -p 9091:9091/tcp \ arcium/arx-node:v0.10.3 ``` -------------------------------- ### Verify Migration Source: https://docs.arcium.com/developers/migration/migration-v0.7.0-to-v0.8.0 Run build, check all Rust code, and execute tests to ensure the migration was successful. Use `--skip-local-circuit` if offchain circuits are not needed locally. ```bash arcium build cargo check --all arcium test ``` ```bash arcium test --skip-local-circuit ``` -------------------------------- ### Arcup Available Commands Source: https://docs.arcium.com/developers/installation/arcup Lists the available commands for the arcup version manager, including install, update, list, version, use, uninstall, self, and help. ```bash install Install the latest (or a specific) version of Arcium components (Arx Node and CLI) update Update all Arcium components (Arx Node and CLI) to the latest version list List all installed versions version Show currently active version use Switch to using a specific installed version uninstall Remove a specific version (alias: rm) self Manage arcup itself (update, uninstall) help Print this message or the help of the given subcommand(s) ``` -------------------------------- ### If-Else Expression Example Source: https://docs.arcium.com/developers/arcis/operations Illustrates the syntax for an if-else expression. ```plaintext if cond { ... } else { ... } ``` -------------------------------- ### Struct Declaration in Arcis Source: https://docs.arcium.com/developers/arcis/operations Example of defining a structure. This is fully supported. ```rust struct MyStruct { ... } ``` -------------------------------- ### Multiple Instructions and Output Types Source: https://docs.arcium.com/developers/program/callback-type-generation Demonstrates how each #[instruction] generates a distinct `.idarc` file, leading to separate output types for each circuit, ensuring type safety and modularity. ```rust #[instruction] pub fn add() -> Enc // → AddOutput #[instruction] pub fn multiply() -> Enc // → MultiplyOutput #[instruction] pub fn divide() -> Enc // → DivideOutput ``` -------------------------------- ### Basic Node Configuration Source: https://docs.arcium.com/developers/node-setup Configures the node's network connection and Solana RPC endpoints. Update with your specific node offset and RPC provider URLs. ```toml [node] offset = # Your node offset from step 5 [solana] endpoint_rpc = "" # e.g., https://api.mainnet-beta.solana.com or https://api.devnet.solana.com endpoint_wss = "" # Replace with your RPC provider WebSocket URL (e.g., wss://api.mainnet-beta.solana.com) ``` -------------------------------- ### Configure RPC Provider in Anchor.toml Source: https://docs.arcium.com/developers/migration/migration-v0.5-to-v0.6 For non-localnet testing, configure your RPC endpoint and wallet in the `[provider]` section of your `Anchor.toml` file. This ensures tests connect to the correct cluster. ```toml [provider] cluster = "devnet" wallet = "~/.config/solana/id.json" ``` -------------------------------- ### Assignment Expression Example Source: https://docs.arcium.com/developers/arcis/operations Shows the basic syntax for an assignment operation. ```plaintext a = b; ``` -------------------------------- ### If Let Pattern Matching Example Source: https://docs.arcium.com/developers/arcis/operations Shows the syntax for an 'if let' pattern matching construct. Let chains require Rust edition 2024. ```plaintext if let Some(x) = ... ``` -------------------------------- ### Manual CallbackInstruction Construction Source: https://docs.arcium.com/developers/program/callback-accs This Rust code demonstrates the manual creation of a `CallbackInstruction` for a confidential computation. It shows how to specify the callback program ID, instruction discriminator, and all necessary accounts, including custom ones like the result account marked as writable. ```rust pub fn add_together( ctx: Context, computation_offset: u64, ciphertext_0: [u8; 32], ciphertext_1: [u8; 32], pub_key: [u8; 32], nonce: u128, ) -> Result<()> { // Note: Using `create_program_address` with the bump would be more efficient than `find_program_address`. // Since this PDA is constant, you could also derive it at compile time and save it as a constant. // We use find_program_address here for simplicity. let addition_result_pda = Pubkey::find_program_address(&[b"AdditionResult"], ctx.program_id).0; // Build the args the confidential instruction expects using ArgBuilder let args = ArgBuilder::new() .x25519_pubkey(pub_key) .plaintext_u128(nonce) .encrypted_u8(ciphertext_0) .encrypted_u8(ciphertext_1) .build(); // Set the bump for the sign_pda_account ctx.accounts.sign_pda_account.bump = ctx.bumps.sign_pda_account; // Build & queue our computation (via CPI to the Arcium program) queue_computation( ctx.accounts, // Random offset for the computation computation_offset, // The one-time inputs our confidential instruction expects args, // Manual approach: Define which callback instruction to call when the computation is complete. // We specify the program ID, instruction discriminator, and all accounts needed // for the callback, including our result account which we want to be writable. vec![CallbackInstruction { program_id: ID_CONST, discriminator: instruction::AddTogetherCallback::DISCRIMINATOR.to_vec(), accounts: vec![ // Standard accounts (always required, in this order) CallbackAccount { pubkey: ::arcium_client::ARCIUM_PROGRAM_ID, is_writable: false, }, CallbackAccount { pubkey: derive_comp_def_pda!(COMP_DEF_OFFSET_ADD_TOGETHER), is_writable: false, }, CallbackAccount { pubkey: ctx.accounts.mxe_account.key(), is_writable: false, }, CallbackAccount { pubkey: ctx.accounts.computation_account.key(), is_writable: false, }, CallbackAccount { pubkey: derive_cluster_pda!(ctx.accounts.mxe_account), is_writable: false, }, CallbackAccount { pubkey: INSTRUCTIONS_SYSVAR_ID, is_writable: false, }, // Custom accounts (your callback-specific accounts) CallbackAccount { pubkey: addition_result_pda, is_writable: true, // Tells nodes to mark this account as writable in the transaction } ] }], 1, // Number of transactions needed for callback (1 for simple computations) 0, // cu_price_micro: priority fee in microlamports (0 = no priority fee) )?; Ok(()) } /* The AddTogether accounts struct stays exactly the same as shown in the basic guide */ ``` -------------------------------- ### Basic Deployment Command Source: https://docs.arcium.com/developers/deployment Executes the basic deployment command for an MXE to Solana. This command handles both program deployment and MXE account initialization. Ensure you replace placeholder values with your specific configuration. ```bash arcium deploy --cluster-offset --recovery-set-size --keypair-path --rpc-url ``` -------------------------------- ### Update TypeScript Dependencies (pnpm) Source: https://docs.arcium.com/developers/migration/migration-v0.8.0-to-v0.9.0 Install the @arcium-hq/client version 0.9.7 using pnpm. ```bash pnpm add @arcium-hq/client@0.9.7 ``` -------------------------------- ### Run Existing Tests Source: https://docs.arcium.com/developers/migration/migration-v0.2-to-v0.3 Execute your existing tests to confirm that functionality has been preserved post-migration. ```bash # Run your existing tests to ensure functionality is preserved arcium test ``` -------------------------------- ### Update TypeScript Dependencies (npm) Source: https://docs.arcium.com/developers/migration/migration-v0.8.0-to-v0.9.0 Install the @arcium-hq/client version 0.9.7 using npm. ```bash npm install @arcium-hq/client@0.9.7 ``` -------------------------------- ### Wildcard Pattern Source: https://docs.arcium.com/developers/arcis/operations Example of a wildcard pattern (`_`) to ignore a value. Supported in variable bindings. ```rust let _ = ...; ``` -------------------------------- ### Partial Arcium Deployment: Initialize MXE Account Only Source: https://docs.arcium.com/developers/deployment Skip program deployment and only initialize the MXE account using the `--skip-deploy` flag. This is useful when the program is already deployed. ```bash # Skip program deployment, only initialize MXE account arcium deploy --cluster-offset 456 \ --recovery-set-size 4 \ --keypair-path ~/.config/solana/id.json \ --rpc-url \ --skip-deploy ```