TypeScript SDK Reference
The @estamora/sdk package provides complete TypeScript abstractions for interacting with Estamora smart contracts.
- Package:
@estamora/sdk - Repository:
estamora-sdk
Installation
Classes & Methods
EstamoraClient
new EstamoraClient(config?: Partial<EstamoraClientConfig>)
Creates a client instance. If config is omitted, defaults to Stellar Testnet and contract CADQOBYHA4DQOBYHA4DQOBYHA4DQOBYHA4DQP5KR.
simulateCreateEscrow(params: CreateEscrowParams): Promise<PreflightSimulation>
Simulates the creation of an escrow off-chain. Validates: - Positive amounts and milestone breakdowns. - Expiration timestamps in the future. - Valid Stellar public keys (RFC 4648 base32 / StrKey format). - Estimated gas and CPU instructions.
simulateDelegatedPayment(params: DelegatedPaymentParams): Promise<PreflightSimulation>
Simulates a delegated payment against the agent's rolling 24-hour spend allowance.
Error Decoding
The SDK decodes raw Soroban contract errors into typed error classes:
import { decodeContractError, ContractErrorCode } from '@estamora/sdk';
try {
// transaction call
} catch (err) {
const decoded = decodeContractError(err);
console.error(`Error Code: ${decoded.code} - ${decoded.message}`);
}
Supported Contract Error Codes:
INVALID_AMOUNT(Code 1) - Amount must be positive.INVALID_TIMEOUT(Code 2) - Timeout ledger must be in the future.UNAUTHORIZED(Code 3) - Caller failed cryptographic authorization.ESCROW_NOT_FOUND(Code 4) - Escrow ID does not exist.ESCROW_EXPIRED(Code 5) - Timeout ledger has already passed.ESCROW_NOT_EXPIRED(Code 6) - Cannot refund before timeout ledger.ESCROW_ALREADY_SETTLED(Code 7) - All milestones have been released.ESCROW_IN_DISPUTE(Code 8) - Action blocked while dispute is pending.ESCROW_NOT_IN_DISPUTE(Code 9) - Dispute resolution called on active escrow.INVALID_PAYOUT_SUM(Code 10) - Payer + merchant payout sum does not match balance.EXCEEDS_PER_TX_CAP(Code 11) - Delegated amount exceeds single transaction limit.EXCEEDS_DAILY_CAP(Code 12) - Cumulative 24h spend exceeds daily cap.INVALID_MILESTONE_INDEX(Code 13) - Milestone index out of range.MILESTONE_ALREADY_RELEASED(Code 14) - Milestone has already been paid out.