githubEdit

TypeScript PoD SDK (CotiPodCrypto, PodContract)

The npm package @coti/pod-sdk ships TypeScript helpers for encrypting and decrypting PoD payloads and for encoding, fee estimation, and sending calls against your host-chain contract through coti-pod-crypto.tsarrow-up-right and pod-method-call.tsarrow-up-right.

Use these helpers from a wallet script, backend service, or dApp frontend once you have a Signer (or Provider for read-only helpers) and your contract ABI.

Encrypt and decrypt data (CotiPodCrypto)

CotiPodCrypto.encrypt POSTs to the PoD encryption service:

  • "testnet" and "mainnet" resolve to SDK defaults.

  • You can also pass a full encryption service URL.

  • DataType distinguishes plaintext types (Uint64, String, etc.) from it* types that become ciphertext tuples on chain.

CotiPodCrypto.decrypt uses the user's account AES key and @coti-io/coti-sdk-typescript under the hood.

import { CotiPodCrypto, DataType } from "@coti/pod-sdk";

// Encrypt plaintext for Solidity itUint256 parameters
const enc = await CotiPodCrypto.encrypt("42", "testnet", DataType.itUint256);

// Decrypt scalar ciphertext read from contract storage
const plain = CotiPodCrypto.decrypt("0x...", accountAesKeyFromOnboarding, DataType.Uint64);

Gas estimation and method calls (PodContract)

PodContract wraps ethers.Contract with PoD-aware helpers:

  • estimateFee for Inbox two-way fee calculation.

  • encryptAndCallMethod to encrypt it* plaintext args and send the tx.

  • callMethod to send pre-encrypted JSON ciphertext values.

  • extractRequestIds(txHash) to parse Inbox MessageSent logs and recover request IDs for async tracking.

Important fee config rules

  • forwardGasLimit and gasPrice are required.

  • callBackGasLimit and callBackDataSize must be provided together (or both omitted).

  • forwardDataSize is optional; SDK can estimate from argument string sizes.

Choosing encryptAndCallMethod vs callMethod

  • Use encryptAndCallMethod when your app currently has plaintext user input.

  • Use callMethod when the app already has ciphertext JSON from a prior CotiPodCrypto.encrypt step and you want to submit it directly.

See also

Last updated

Was this helpful?