Skip to content

TypeScript SDK

Home · Top · Table of Contents

Table of Contents

Kevin K. Le (LinkedIn) — Founder, Founding Engineer, and Current Lead Engineer; Software Engineer at the Oregon Blockchain Group, University of Oregon.

Kellen Snider — Founding Engineer; Software Engineer at the Oregon Blockchain Group, University of Oregon. His vision, ideas, and dedication during TrustLedger's Ethereum development were invaluable to the codebase we build on today.

See CREDITS.md.

This document explains the TypeScript integration surfaces available in TrustLedger. Read it when writing scripts, tests, frontend calls, or external TypeScript clients.

Integration Surfaces

Home · Top · Table of Contents

Surface Path Use
Hardhat scripts scripts/*.ts Deploy, wire contracts, check balances, sync frontend env.
Hardhat tests test/TrustLedger.test.ts Ethers v6 TypeScript contract tests.
Shared frontend types src/types/*.ts Frontend TypeScript domain helpers exported through @/types.
Frontend ABI src/lib/abi.ts ABI exports used by the Next.js app.
Frontend wagmi helpers src/lib/wagmi.ts Network, address, explorer, and USDC helper functions.
TypeChain output artifacts/typechain-types Generated after Hardhat compile.

Compile Before Using TypeChain

Home · Top · Table of Contents

Run:

npm run compile

Hardhat compiles contracts/src, writes artifacts under artifacts/, and generates TypeChain wrappers under artifacts/typechain-types with target ethers-v6.

Script Patterns

Home · Top · Table of Contents

Run Hardhat scripts with the configured TypeScript project:

TS_NODE_PROJECT=tsconfig.hardhat.json hardhat run scripts/deploy.ts --network sepolia

Use the package scripts where possible:

npm run hardhat:deploy:sepolia
npm run hardhat:wire-reputation:sepolia
npm run sync:frontend:env

Frontend Helpers

Home · Top · Table of Contents

src/lib/wagmi.ts exports:

Export Purpose
ZERO_ADDRESS Canonical zero address string.
TRUSTLEDGER_ADDRESS Default TrustLedger address from env or zero address.
ARBITRATION_ADDRESS Default Arbitration address from env or zero address.
JUROR_REGISTRY_ADDRESS Default JurorRegistry address from env or zero address.
REPUTATION_REGISTRY_ADDRESS Default ReputationRegistry address from env or zero address.
getContractDeployment Resolve deployment addresses for a chain ID.
getNetworkName Return a display name for a chain ID.
getConfiguredDeploymentNetworkNames Return networks with configured TrustLedger addresses.
getUsdcAddress Return the configured or default USDC address for supported chains.
getExplorerTxUrl Build a transaction URL for a supported chain.
config wagmi config built by Reown AppKit.

Example Contract Address Lookup

Home · Top · Table of Contents

import { getContractDeployment, getExplorerTxUrl } from "./lib/wagmi";

const chainId = 11155111;
const deployment = getContractDeployment(chainId);
const txUrl = getExplorerTxUrl(chainId, "0x...");

console.log(deployment.trustLedger, txUrl);

ABI Usage

Home · Top · Table of Contents

Use src/lib/abi.ts for frontend contract calls. Use TypeChain output for Hardhat scripts and tests after npm run compile.

Do not hardcode deployment addresses in scripts or frontend code. Read them from deployment artifacts or environment variables documented in Environment.

Authors and Contributors

Home · Top · Table of Contents

  • Kevin K. Le — Founder, Founding Engineer, and Current Lead Engineer (LinkedIn)
  • Kellen Snider — Founding Engineer (LinkedIn)

See CREDITS.md for the complete acknowledgement list.

Home · Top · Table of Contents

This document is part of TrustLedger, an open-source decentralized escrow and arbitration protocol. Use of this software and documentation is subject to the Terms and Conditions, Privacy Policy, and Risk Disclosure. See LEGAL.md for the full compliance and licensing overview.