Uploader
TheUploader sub-client handles vault allocation, TDH2 encryption, and writing encrypted data on-chain. Requires a walletClient.
Methods
- uploadCDR
- allocate
- write
- encryptDataKey
uploadCDR
High-level method that allocates a vault, encrypts your data, and writes the ciphertext in a single call.| Method | Type |
|---|---|
uploadCDR | (params: UploadCDRParams) => Promise<UploadCDRResponse> |
params.dataKey:Uint8Array- The secret data to encrypt (arbitrary bytes, up to 32 bytes for a key)params.globalPubKey:Uint8Array- The DKG global public key (fromobserver.getGlobalPubKey())params.updatable:boolean- Whether the vault can be rewritten after initial writeparams.writeConditionAddr:`0x${string}`- Address of the write condition contract (or wallet address for simple access)params.readConditionAddr:`0x${string}`- Address of the read condition contract (or wallet address for simple access)params.writeConditionData:`0x${string}`- ABI-encoded data passed to the write conditionparams.readConditionData:`0x${string}`- ABI-encoded data passed to the read conditionparams.accessAuxData:`0x${string}`- Auxiliary data passed to conditions during writeparams.allocateFeeOverride(optional):bigint- Skip fee query and use this valueparams.writeFeeOverride(optional):bigint- Skip fee query and use this value
Example
UploadCDRResponse
allocate
Creates a new CDR vault on-chain with the specified access control conditions.| Method | Type |
|---|---|
allocate | (params: AllocateParams) => Promise<AllocateResponse> |
params.updatable:boolean- Whether the vault can be rewrittenparams.writeConditionAddr:`0x${string}`- Write condition contract addressparams.readConditionAddr:`0x${string}`- Read condition contract addressparams.writeConditionData:`0x${string}`- ABI-encoded write condition dataparams.readConditionData:`0x${string}`- ABI-encoded read condition dataparams.feeOverride(optional):bigint- Skip fee query
Example
AllocateResponse
write
Writes encrypted data to an existing vault. The caller must satisfy the vault’s write condition.| Method | Type |
|---|---|
write | (params: WriteParams) => Promise<WriteResponse> |
params.uuid:number- The vault UUIDparams.accessAuxData:`0x${string}`- Auxiliary data passed to the write conditionparams.encryptedData:`0x${string}`- Hex-encoded TDH2 ciphertextparams.feeOverride(optional):bigint- Skip fee query
Example
WriteResponse
encryptDataKey
Locally encrypts data using TDH2 threshold encryption. No blockchain interaction.| Method | Type |
|---|---|
encryptDataKey | (params: EncryptParams) => Promise<TDH2Ciphertext> |
params.dataKey:Uint8Array- The plaintext data to encryptparams.globalPubKey:Uint8Array- DKG global public key (34 bytes)params.label:Uint8Array- 32-byte label binding ciphertext to a vault (useuuidToLabel(uuid))
Example
TDH2Ciphertext

