With the help of etherscan, Metamask wallet, and Remix IDE to directly interact with smart contracts, you can also become a “DeFi scientist”.
Original title: “Xu Chaoyi: How to become a respected DeFi scientist in three minutes”
Author: Xu Chaoyi, founder of BKFUND
I didn’t plan to write this article, but many friends are very curious about the “scientist” who is currently at the “top of the pyramid” in the DeFi industry. They all came to ask me how “scientists” play, so I wrote a simple article to popularize it.
There is a very popular article called ” DeFi Riders, Scientists’ Bull Market “, which describes the group of “DeFi scientists” very mysteriously, meaning that they refer to the big cows who use technical means to arbitrage in DeFi projects. It feels that they are almost hidden from the world. Hacker who does not eat fireworks, in fact, if you read this article, you will find that to become a junior-level “DeFi scientist” does not need to understand Hacker technology, or even know how to program. Anyone only needs to spend three. You can become the “DeFi scientist” in the eyes of New Leek in a minute of learning.
It should be noted that there is a prerequisite for “DeFi Scientists” to carry out their work, that is, the smart contract deployed on the blockchain network has been open source, and the open source code can be consistent with the bytecode verification after the smart contract is compiled. Based on this condition, we can roughly interpret the current “DeFi scientist” as ” When the smart contract is released and the code is open source, but the front-end webpage of the project is not officially online, or the webpage is online but does not allow users to mine, they will have their own Directly interact with smart contracts through other tools, a group of people who desperately yield farming to make money by mining their heads. ” In most cases, they directly interact with smart contracts using the three most commonly used tools: etherscan, Metamask wallet, and Remix IDE. It is enough to take 3 minutes to study.
Let’s take a simplest case to illustrate in actual combat:
Everyone knows that in the Uniswap protocol, we can convert Ethereum’s main network currency ETH 1:1 to WETH ERC20 tokens, and we can also convert WETH ERC20 tokens 1:1 to Ethereum’s main network currency ETH. In fact, this is through The front-end page of the Uniswap website calls the desopit and withdraw functions in the WETH smart contract to process.
So what should we do if we do not go through the Uniswap website?
1. First, we go online scientifically, open the etherscan.io website, find the WETH smart contract address 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, click the Contract button, and see the source code of the WETH smart contract
2. Click “Write Contract” and connect to Metamesk wallet via “Connect to Web3”
3. Suppose we now want to directly convert 1 WETH 1:1 in the wallet to ETH through the WETH smart contract, we can click withdraw, enter the amount of Ethereum we want to convert, and convert it to hexadecimal, click “Write” button to write the contract, and click confirm in the Metamask dialog box that pops up. It should be noted that usually in Ethereum smart contracts, the smallest unit wei is used, then 1ETH = 10^18 wei, converted to hexadecimal format is 0xde0b6b3a7640000
4. After a while, we can see from the Ethereum browser that the transaction between us and the WETH smart contract withdraw function through the WriteContract function has been successful, and 1 WETH in the wallet has been converted to 1 ETH.
5. So if we want to directly convert ETH to WETH by writing the WETH smart contract desopit function in the above way?
The answer is no, because ETH is the native currency of Ethereum and is not equivalent to ERC20 tokens. It is not possible to interact with smart contracts directly through writeContract. We need to use another tool, remix, please open https:/ /remix.ethereum.org/ , enter the most popular Ethereum Web IDE, according to personal usage habits, you can use the old version or the new version interface.
6. Click to create a new solidity source file, and copy and paste the WETH smart contract source code displayed on the etherscan.io website to the source file window, select the corresponding compiler version in the Compile window, and execute the compilation
7. After the compilation is successful, select the Run page in the right window, select “Injected Web3” in the execution environment Environment, and connect to the Metamask wallet. At this time, we paste the WETH contract address 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 into the input box on the right of At Address, and click “At Address” , That is, all functions of the smart contract are displayed at the bottom right
8. Next, we enter the amount and unit we want to convert in the Value window on the upper right, for example, 1ETH, and click the desopit function on the lower right
Click Confirm in the pop-up window of Remix
Click to confirm again in the pop-up window of Metamask
9. After waiting for the block confirmation, you can see that we have successfully converted 1 ETH to 1 WETH.
Becoming a junior DeFi scientist is as simple as that. You don’t need to know how to program, just press a few buttons. Start your yield farming journey quickly.
Source link: mp.weixin.qq.com