Skip to main content
The Privora SDKs provide transaction builders for sending transactions with FHE data references.

Basic Transaction

let signature = privora
    .transaction()
    .instruction(instruction)
    .sign(&payer)
    .send()
    .await?;

With FHE Data

When your transaction references encrypted data, include the hashes:
let hash = privora.submit(&encrypted).await?;

let signature = privora
    .transaction()
    .instruction(instruction)
    .with_fhe_data(&[hash])
    .sign(&payer)
    .send()
    .await?;

Multiple Instructions

let signature = privora
    .transaction()
    .instruction(create_account_ix)
    .instruction(initialize_ix)
    .instruction(process_ix)
    .with_fhe_data(&[hash1, hash2])
    .sign(&payer)
    .send()
    .await?;

Building Instruction Data

Include hash references in your instruction data:
let mut data = vec![0u8]; // instruction discriminator
data.extend_from_slice(&hash);

let instruction = Instruction {
    program_id: PROGRAM_ID,
    accounts: vec![AccountMeta::new(account, false)],
    data,
};

Complete Example

use privora_sdk_client::prelude::*;

async fn submit_order(price: u8, quantity: u8) -> Result<String> {
    let privora = PrivoraClient::new("http://localhost:8899").await?;
    let payer = Keypair::new();
    privora.request_airdrop(&payer.pubkey(), 1_000_000_000).await?;

    // Encrypt
    let enc_price = privora.encryptor().encrypt(price)?;
    let enc_qty = privora.encryptor().encrypt(quantity)?;

    // Submit
    let price_hash = privora.submit(&enc_price).await?;
    let qty_hash = privora.submit(&enc_qty).await?;

    // Build instruction
    let mut data = vec![1u8];
    data.extend_from_slice(&price_hash);
    data.extend_from_slice(&qty_hash);

    let instruction = Instruction {
        program_id: PROGRAM_ID,
        accounts: vec![
            AccountMeta::new(payer.pubkey(), true),
        ],
        data,
    };

    // Send
    let signature = privora
        .transaction()
        .instruction(instruction)
        .with_fhe_data(&[price_hash, qty_hash])
        .sign(&payer)
        .send()
        .await?;

    Ok(signature)
}