Network
Launch Date
Consensus
Note
Sepolia
Oct 2021
PoW
Like-for-like representation of Ethereum
Görli
Jan 2019
PoA
Proof-of-Authority
Kiln
Mar 2022
PoS
Post-Merge (for ETH2), shadow fork of the mainnet
Kintsugi
Dec 2021
PoS
DEPRECATED, use Kiln; post-Merge (for ETH2)
Ropsten
Nov 2016
PoW
DEPRECATED, use Sepolia; the Merge to happen on Jun 8, 2022
Rinkeby
Apr 2017
PoA
DEPRECATED, use Görli and Görli Faucet
Kovan
Mar 2017
PoA
DEPRECATED, use Sepolia or Görli
List of active and deprecated Ethereum testnets, including Kintsugi.
Features
Optimistic rollup 
ZK-rollup 
Proof
Uses fraud proofs to prove transaction validity. 
Uses validity (zero-knowledge) proofs to prove transaction validity. 
Capital efficiency
Requires waiting through a 1-week delay (dispute period) before withdrawing funds. 
Users can withdraw funds immediately because validity proofs provide incontrovertible evidence of the authenticity of off-chain transactions. 
Data compression
Publishes full transaction data as calldata to Ethereum Mainnet, which increases rollup costs. 
Doesn't need to publish transaction data on Ethereum because ZK-SNARKs and ZK-STARKs already guarantee the accuracy of the rollup state. 
EVM compatibility
Uses a simulation of the Ethereum Virtual Machine (EVM), which allows it to run arbitrary logic and support smart contracts. 
Doesn't widely support EVM computation, although a few EVM-compatible ZK-rollups have appeared. 
Rollup costs
Reduces costs since it publishes minimal data on Ethereum and doesn't have to post proofs for transactions, except in special circumstances. 
Faces higher overhead from costs involved in generating and verifying proofs for every transaction block. ZK proofs require specialized, expensive hardware to create and have high on-chain verification costs. 
Trust assumptions
Doesn't require a trusted setup. 
Requires a trusted setup to work. 
Liveness requirements
Verifiers are needed to keep tabs on the actual rollup state and the one referenced in the state root to detect fraud. 
Users don't need someone to watch the L2 chain to detect fraud. 
Security properties 
Relies on cryptoeconomic incentives to assure users of rollup security. 
Relies on cryptographic guarantees for security. 
Start building
on Alchemy.
Sign up for free
Start building on Optimism.
Sign up for free
Start building on Arbitrum.
Sign up for free
Start building on Ethereum.
Sign up for free
Start building on Polygon.
Sign up for free
Start building on Starknet.
Sign up for free
Start building on Flow.
Sign up for free
kiln faucet
Get free Kiln ETH.
Start building today
Goerli faucet
Get free Goerli ETH.
Start building today
mumbai faucet
Get free Mumbai Matic.
Start building today
rinkeby faucet
Get free Rinkeby
ETH.
Start building today
Start building on Ethereum.
Get started for free
Start building on Ethereum.
Get started for free
Start building on Flow.
Get started for free
Start building on Polygon.
Get started for free
Start building on Starknet.
Get started for free
Start building on Optimism.
Get started for free
Start building on Solana.
Get started for free
Start building on Solana.
Sign up for beta access
Start building on Solana.
Join the waitlist
Arbitrum logo
Start building on Arbitrum.
Get started for free
Learn
Solidity at
Alchemy
University
Get started today
curl 
https://release.solana.com/v1.10.32/solana-install-init-x86_64-pc-windows-msvc.exe 
--output 
C:\solana-install-tmp\solana-install-init.exe 
--create-dirs
DeFi
FLASH LOAN OVERVIEW

Creating a Flash Loan using Aave

Definitions, Uses, and Developer Walkthrough
Last Updated:
April 7, 2022

Introduction

In this tutorial, we will: 

  • Create and deploy a Flash loan smart contract
  • Receive funding with the liquidity protocol called Aave 
  • Transact with our deployed contract to execute a Flash loan

Before we begin, let's look at each of the building blocks of this project: 

What is a flash loan?

In traditional finance, borrowers many times are required to offer collateral to receive a loan. This collateral is usually in the form of an asset like a car or home. Banks use this collateral as security to cover losses if the borrower fails to pay. 

In the world of Decentralized Finance(DeFi), a borrower can receive a loan without the need for providing collateral by using flash loans.

In a flash loan, lenders can both provide a loan to a borrower and be paid back for that loan in a single transaction. This is possible because of the time that a transaction is started and when it is finally committed to a block on the blockchain. 

Here are the steps of a flash loan: 

1. Borrower executes a Flash loan smart contract

2. A flash loan contract requests a loan amount from the liquidity pool 

3. The contract then uses loan funds to execute defined operations (eg trading on an exchange) 

4. After operations are completed, the borrowed funds are returned to the liquidity pool 

5. The transaction is committed to the blockchain 

Smart contracts allow us to validate that: 

  • The flash loan has the required funds to perform the operations in the smart contract. 
  • The operations are complete before the transaction is added to a new block 
  • The operations do not result in a loss of funds for the borrower. 
  • The lending pool is paid back the correct amount + a transaction fee for using the protocol. 

The borrower can do whatever they like with the funds as long as the lender is paid back the corrected lent amount. Some popular use cases of Flash Loans are: 

 - Trading Arbitrage - taking a token from one exchange to another exchange with a higher value to make a profit

 - Collateral Swap - swapping tokens of collateralized loans to another token as collateral for an existing loan

 - Self-Liquidation - repaying a collateralized loan by swapping tokens and repaying the flash loan 

Before a flash loan contract executes, the contract needs to be funded. Flash loan funding typically comes through one main lending protocol, Aave

The mechanisms of a flash loan allow for easy borrowing because they do not require any collateral. This feature can also open a flash loan up to attackers that perform flash loan attacks. A flash loan attack is when a borrower borrows some funds, manipulates the price of the asset, and then returns the borrowed asset at a large profit to themselves. This is usually done either by compromising the pricing oracle or creating artificial movements in the market. Choosing decentralized oracles like Chainlink and auditing smart contracts through services like OpenZepplin are steps to prevent these types of attacks. 

 

What is Aave?

With traditional loans, banks provide funding. In DeFi, the Aave Protocol is the largest source of funding for flash loans. Aave allows users to supply liquidity pools of ERC20 Tokens. Borrowers can then use these pools to receive loans. Depending on the type of loan, borrowers pay an interest rate which goes to the suppliers to receive interest on the tokens they supply. Currently the Aave protocol also charges a transaction fee of 0.09%.   

Let's look at how all these concepts come together to create a flash loan: 

Requirements

 - Access to Remix IDE 

- Creation of a Metamask Wallet 

- Access to the Github Gists - Smart Contract Code 

Getting the smart contract code

1 ) Open up a new workspace in the Remix IDE. 

2) In a separate tab, open up the Github Gists here. This contains the smart contract code that we will use to create our flash loan. 

3) Create new contract files in the Remix IDE with the exact naming below and copy and paste the code connected to that file (6): 

- Flashloan.sol 

- FlashloanRecieverBase.sol

- IFlashLoanReciever.sol

- ILendingPool.sol

- ILendingPoolAnddressesProvider.sol

- Withdrawable.sol

About the contracts

Flashloan.sol - This is the flash loan smart contract. It contains an ExecuteOperation function that the contract 

will call to complete the operations that will use the funds from the loan. 

FlashLoanRecieverBase.sol / IFlashLoanReciever.sol   - This is what allows the contract to receive funds for the flash loan

ILendingPool.sol  / ILendingPoolAddressProvider.sol  - Points to the Aave lending pools that will fund the flash loan

