Source: Gem Hunters
Original compilation: 0x26
许多 DeFi 的参与者已经成为代币合约漏洞的受害者,这导致他们损失了不计其数的钱或代币。这中情况在 Uniswap 中最常见,因为只要他们有技术并且可以支付以太坊手续费, 任何人都被可以写一份智能合约。不幸的是,这也导致了出现许多本质上就是恶意的智能合约。
However, the vast majority of scammers' tricks can be identified by checking smart contracts using Etherscan. The following steps can be used to determine whether a contract is in bad faith. To show the difference between a good contract and a bad contract, this tutorial will first give an example of a normal contract and then give an example of a malicious contract.
1. Access the Ethereum browser;
2. Enter the contract address in the search bar (double check if you have the correct address);
2a. If you don't know the contract address, you can get it through DexTools, CMC, or Coingecko.
2b. It is important to remember that,The token page is different from the contract page, please make sure it is on the contract page.
Here is an example of a token page:

Here is an example of a contract page (highlighting contract options) :

3. Click the "Contract" button highlighted in yellow above;
4. Select the following reading contract:

5. You can now read the parameters of the contract. They should look like this:

This is where it gets trickiest, as there are countless potential parameters that can be included in a smart contract for a single token. In the example above, there are only eight parameters, which is a sign of a normal contract. Because all eight of these parameters are required for the token and do not trigger a "blanket pumping".

Rug pull, rug pull
The same goes for contracts for other tokens, which can still be read using exactly the same steps.There are some common red flags in malicious fraud contracts, which will be outlined later. Now that we know how to access and view smart contract parameters, we can identify potentially malicious code.
1. Mint - This feature allows more tokens to be minted, thereby increasing the supply and potentially allowing the minter to sell these tokens in the market. This is the most common scenario that causes the price of the underlying token to collapse. Disclaimer: Some tokens function as Mint because they rely on elastic supply. But unless there is a reason to coinage, or a rule exists, Mint should not be available.It is important to check who is the owner of the Mint feature: if the owner is Dev (the developer), this is obviously a red flag; If the Minter was a smart contract based on volume/price, it would be decentralized and unlikely to be a scam.
2. 白名单功能( Whitelist )——这个参数只有在项目进行随机预售(persale)时才会出现,功能是要求白名单的地址才可以参与购买,以确保没有超额认购。如果项目没有预售,并且在合约中仍然有这个功能,那么它可能被用来使得任何不在白名单上的地址无法出售。也就是说,你可以买,但不能卖。
3. 冻结功能( Freeze )——顾名思义,这个功能可以在任何时候冻结资产交易。虽然简单,但它可以很明显地阻止人们出售资金池中的代币,锁定以太和原生代币直到解冻。
3a. 叠加所有权转移功能(
Transfer Ownership
),如果合约创建者拥有冻结功能的控制权,那么他们可以冻结合约,然后将所有权发送到烧毁地址。这样就「杀死了」合约中的以太坊和其他代币,这部分代币将永远无法操作。
4. Not specific parameters, but the more parameters a token has, the more parameters will be attacked. These parameters should not be arbitrarily added to the code unless the item of the token requires them.
1. The amount of "zero too many to measure", or the majority of tokens owned by a single address. It is common to see that the address of the deployment contract (i.e., the developer address) holds most of the tokens, which is a potential red flag.
2. The amount of tokens (liquidity) in the UNI-V2 pool is significantly smaller than the amount of tokens in the largest individual holder. Note that I do not include staking, because staking an address is the cumulative amount that many addresses roll into. This is a sign of the uneven distribution of whales, which are increasingly likely to damage the ecosystem.

Note: The difference between a normal address and a contract address is the symbol next to the address. A yellow highlighted symbol indicates that the address is a contract. If the symbol does not exist, the address is a personal address. If there are a lot of tokens in a contract, it's important to know what they're for (such as for staking, linear unlocking, or locking team tokens, etc.)
3. Anonymous teams can be a red flag, but anonymity should also be viewed rationally. Anonymity should not be a negative factor if the product is robust, security measures are in place, and developers are transparent in their code and answers to questions. But if anonymity comes along with other red flags, it means the risk is significantly increased.
Overall, Defi contracts on ethereum are certainly high risk compared to other investments. However, knowing the basics of how contracts work and being able to identify red flags of potential fraud can help users reduce this risk. Interacting on a blockchain is always risky, but investing in a contract without malicious code can significantly protect against more losses and may help your bottom line in the long run.
The original link
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia