# Lend ERC20 Tokens - FIL as Collateral

## FIL backed ERC20 Loan

![](https://2244172924-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWQ5XrYoQYzJ0D9WZIj%2F-MbSeQSobDcmW9-7OVuM%2F-MbSfwSowdm_rxbzS8nI%2FLend%20ERC20%20-%20FIL%20Collateral%20_%20Filecoin%20Loans.png?alt=media\&token=1d8812e4-eaf7-4e93-b709-b8613b338b7d)

## Normal Flow

### Step 1: Create Loan Offer

* **Actor:** Lender
* **Blockchain:** Ethereum (or EVM compatible blockchain)
* **Action:** Create Loan Offer
* **Description:** The Lender creates a loan offer and funds the loan offer with the principal (ERC20 tokens).

### Step 2: Create Payment Channel

* **Actor:** Borrower
* **Blockchain:** Filecoin
* **Action:** Create a Payment Channel to the Lender's FIL address.
* **Description:** The Borrower creates a Payment Channel to the Lender's FIL address to lock the required collateral.

### Step 3: Create (Seize Collateral) Voucher

* **Actor:** Borrower
* **Blockchain:** Filecoin
* **Action:** Create Voucher
* **Description:** The Borrower created a Voucher to allow the Lender to seize the collateral in case of default. The Voucher can only be redeemed by the Lender by using the `secretA1`. The `secretA1` is revealed when the Borrower withdraws the loan's principal.

### Step 5: Approve Request & Sign (Unlock Collateral) Voucher&#x20;

* **Actor:** Lender
* **Blockchain:** Ethereum (or EVM compatible blockchain)
* **Action:** Approve Request & Sign Voucher
* **Description:** The Lender assigns the Loan to the borrower by entering the Borrower's ETH based address and hashed preimage (`secretHashA1`). Afterwards, the Lender signs a voucher with nonce `n+1` and `amount = 0` to allow the Borrower to unlock the collateral once the payback is accepted.

### Step 6: Withdraw Principal

* **Actor:** Borrower
* **Blockchain:** Ethereum (or EVM compatible blockchain)
* **Action:** Withdraw Principal
* **Description:** The Borrower withdraws the Loan's principal from the smart contract by revealing the `secretA1`. This secret allows the Lender to seize the collateral if the Borrower fails to pay back the loan on time.

### Step 7: Repay Loan

* **Actor:** Borrower
* **Blockchain:** Ethereum (or EVM compatible blockchain)
* **Action:** Payback
* **Description:** The Borrower pays back the loan's principal plus interests before the loan expiration date by sending the ERC20 token amount to the smart contract.

### Step 7: Accept Payback

* **Actor:** Lender
* **Blockchain:** Ethereum (or EVM compatible blockchain)
* **Action:** Accept Payback
* **Description:** To accept the Payback, the Lender reveals `secretB1` which allows the Borrower to redeem the (unlock collateral) voucher and settle the payment channel.

### Step 8: Unlock Collateral

* **Actor:** Borrower
* **Blockchain:** Filecoin
* **Action:** Unlock Collateral
* **Description:** The Borrower uses `secretB1` to redeem the (Unlock Collateral) voucher and close the payment channel.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blitslabs.gitbook.io/filecoin-loans/protocol/lend-erc20-diagram.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
