> For the complete documentation index, see [llms.txt](https://unilend.gitbook.io/unilend-finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unilend.gitbook.io/unilend-finance/unilend-v1/the-protocol/flash-loan/deploy-flashloan.md).

# Deploying Flash Loan Smart Contract

For testing purpose we always recommend using one of testnets.

#### 1. Visit Remix - Ethereum IDE

Remix IDE is a powerful open source tool that helps you write Solidity contracts straight from the browser. It is written in JavaScript and supports both usage in the browser, in the browser but run locally and in a desktop version.

{% embed url="<https://remix.ethereum.org/>" %}

#### 2. Create New Workspace and File

Start with a new workspace in Remix IDE, so that you do not clutter your existing work with UniLend Flashloan smart contract.&#x20;

<div align="center"><img src="https://3962044129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MX1e5AGCERC0KviMC4D%2F-MgeWR3KmO5SR84fUJDK%2F-MgeY1lCBnUVR4uaKvgn%2FScreen%20Shot%202021-08-09%20at%204.23.30%20PM.png?alt=media&amp;token=7a1e93e9-d6bd-4f84-a08c-68a713d2c67a" alt=""></div>

Click on **New File** and name it as **MyUniLendFlashloan.sol** (or anything preferred by you). Also copy the smart contract from previous section with your trading logic here.

![](https://3962044129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MX1e5AGCERC0KviMC4D%2F-MgeYiNrU4rKWdDU6dLD%2F-MgeaqFZJn5VUP5gW_4n%2FScreen%20Shot%202021-08-09%20at%204.40.18%20PM.png?alt=media\&token=2f0f1eb1-8223-4023-8edd-699601ac63a8)

**3. Compile the smart contract**

From the sidebar select the version 0.8.0+ in the solidity compiler and compile the code by clicking the Compile button.&#x20;

![](https://3962044129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MX1e5AGCERC0KviMC4D%2F-MgeYiNrU4rKWdDU6dLD%2F-Mgead_6F3UUadeVIzoD%2FScreen%20Shot%202021-08-09%20at%204.39.31%20PM.png?alt=media\&token=1ad917ff-eafb-4926-8009-8f6515782009)

**4. Deploying smart contract**

Select Injected Web 3 Ropsten under environment and the account in Metamask (or from any other wallet) is shown here under Account with balance ether as well.

![](https://3962044129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MX1e5AGCERC0KviMC4D%2F-MgeYiNrU4rKWdDU6dLD%2F-MgedFp90UUFZofFDu_H%2FScreen%20Shot%202021-08-09%20at%204.50.56%20PM.png?alt=media\&token=83eefbe0-a300-4a80-9484-67ef068c1c37)

**5. Add balance to your newly deployed smart contract**

Use your wallet to add balance of token equivalent or more than fee (0.05%) charged by UniLend protocol.&#x20;

![](https://3962044129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MX1e5AGCERC0KviMC4D%2F-MgeedE9WTT8MpxgJN1e%2F-MgeeeqU5z89EpwGjb-d%2FScreen%20Shot%202021-08-09%20at%204.55.36%20PM.png?alt=media\&token=06fa6ea5-cee4-475d-82f1-13cac712b35f)

**6. Call the flashloan function**

Under the Deployed Contracts sidebar find the flashloanCall function and enter the `_asset` (address of token with LP on UniLend) `_amount` and execute transact.&#x20;

![](https://3962044129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MX1e5AGCERC0KviMC4D%2F-MgekhPd69gOtCLKf-y9%2F-MgepCosYwJsuxRnSMTP%2FScreen%20Shot%202021-08-09%20at%205.43.10%20PM.png?alt=media\&token=b0635eb3-a5ab-401c-a8c8-22591b96da33)

&#x20;
