In late 2020, Filecoin’s circulating supply sat at around 2%. Miners needed collateral to complete storage deals. FIL holders had no way to trade the time-value of their holdings. Centralized lending services emerged to fill the gap, but they came with risks: custody loss, restricted access, and potential fund seizure.

The Filecoin blockchain lacked a Virtual Machine for external smart contracts. Only built-in actors were available. This constraint meant traditional DeFi approaches would not work. We needed a different path.

I joined the Blits Labs team to help build Filecoin Loans, the first decentralized, non-custodial lending protocol native to Filecoin.

What it does

Filecoin Loans enables cross-chain collateralized loans between Filecoin and EVM-compatible blockchains. Users can borrow ERC20 stablecoins by locking native FIL as collateral. They can also do the reverse: borrow FIL by locking ERC20 tokens.

The protocol runs as a peer-to-peer system. No intermediaries, bridges, or validators stand between users. Both parties maintain custody of their assets throughout the loan lifecycle.

Borrowers create loan requests by locking collateral. Lenders fund those requests with the desired principal. When borrowers repay, they unlock their collateral. If they default, lenders can seize the collateral. All of this happens without trusting a third party.

Technical deep-dive

The protocol builds on the Atomic Loans paper, originally conceptualized for Bitcoin and Ethereum. We adapted it for Filecoin.

Hash Time Locked Contracts across chains

Filecoin’s Payment Channel actor became our Hash Time Locked Contract (HTLC) primitive. Payment channels allow conditional transfers based on secret revelation within time constraints. We repurposed this mechanism to coordinate actions across two independent blockchains.

Both parties generate cryptographic secrets before the loan begins. These secrets and their hashes drive the state machine. When one party reveals a secret on one chain, it unlocks actions on the other chain. This atomic swap pattern ensures neither party can cheat without losing their stake.

Blake2b-256 on Ethereum

Filecoin uses Blake2b-256 for hashing. Ethereum does not support this natively. We needed to verify Filecoin secret hashes on EVM chains.

We updated a Solidity implementation of Blake2b from ConsenSys, originally built for EIP-152. The modified library outputs the Blake2b-256 variant that Filecoin uses. This allows our Ethereum contracts to validate secrets that originated on Filecoin.

Custom signing library

At the time, existing Filecoin signing tools written in Rust and WASM required loading WebAssembly binaries. This added complexity to React Native and web environments.

We built Filecoin JS Signer, a pure TypeScript library for interacting with Filecoin’s built-in actors. It handles message creation and signing for Payment Channels. No WASM dependencies. It runs natively in JavaScript environments.

The library also needed modifications to support preimages and secret hashes in voucher creation and redemption. These are the building blocks of our HTLC pattern.

Smart contract architecture

Two main contracts manage the EVM side:

The first handles loan offers where lenders lock ERC20 tokens. It tracks loan state: funded, approved, withdrawn, repaid, or closed. Borrowers accept offers by providing their Filecoin address and a secret hash. The contract releases funds when valid secrets are revealed.

The second manages collateral locks for borrowers wanting FIL. It holds ERC20 collateral with price oracles determining liquidation thresholds. A minimum 110% collateralization ratio protects lenders from FIL price drops.

Both contracts enforce time-based expirations. If one party disappears, the other can recover their funds after the deadline passes.

The monorepo

The project spans four main components:

  • Solidity contracts for EVM chains
  • A Node.js backend API for loan coordination
  • A React web application for browser-based access
  • A React Native mobile wallet for iOS and Android

The mobile wallet integrates directly with Blits Wallet, giving users a native experience for managing cross-chain loans from their phone.

Learnings

Building DeFi on a blockchain without smart contracts pushed us toward creative solutions. Payment Channels became our programmability layer. Cryptographic secrets replaced on-chain logic.

The constraint forced simplicity. Every cross-chain message had real costs. We designed the protocol to minimize round trips while maintaining security guarantees.

Cross-chain development requires thinking in state machines that span multiple systems. Failure modes multiply. Time synchronization matters. We learned to design for partial failures and ensure every state had a recovery path.

Back to Projects