arcium-darkpool-sdk
v0.2.0
Published
TypeScript SDK for Arcium confidential darkpools on Solana
Maintainers
Readme
@arcium-darkpool/sdk
TypeScript SDK for interacting with Arcium confidential darkpools on Solana.
Encrypt inputs, queue MPC computations, and decrypt results — with a clean API that hides all the Arcium complexity.
Install
npm install @arcium-darkpool/sdkQuick start
import { DarkpoolClient } from "@arcium-darkpool/sdk";
import tradingIdl from "./target/idl/solana_darkpool.json";
const client = await DarkpoolClient.create(
{
programId: "h6zsnHt28NpeS94Ek3fQP1YEiu1WrpGT2pKynWZzKVX",
heliusApiKey: "your-api-key",
cluster: "devnet",
},
walletKeypair,
tradingIdl
);
// Match two encrypted orders
const result = await client.matchOrders({ buyBid: 100n, sellBid: 95n });
console.log("Matched:", result.matched); // true
// The MPC nodes never saw 100 or 95Supported darkpools
Trading Dark Pool
await client.placeOrder({ bid: 100n, size: 10n, isBuy: true });
await client.matchOrders({ buyBid: 100n, sellBid: 95n }); // { matched: true }
await client.cancelOrder(42n);
await client.getStats({ buyVolume: 150n, sellVolume: 100n }); // { totalVolume: 250n }Medical Darkpool
await client.registerDataset({
diseaseCode: 340n, // C34 lung cancer
sampleCount: 5000n,
ageMean: 580n, // 58.0 years
genderFemale: 40n, // 40%
dataModality: 2n, // imaging
});
const match = await client.matchDataset({
// dataset profile
diseaseCode: 340n, sampleCount: 5000n, ageMean: 580n, genderFemale: 40n, dataModality: 2n,
// query
queryDisease: 340n, minSamples: 1000n, ageMin: 500n, ageMax: 700n, queryModality: 2n,
});
console.log(match.compatible, match.score.toString()); // true, 100nSupply Chain Darkpool
const supply = await client.matchSupply({
// offer: 50000kg steel, grade 85, 150ct/kg, 7 days, EU
materialCode: 1001n, quantity: 50000n, qualityGrade: 85n,
pricePerUnit: 150n, deliveryDays: 7n, supplyRegion: 1n,
// demand: need steel, min 10000kg, min grade 80, max 200ct, max 10 days, EU
reqMaterial: 1001n, minQuantity: 10000n, minQuality: 80n,
maxPrice: 200n, maxDelivery: 10n, reqRegion: 1n,
});
console.log(supply.matched, supply.score.toString()); // true, 96n
// Carbon credits
const carbon = await client.matchCarbon({
credits: 1000n, pricePerCredit: 12n, vintage: 2022n, certType: 1n, // VCS
reqCredits: 500n, maxPrice: 15n, minVintage: 2020n, reqCertType: 1n,
});
console.log(carbon.matched); // trueHow it works
- Values are encrypted locally using the MXE public key
- Encrypted values are submitted to Solana
- Arcium MPC nodes execute the computation over encrypted data
- The result is returned encrypted via a Solana callback
- The SDK decrypts the result locally
The MPC nodes never see any plaintext values.
License
MIT
