This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm install # Install dependencies
npm run build # Production build (tsup, outputs ESM+CJS to dist/)
npm run build:watch # Watch mode for development
npm run lint # ESLint with auto-fix
npm link # Link package locally for testing in other projectsnpm test # Run tests with typecheck (vitest)
npm run test:watch # Watch modeThe SDK exports three entry points (see package.json exports):
genlayer-js- Main: client, accounts, transaction decoders, staking utilsgenlayer-js/chains- Chain configs:localnet,studionet,testnetAsimov,testnetBradburygenlayer-js/types- TypeScript types for all SDK entities
createClient() in src/client/client.ts builds a composable client by extending viem's base client with action modules:
baseClient → publicActions → walletActions → accountActions
→ transactionActions → chainActions → contractActions
→ receiptActions → stakingActions
Each action module (src/<domain>/actions.ts) returns an object of methods that get merged into the client. The client auto-initializes the consensus smart contract on creation.
GenLayerChain extends viem's Chain with GenLayer-specific properties:
isStudio- Whether using studio-based localnetconsensusMainContract/consensusDataContract- On-chain consensus contractsstakingContract- Staking contract (testnet-bradbury and testnet-asimov)defaultNumberOfInitialValidators/defaultConsensusMaxRotations
Custom binary encoding for GenLayer transactions in src/abi/calldata/:
encoder.ts- Encodes JS values to GenLayer binary formatdecoder.ts- Decodes binary responses back to JS- Uses MessagePack-like format with type tags
@/*→./src/*@@/tests/*→./tests/*
viem- Ethereum client, used as foundation for all blockchain interactionstypescript-parsec- Parser combinator for calldata string parsing