Withdrawable.sol - Allows for other contracts to withdraw funds from this contract in the case of incorrect or stuck funds 

Add funds to wallet

We will be using the Kovan Test Network in order to deploy and execute our flash loan contract. We need to have funds in our wallet in order to do this successfully: 

1. Go to https://faucets.chain.link/kovan

2. Enter your Wallet Address: 

- How to get your wallet address 

- Select the Kovan Network on your Metamask Wallet 

3. Make sure to select .1 Test Eth

4. Wait for confirmation that the tokens have been transferred

5. Funds should be added to your Metamask Wallet 

Deploy the contract

Now that we have some funds in our wallet, it is now time that we deploy the smart contract to the Kovan Testnet so that we can execute and interact with it. 

1) Go to the Solidity Compiler on the side panel inside Remix

2) Use the settings below: 

Compiler: 0.6.6+comitt.6c…

Language: Solidity 

EVM Version: Default 

Compile Flashloan.sol 

4) Click 'Compile' - You may receive some warnings but no errors if done successfully 

After compiling the flash loan smart contract, we need to deploy it: 

1) Go to the 'Deploy and Run Transactions' tab

2) Use the following settings: 

Environment: Injected Web3

Account: Copy and Paste Your Kovan Wallet Address

Contract: Flashloan - contracts/Flashloan

3) Add the Lending Pool Contract as the address_addressProvider: 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5 . This is the address for the lending provider for Aave. You can find other contract addresses here

4) Click 'Deploy’

5) Metamask should popup for you to 'Confirm' the transaction. Inside your terminal, you’ll see the link to view your transaction on etherscan

 

Add funds to the flash loan

Our smart contract has now been deployed to the Kovan Test Network. We will need to add funds to the contract from the testnet lending pool of Aave. 

1. Go to this page: https://staging.aave.com/?marketName=proto_kovan

2. Connect Your Metamask Wallet 

3. Make sure that you’re using the 'Kovan Ethereum Market'. There will be a small 'K'

Note: You may need to enable ‘Testnet mode’ in your settings. 

4. Supply some test Eth to Aave by clicking on the ‘Supply’ button under ‘Assets to supply’ . We can start with .001

5. Then borrow some DAI by clicking on the ‘Borrow’ button next to DAI. Borrow 10 DAI. 

5. Metamask should open up to confirm the transaction and the DAI will show up in your wallet once the transaction is complete:

6. If this is the first time receiving DAI, you will need to set up your wallet so that you can see DAI in your wallet.

  • Go to ‘Import Tokens’ inside Metamask 
  • Enter the DAI contract address for Kovan: 0xFf795577d9AC8bD7D90Ee22b6C170349 

7. Once you have DAI inside your wallet, send 10 DAI to your deployed contract. You can get your deployed contract address by copying it from Remix: 

Then send it to the address using Metamask: 

Execute the flash loan contract

Now we need to call Aave’s KovanTestnet DAI contract to indicate what asset we will be using in order to execute the smart contract.

1. Go back to your Remix IDE and to the 'Deploy & Run Transactions' tab

2. Under 'Deployed Contracts' you will see your flash loan and contract address 

3. Go to the text field labeled ‘address asset’ next to the label 'flashloan'

4. Enter this contract address in address_asset field: 0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD . Then click on the flashloan label button in order to start the transaction.

5. This will start the flash loan process and generate 3 transactions on etherscan.

The first transaction is from the lending pool to our flash loan contract. Since we did not include any operations to the smart contract, the amount is returned to the lending pool plus an additional fee. The last transaction is the interest for the amount borrowed, which would go to the suppliers of the liquidity pool. 

ALCHEMY SUPERNODE - ETHEREUM NODE API

Scale to any size, without any errors

Alchemy Supernode finally makes it possible to scale blockchain applications without all the headaches. Plus, our legendary support will guide you every step of the way.

Get started for free
Supernode footer
DeFi
FLASH LOAN OVERVIEW

Creating a Flash Loan using Aave

Definitions, Uses, and Developer Walkthrough
Last Updated:
April 7, 2022
Don't miss an update
Sign up for our newsletter to get alpha, key insights, and killer resources.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Introduction

In this tutorial, we will: 

  • Create and deploy a Flash loan smart contract
  • Receive funding with the liquidity protocol called Aave 
  • Transact with our deployed contract to execute a Flash loan

Before we begin, let's look at each of the building blocks of this project: 

What is a flash loan?

In traditional finance, borrowers many times are required to offer collateral to receive a loan. This collateral is usually in the form of an asset like a car or home. Banks use this collateral as security to cover losses if the borrower fails to pay. 

In the world of Decentralized Finance(DeFi), a borrower can receive a loan without the need for providing collateral by using flash loans.

In a flash loan, lenders can both provide a loan to a borrower and be paid back for that loan in a single transaction. This is possible because of the time that a transaction is started and when it is finally committed to a block on the blockchain. 

Here are the steps of a flash loan: 

1. Borrower executes a Flash loan smart contract

2. A flash loan contract requests a loan amount from the liquidity pool 

3. The contract then uses loan funds to execute defined operations (eg trading on an exchange) 

4. After operations are completed, the borrowed funds are returned to the liquidity pool 

5. The transaction is committed to the blockchain 

Smart contracts allow us to validate that: 

  • The flash loan has the required funds to perform the operations in the smart contract. 
  • The operations are complete before the transaction is added to a new block 
  • The operations do not result in a loss of funds for the borrower. 
  • The lending pool is paid back the correct amount + a transaction fee for using the protocol. 

The borrower can do whatever they like with the funds as long as the lender is paid back the corrected lent amount. Some popular use cases of Flash Loans are: 

 - Trading Arbitrage - taking a token from one exchange to another exchange with a higher value to make a profit

 - Collateral Swap - swapping tokens of collateralized loans to another token as collateral for an existing loan

 - Self-Liquidation - repaying a collateralized loan by swapping tokens and repaying the flash loan 

Before a flash loan contract executes, the contract needs to be funded. Flash loan funding typically comes through one main lending protocol, Aave

The mechanisms of a flash loan allow for easy borrowing because they do not require any collateral. This feature can also open a flash loan up to attackers that perform flash loan attacks. A flash loan attack is when a borrower borrows some funds, manipulates the price of the asset, and then returns the borrowed asset at a large profit to themselves. This is usually done either by compromising the pricing oracle or creating artificial movements in the market. Choosing decentralized oracles like Chainlink and auditing smart contracts through services like OpenZepplin are steps to prevent these types of attacks. 

 

What is Aave?

With traditional loans, banks provide funding. In DeFi, the Aave Protocol is the largest source of funding for flash loans. Aave allows users to supply liquidity pools of ERC20 Tokens. Borrowers can then use these pools to receive loans. Depending on the type of loan, borrowers pay an interest rate which goes to the suppliers to receive interest on the tokens they supply. Currently the Aave protocol also charges a transaction fee of 0.09%.   

Let's look at how all these concepts come together to create a flash loan: 

Requirements

 - Access to Remix IDE 

- Creation of a Metamask Wallet 

- Access to the Github Gists - Smart Contract Code 

Getting the smart contract code

1 ) Open up a new workspace in the Remix IDE. 

2) In a separate tab, open up the Github Gists here. This contains the smart contract code that we will use to create our flash loan. 

3) Create new contract files in the Remix IDE with the exact naming below and copy and paste the code connected to that file (6): 

- Flashloan.sol 

- FlashloanRecieverBase.sol

- IFlashLoanReciever.sol

- ILendingPool.sol

- ILendingPoolAnddressesProvider.sol

- Withdrawable.sol

About the contracts

Flashloan.sol - This is the flash loan smart contract. It contains an ExecuteOperation function that the contract 

will call to complete the operations that will use the funds from the loan. 

FlashLoanRecieverBase.sol / IFlashLoanReciever.sol   - This is what allows the contract to receive funds for the flash loan

ILendingPool.sol  / ILendingPoolAddressProvider.sol  - Points to the Aave lending pools that will fund the flash loan

Withdrawable.sol - Allows for other contracts to withdraw funds from this contract in the case of incorrect or stuck funds 

Add funds to wallet

We will be using the Kovan Test Network in order to deploy and execute our flash loan contract. We need to have funds in our wallet in order to do this successfully: 

1. Go to https://faucets.chain.link/kovan

2. Enter your Wallet Address: 

- How to get your wallet address 

- Select the Kovan Network on your Metamask Wallet 

3. Make sure to select .1 Test Eth

4. Wait for confirmation that the tokens have been transferred

5. Funds should be added to your Metamask Wallet 

Deploy the contract

Now that we have some funds in our wallet, it is now time that we deploy the smart contract to the Kovan Testnet so that we can execute and interact with it. 

1) Go to the Solidity Compiler on the side panel inside Remix

2) Use the settings below: 

Compiler: 0.6.6+comitt.6c…

Language: Solidity 

EVM Version: Default 

Compile Flashloan.sol 

4) Click 'Compile' - You may receive some warnings but no errors if done successfully 

After compiling the flash loan smart contract, we need to deploy it: 

1) Go to the 'Deploy and Run Transactions' tab

2) Use the following settings: 

Environment: Injected Web3

Account: Copy and Paste Your Kovan Wallet Address

Contract: Flashloan - contracts/Flashloan

3) Add the Lending Pool Contract as the address_addressProvider: 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5 . This is the address for the lending provider for Aave. You can find other contract addresses here

4) Click 'Deploy’

5) Metamask should popup for you to 'Confirm' the transaction. Inside your terminal, you’ll see the link to view your transaction on etherscan

 

Add funds to the flash loan

Our smart contract has now been deployed to the Kovan Test Network. We will need to add funds to the contract from the testnet lending pool of Aave. 

1. Go to this page: https://staging.aave.com/?marketName=proto_kovan

2. Connect Your Metamask Wallet 

3. Make sure that you’re using the 'Kovan Ethereum Market'. There will be a small 'K'

Note: You may need to enable ‘Testnet mode’ in your settings. 

4. Supply some test Eth to Aave by clicking on the ‘Supply’ button under ‘Assets to supply’ . We can start with .001

5. Then borrow some DAI by clicking on the ‘Borrow’ button next to DAI. Borrow 10 DAI. 

5. Metamask should open up to confirm the transaction and the DAI will show up in your wallet once the transaction is complete:

6. If this is the first time receiving DAI, you will need to set up your wallet so that you can see DAI in your wallet.

  • Go to ‘Import Tokens’ inside Metamask 
  • Enter the DAI contract address for Kovan: 0xFf795577d9AC8bD7D90Ee22b6C170349 

7. Once you have DAI inside your wallet, send 10 DAI to your deployed contract. You can get your deployed contract address by copying it from Remix: 

Then send it to the address using Metamask: 

Execute the flash loan contract

Now we need to call Aave’s KovanTestnet DAI contract to indicate what asset we will be using in order to execute the smart contract.

1. Go back to your Remix IDE and to the 'Deploy & Run Transactions' tab

2. Under 'Deployed Contracts' you will see your flash loan and contract address 

3. Go to the text field labeled ‘address asset’ next to the label 'flashloan'

4. Enter this contract address in address_asset field: 0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD . Then click on the flashloan label button in order to start the transaction.

5. This will start the flash loan process and generate 3 transactions on etherscan.

The first transaction is from the lending pool to our flash loan contract. Since we did not include any operations to the smart contract, the amount is returned to the lending pool plus an additional fee. The last transaction is the interest for the amount borrowed, which would go to the suppliers of the liquidity pool. 

Introduction

In this tutorial, we will: 

  • Create and deploy a Flash loan smart contract
  • Receive funding with the liquidity protocol called Aave 
  • Transact with our deployed contract to execute a Flash loan

Before we begin, let's look at each of the building blocks of this project: 

What is a flash loan?

In traditional finance, borrowers many times are required to offer collateral to receive a loan. This collateral is usually in the form of an asset like a car or home. Banks use this collateral as security to cover losses if the borrower fails to pay. 

In the world of Decentralized Finance(DeFi), a borrower can receive a loan without the need for providing collateral by using flash loans.

In a flash loan, lenders can both provide a loan to a borrower and be paid back for that loan in a single transaction. This is possible because of the time that a transaction is started and when it is finally committed to a block on the blockchain. 

Here are the steps of a flash loan: 

1. Borrower executes a Flash loan smart contract

2. A flash loan contract requests a loan amount from the liquidity pool 

3. The contract then uses loan funds to execute defined operations (eg trading on an exchange) 

4. After operations are completed, the borrowed funds are returned to the liquidity pool 

5. The transaction is committed to the blockchain 

Smart contracts allow us to validate that: 

  • The flash loan has the required funds to perform the operations in the smart contract. 
  • The operations are complete before the transaction is added to a new block 
  • The operations do not result in a loss of funds for the borrower. 
  • The lending pool is paid back the correct amount + a transaction fee for using the protocol. 

The borrower can do whatever they like with the funds as long as the lender is paid back the corrected lent amount. Some popular use cases of Flash Loans are: 

 - Trading Arbitrage - taking a token from one exchange to another exchange with a higher value to make a profit

 - Collateral Swap - swapping tokens of collateralized loans to another token as collateral for an existing loan

 - Self-Liquidation - repaying a collateralized loan by swapping tokens and repaying the flash loan 

Before a flash loan contract executes, the contract needs to be funded. Flash loan funding typically comes through one main lending protocol, Aave

The mechanisms of a flash loan allow for easy borrowing because they do not require any collateral. This feature can also open a flash loan up to attackers that perform flash loan attacks. A flash loan attack is when a borrower borrows some funds, manipulates the price of the asset, and then returns the borrowed asset at a large profit to themselves. This is usually done either by compromising the pricing oracle or creating artificial movements in the market. Choosing decentralized oracles like Chainlink and auditing smart contracts through services like OpenZepplin are steps to prevent these types of attacks. 

 

What is Aave?

With traditional loans, banks provide funding. In DeFi, the Aave Protocol is the largest source of funding for flash loans. Aave allows users to supply liquidity pools of ERC20 Tokens. Borrowers can then use these pools to receive loans. Depending on the type of loan, borrowers pay an interest rate which goes to the suppliers to receive interest on the tokens they supply. Currently the Aave protocol also charges a transaction fee of 0.09%.   

Let's look at how all these concepts come together to create a flash loan: 

Requirements

 - Access to Remix IDE 

- Creation of a Metamask Wallet 

- Access to the Github Gists - Smart Contract Code 

Getting the smart contract code

1 ) Open up a new workspace in the Remix IDE. 

2) In a separate tab, open up the Github Gists here. This contains the smart contract code that we will use to create our flash loan. 

3) Create new contract files in the Remix IDE with the exact naming below and copy and paste the code connected to that file (6): 

- Flashloan.sol 

- FlashloanRecieverBase.sol

- IFlashLoanReciever.sol

- ILendingPool.sol

- ILendingPoolAnddressesProvider.sol

- Withdrawable.sol

About the contracts

Flashloan.sol - This is the flash loan smart contract. It contains an ExecuteOperation function that the contract 

will call to complete the operations that will use the funds from the loan. 

