Sub topic 7
Reading a Token Contract for Red Flags
Assume you understand wallets, blockchain transactions, and basic token transfers. You do not need to be able to write Solidity. The goal is to identify powers that could let an insider stop selling, create new tokens, or take value from trades.
A token contract is a program deployed on a blockchain. Its functions define how balances change and who may change them. A block explorer often shows the verified source code, but verification only means that the published source matches the deployed bytecode. It does not mean that the contract is safe.
Start with privileged powers
Look for the deployer, owner, administrator, or role accounts. Then inspect what those accounts can do. Important functions often include:
| Function or power | Why it matters |
|---|---|
| `mint` | Can increase supply and dilute buyers |
| `pause` | Can stop transfers, including selling |
| `blacklist` or `setBlocked` | Can prevent selected addresses from transferring |
| Fee or tax setter | Can make selling expensive or impossible |
| Upgrade function | Can replace the contract logic later |
| Withdrawal function | Can move assets held by the contract |
The names may differ. Search for permission checks such as onlyOwner, role-based access control, or comparisons with an administrator address. A function without an obvious permission check may be callable by anyone, which can create a different security problem.
Transfer restrictions and honeypot behavior
A honeypot is a token that buyers can acquire but cannot sell under normal conditions. The restriction may be direct, such as a blacklist, or indirect, such as a very high sell fee.
This simplified contract shows an owner-controlled blacklist:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract RedFlagToken {
address public owner;
mapping(address => bool) public blocked;
mapping(address => uint256) public balanceOf;
constructor() {
owner = msg.sender;
}
function setBlocked(address account, bool value) external {
require(msg.sender == owner, "not owner");
blocked[account] = value;
}
function transfer(address to, uint256 amount) external returns (bool) {
require(!blocked[msg.sender], "blocked");
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
return true;
}
}This example is not a complete ERC-20 token, but it demonstrates the risk. The owner can block a holder immediately before that holder tries to sell. In a real token, inspect both transfer and transferFrom, because trading contracts commonly use the second function.
Supply, fees, and upgrades
Check whether the owner can mint after launch. A large new supply can reduce the value of existing tokens, especially if the new tokens are sent to insider wallets.
Inspect fee variables and their maximum values. A contract may advertise a small launch fee while retaining a function that raises the buy or sell fee later. Also check whether fees go to a wallet controlled by the team.
Upgradeable contracts need extra care. A proxy address may show harmless-looking code while an administrator controls a separate implementation address. That administrator may be able to add minting, transfer restrictions, or fund withdrawals later.
Ownership claims are not enough
“Ownership renounced” does not automatically make a token safe. Other privileged roles may remain active, a proxy administrator may still control upgrades, or liquidity may be held by an account that can withdraw it. Check the current role holders and recent administrative transactions on the block explorer.
Exercise
A token has a public mint function protected by onlyOwner, and the owner address is an ordinary wallet. What should you verify next?
Show answer
Verify whether the owner can mint an unlimited amount, where newly minted tokens can go, and whether the owner has transferred control to a transparent, time-locked, or multisignature arrangement.