This example uses the BITE V2 Sandbox 2. Contact the SKALE Team in https://discord.gg for access.
How CTX Works
- Encrypt off-chain: Use
bite.encryptMessage()to encrypt data - Submit to contract: Send encrypted data to a smart contract
- Request decryption: Contract calls
BITE.submitCTX()to create a Conditional Transaction - Next block: SKALE consensus decrypts and calls
onDecrypt()callback with decrypted values
Prerequisites
- Node.js 18+ and bun or npm
@skalenetwork/biteTypeScript SDK@skalenetwork/bite-soliditySolidity helpers- Access to BITE V2 Sandbox 2
Project Setup
- Hardhat
- Foundry
Smart Contract
CreateSimpleSecret.sol:
Key Points
IBiteSupplicantrequires implementingonDecrypt()callbackBITE.submitCTX()creates the Conditional TransactionBITE.SUBMIT_CTX_ADDRESSis the predeployed CTX handlerctxSenderstores the address that will call back - used for security
Test Script
Createrun-simple.ts:
Running
- Hardhat
- Foundry
Resources
- BITE API Reference: BITE API
- Repository: https://github.com/skalenetwork/bite-ts
- Solidity Helpers: https://github.com/skalenetwork/bite-solidity
- How BITE Works: How BITE Works
- Tutorial: Conditional Transactions Demo
