$ show airalab/hs-web3
This is a Haskell monorepo providing a client library for interacting with Ethereum and Polkadot blockchains. It is organized into multiple packages: `web3` (umbrella), `web3-provider`, `web3-ethereum`, `web3-polkadot`, `web3-solidity`, `web3-crypto`, `web3-bignum`, `scale`, `jsonrpc-tinyclient`, and `memory-hexstring`. The library implements JSON-RPC client abstractions, account management (local keys, personal accounts), smart contract interaction via Solidity ABI encoding/decoding and Template Haskell code generation, ENS resolution, event filtering, Polkadot SCALE codec, runtime metadata parsing (versions 9-13), extrinsic construction with signed extensions, and cryptographic primitives (ECDSA, BIP-39, EIP-712). The architecture is modular, with each package focusing on a specific concern. Key entry points include `Network.Web3.Provider` for connecting to nodes, `Network.Ethereum.Contract.TH` for generating contract bindings, and `Network.Polkadot.Extrinsic` for building and signing transactions. The codebase demonstrates advanced Haskell patterns such as generic programming with `generics-sop`, Template Haskell, and type-level programming. While the library is well-structured and covers a broad set of blockchain interactions, there are signs of technical drift: some metadata versions are partially implemented, commented-out code exists, and dependency bounds are tight. Overall, it is a solid, actively maintained library suitable for Haskell-based blockchain development.
The LLM identified 7 files worth highlighting for reuse:
Provides a newtype wrapper for hex-encoded byte arrays with safe conversions to/from ByteString, Text, and numeric types. Includes Template Haskell for compile-time hex literals. This module is self-contained within the `memory-hexstring` package and can be reused in any Haskell project requiring hex encoding/decoding.
A minimal JSON-RPC client supporting HTTP and WebSocket transports. Defines a `JsonRpc` typeclass for remote method calls and provides a `remote` combinator for type-safe RPC invocations. The module is standalone and can be extracted for any JSON-RPC service interaction.
Implements a `BigNum` type for arbitrary-precision integers used in blockchain contexts (e.g., Ethereum units, SCALE compact encoding). Provides arithmetic operations and conversions. This module is a standalone package and reusable for any project needing big integer support.
Defines the `Encode` and `Decode` typeclasses for SCALE (Simple Concatenated Aggregate Little-Endian) encoding, used by Substrate-based chains. Includes generic deriving via `GHC.Generics` and instances for standard types. While it imports internal modules from the `scale` package, the pattern of a typeclass-based codec is reusable for any SCALE implementation.
Provides `AbiPut` and `AbiGet` typeclasses for Solidity ABI encoding/decoding, with generic deriving using `generics-sop`. Supports all Solidity types including dynamic arrays and tuples. This module is central to Ethereum smart contract interaction and the pattern is reusable for any ABI-based encoding.
Implements Template Haskell quasiquoters (`abi` and `abiFrom`) that parse Solidity ABI JSON and generate Haskell data types and method bindings for smart contracts. This pattern of schema-driven code generation is reusable for any JSON-based interface definition.
Defines the `SignedExtension` typeclass for composing Polkadot extrinsic signed data (e.g., era, nonce, tip). Includes tuple instances for combining multiple extensions. This composable pattern is reusable for building extrinsics on any Substrate chain.