Evolution SDK
Advanced

TypeScript Tips

Advanced TypeScript patterns for Evolution SDK

TypeScript Tips

Evolution SDK leverages TypeScript's type system for safety and developer experience. Here are key patterns to know.

Type Inference from Schemas

TSchema definitions infer their TypeScript types automatically:

import {  } from "@evolution-sdk/evolution"

const  = .({
  : .,
  : .,
  : .(.)
})

// Type is inferred — no need to define separately
type  = typeof .
// { amount: bigint; recipient: Uint8Array; metadata: Uint8Array | undefined }

Branded Types

Core types like Address, TransactionHash, and PolicyId are branded — they're structurally identical to their base types but won't accidentally mix:

import {  } from "@evolution-sdk/evolution"

// Address.Address is a branded type
const  = .("addr_test1vrm9x2dgvdau8vckj4duc89m638t8djmluqw5pdrFollw8qd9k63")
// Type: Address.Address (not just any object)

Client Type Narrowing

The client type narrows based on configuration:

import {  } from "@evolution-sdk/evolution"

// Provider-only client (no wallet) — can query but not sign
const  = ({
  : "preprod",
  : { : "blockfrost", : "", : "" }
})

// Signing client (wallet + provider) — full capabilities
const  = ({
  : "preprod",
  : { : "blockfrost", : "", : "" },
  : { : "seed", : "", : 0 }
})

Effect Integration

The SDK provides both Promise and Effect APIs:

import {  } from "effect"

// Promise API — standard async/await
// const tx = await client.newTx().payToAddress({...}).build()

// Effect API — composable error handling
// const program = client.newTx().payToAddress({...}).buildEffect()
// Effect.runPromise(program)

Namespace Imports

The SDK uses namespace exports for tree-shaking optimization:

import { , , ,  } from "@evolution-sdk/evolution"

// Each namespace provides related functions
// Address.fromBech32(), Address.toHex(), Address.toBytes()
// Assets.fromLovelace(), Assets.merge(), Assets.addByHex()
// Data.constr(), Data.map(), Data.toCBORHex()

Next Steps