What is LiFi Contract Types?
LiFi Contract Types (lifi-contract-typings) is a TypeScript library that provides comprehensive type definitions for LiFi’s Solidity smart contracts. These typings enable type-safe interactions with LiFi’s cross-chain infrastructure, ensuring developers pass the correct values when executing bridge and swap operations.
Why LiFi Contract Types?
When building applications that interact with blockchain smart contracts, type safety is crucial to prevent costly errors. LiFi Contract Types addresses this by:- Ensuring Type Safety: Auto-generated TypeScript definitions from Solidity contracts prevent runtime errors
- Improving Developer Experience: Get autocomplete, inline documentation, and compile-time validation in your IDE
- Reducing Integration Errors: Catch parameter mismatches and type errors before deploying your code
- Maintaining Consistency: Types are automatically synchronized with the latest LiFi contract implementations
What Problems Does It Solve?
1. Type Safety for Bridge Operations
When executing cross-chain transactions, you need to pass complex data structures likeBridgeDataStruct with precise field types. Without proper typings, it’s easy to pass incorrect values:
2. Contract Factory Type Safety
Access properly typed contract factories for all LiFi facets:3. Event Listening with Type Safety
Listen to contract events with properly typed event objects:Key Features
100+ Contract Types
Complete TypeScript definitions for all LiFi contracts including bridge facets, DEX aggregators, and periphery contracts
Ethers.js v5 Compatible
Built for ethers.js v5 with full support for providers, signers, and contract interactions
Auto-generated
Typings are automatically generated from Solidity contracts using TypeChain, ensuring accuracy
Modular Exports
Import only what you need with granular exports for each contract and factory
Supported Bridge Facets
LiFi Contract Types includes typings for all major bridge integrations:- Across Protocol (V3, V4, and packed versions)
- Stargate (V2)
- Hop Protocol
- cBridge (Celer)
- Squid
- Mayan
- DeBridge DLN
- Symbiosis
- Native Bridges (Arbitrum, Optimism, Polygon, Gnosis)
- And many more…
Architecture
LiFi uses the Diamond Pattern (EIP-2535) where functionality is split into “facets” that are attached to a central diamond contract. Each facet handles specific bridge or swap protocols:Next Steps
Installation
Install the package and set up your project
Quick Start
Execute your first cross-chain bridge transaction