FlashLoanRecieverBase.sol / IFlashLoanReciever.sol   - This is what allows the contract to receive funds for the flash loan

ILendingPool.sol  / ILendingPoolAddressProvider.sol  - Points to the Aave lending pools that will fund the flash loan

Withdrawable.sol - Allows for other contracts to withdraw funds from this contract in the case of incorrect or stuck funds 

Add funds to wallet

We will be using the Kovan Test Network in order to deploy and execute our flash loan contract. We need to have funds in our wallet in order to do this successfully: 

1. Go to https://faucets.chain.link/kovan

2. Enter your Wallet Address: 

- How to get your wallet address 

- Select the Kovan Network on your Metamask Wallet 

3. Make sure to select .1 Test Eth

4. Wait for confirmation that the tokens have been transferred

5. Funds should be added to your Metamask Wallet 

Deploy the contract

Now that we have some funds in our wallet, it is now time that we deploy the smart contract to the Kovan Testnet so that we can execute and interact with it. 

1) Go to the Solidity Compiler on the side panel inside Remix

2) Use the settings below: 

Compiler: 0.6.6+comitt.6c…

Language: Solidity 

EVM Version: Default 

Compile Flashloan.sol 

4) Click 'Compile' - You may receive some warnings but no errors if done successfully 

After compiling the flash loan smart contract, we need to deploy it: 

1) Go to the 'Deploy and Run Transactions' tab

2) Use the following settings: 

Environment: Injected Web3

Account: Copy and Paste Your Kovan Wallet Address

Contract: Flashloan - contracts/Flashloan

3) Add the Lending Pool Contract as the address_addressProvider: 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5 . This is the address for the lending provider for Aave. You can find other contract addresses here

4) Click 'Deploy’

5) Metamask should popup for you to 'Confirm' the transaction. Inside your terminal, you’ll see the link to view your transaction on etherscan

 

Add funds to the flash loan

Our smart contract has now been deployed to the Kovan Test Network. We will need to add funds to the contract from the testnet lending pool of Aave. 

1. Go to this page: https://staging.aave.com/?marketName=proto_kovan

2. Connect Your Metamask Wallet 

3. Make sure that you’re using the 'Kovan Ethereum Market'. There will be a small 'K'

Note: You may need to enable ‘Testnet mode’ in your settings. 

4. Supply some test Eth to Aave by clicking on the ‘Supply’ button under ‘Assets to supply’ . We can start with .001

5. Then borrow some DAI by clicking on the ‘Borrow’ button next to DAI. Borrow 10 DAI. 

5. Metamask should open up to confirm the transaction and the DAI will show up in your wallet once the transaction is complete:

6. If this is the first time receiving DAI, you will need to set up your wallet so that you can see DAI in your wallet.

  • Go to ‘Import Tokens’ inside Metamask 
  • Enter the DAI contract address for Kovan: 0xFf795577d9AC8bD7D90Ee22b6C170349 

7. Once you have DAI inside your wallet, send 10 DAI to your deployed contract. You can get your deployed contract address by copying it from Remix: 

Then send it to the address using Metamask: 

Execute the flash loan contract

Now we need to call Aave’s KovanTestnet DAI contract to indicate what asset we will be using in order to execute the smart contract.

1. Go back to your Remix IDE and to the 'Deploy & Run Transactions' tab

2. Under 'Deployed Contracts' you will see your flash loan and contract address 

3. Go to the text field labeled ‘address asset’ next to the label 'flashloan'

4. Enter this contract address in address_asset field: 0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD . Then click on the flashloan label button in order to start the transaction.

5. This will start the flash loan process and generate 3 transactions on etherscan.

The first transaction is from the lending pool to our flash loan contract. Since we did not include any operations to the smart contract, the amount is returned to the lending pool plus an additional fee. The last transaction is the interest for the amount borrowed, which would go to the suppliers of the liquidity pool. 

Build web3 with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get started for free