Skip to main content

LiFi Contract Types

Complete TypeScript type definitions for LiFi’s cross-chain bridge protocol. Build type-safe integrations with 20+ bridge providers using ethers.js v5.

TypeScript

Quick Start

Get up and running with LiFi Contract Types in minutes.

1

Install the package

Install the package using your preferred package manager:
npm install lifi-contract-typings
2

Import contract types

Import the contract types and factories you need:
import { 
  AcrossFacet,
  AcrossFacet__factory,
  ILiFi 
} from 'lifi-contract-typings';
import { ethers } from 'ethers';
The package exports both contract type definitions and factory classes for every facet.
3

Connect to a contract

Use the factory to connect to a deployed contract:
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const signer = new ethers.Wallet(PRIVATE_KEY, provider);

const acrossFacet = AcrossFacet__factory.connect(
  CONTRACT_ADDRESS,
  signer
);
4

Execute type-safe transactions

Call contract methods with full TypeScript type safety:
const bridgeData: ILiFi.BridgeDataStruct = {
  transactionId: ethers.utils.formatBytes32String('tx-123'),
  bridge: 'across',
  integrator: 'your-app',
  referrer: ethers.constants.AddressZero,
  sendingAssetId: TOKEN_ADDRESS,
  receiver: RECEIVER_ADDRESS,
  minAmount: ethers.utils.parseEther('1.0'),
  destinationChainId: 137,
  hasSourceSwaps: false,
  hasDestinationCall: false
};

const tx = await acrossFacet.startBridgeTokensViaAcross(
  bridgeData,
  acrossData
);
await tx.wait();
All struct types are fully typed, providing autocomplete and compile-time validation.

Key Features

Everything you need to build cross-chain applications with LiFi.

20+ Bridge Integrations

Support for Across, Hop, Stargate, Celer, and 15+ more bridge protocols.

Type-Safe Contracts

Full TypeScript definitions for all contracts, structs, and events.

Ethers.js v5

Built-in factory classes for seamless ethers.js integration.

Diamond Pattern

EIP-2535 Diamond Standard architecture for upgradeable contracts.

Swap Functionality

Generic DEX swap support for multi-hop cross-chain transactions.

Event Handling

Strongly-typed event listeners and filters for all contract events.

Explore by Topic

Dive deeper into specific areas of the LiFi contract ecosystem.

Core Types

BridgeData, SwapData, and core LiFi interface definitions.

Bridge Facets

Complete reference for all supported bridge protocol integrations.

Swap Facets

DEX aggregation and token swap functionality.

Utility Facets

Fee collection, withdrawals, and access management.

Ready to Build?

Start integrating LiFi’s cross-chain bridge infrastructure into your application today.