I’ve recently learned that taking investment advice from Hard Rock Nick is not always lucrative… In this blog post, I’ll describe a step-by-step process for releasing an ERC20 meme token on the Ethereum network. Additionally, we’ll make our token tradeable by bootstrapping liquidity on permissionless AMM Uniswap contracts. I’ll also demonstrate how to manipulate the initial capitalization so that you can instantly become a crypto millionaire. By creating a token, you can better understand the inner workings of crypto scam schemes. And distinguish potentially genuine projects from outright scams.
We’ll use the OpenZeppelin wizard to create our token ERC20 Smart Contract, so the knowledge of Solidity is not required to complete this tutorial. I’ve deployed the contracts on the ETH Rinkeby test network. But I also describe estimates of gas costs for releasing on the Ethereum Mainnet and Arbitrum L2 sidechain.
Disclaimer: The information provided is for educational purposes only and should not be treated as investment advice. In no event shall the author be liable for legal or financial consequences of implementing anything described in this blog post.
How to create an ERC20 token without knowing Solidity?
ERC20 is the backbone of the DeFi industry. Creating an ERC20 token in practice means deploying an Ethereum Smart Contract that implements methods and events described in the standard:
The Smart Contract works as a ledger storing token balances and implements methods for transferring tokens between addresses. Author of the contract can implement any feature and monetary policy. But, as long as it adheres to the ERC20 interface, a token will be able to interact with the existing DeFi projects and infrastructure. For this tutorial, we’ll generate the simplest possible token using the open-source OpenZeppelin wizard:
We’ll call our token NAR (“Not a Rug”). Just to convince potential buyers that it is a genuine web3 project and not a quick money grab scheme.
As you can see, we’ve did not choose any of the optional features. You should have generated a similar source code:
I’ve chosen a fixed capitalization of one million units. All the initial supply will be minted to the address of the contract deployer. By default, ERC20 tokens support floating-point precision up to 18 decimals, so they are almost infinitely divisible.
You’ll need a Metamask wallet with some testnet Ether to deploy the contract. You can use Rinkeby Faucet by Alchemy to fund your address with 0.1 ETH (or 0.5 if you have a free Alchemy account). But even 0.1 ETH will be enough to complete most of the steps from this tutorial. I’m kind of a Rinkeby testnet whale myself (10+ ETH \o/ ) because I’ve used the currently not working Rinkeby Authenticated Faucet. I’m leaving the link for reference. Maybe it will be restored by the time you’re reading this.
Now back in OpenZeppelin wizard, click Open in Remix. Next click Compile contract-xxx.sol. Then select the Ether icon indicating Deploy & run transactions from the side menu.
After choosing Injected Web3 for Environment, your Metamask extension should pop up and prompt authentication. Make sure to select the correct network and contract to deploy. I’ve made the mistake of deploying a base ERC20 contract instead of my custom one a few times. After clicking Deploy, you’ll need to confirm the transaction at Metamask.
If you’re deploying on testnet, there will be no cost associated. By changing the network in Metamask, you can get an estimate for deployment costs. Deploying this contract on the Ethereum Mainnet is estimated to cost ~$200 at gas prices ~50 gwei. Deploying to Abritrum L2 costs ~$50. web3-tools can be helpful if you want to estimate transaction costs without Metamask simulation.
When you feel ready, click Deploy, and a few moments later, your contract should be live. Here’s my NAR token deployed on the Rinkeby network.
You’ve probably noticed that this contract is verified, i.e., its source code can be read on Etherscan. The open-source nature of smart contracts is at the very core of the DeFi industry. Verifying a contract using OpenZeppelin as a dependency requires a few-step process. Check out this OpenZeppelin forum thread for info on how to do it.
An optional step is to add your new token and its icon to Metamask. You can generate a link for sharing your token Metamask metadata on this website. Here’s the link to add NAR on the Rinkeby network.
If you’ve followed this tutorial, one million units of your very own token are now sitting in your Metamask wallet. But the token still cannot be traded, so it’s currently worthless. Read on to learn how to make it tradeable and hack its initial capitalization.
Intro to Uniswap Automated Market Maker liquidity pools
Back in the 2017 ICO days, it was only possible to trade less popular tokens on shady centralized exchanges. Uniswap revolutionized trading on the Ethereum network by providing a permissionless platform for exchanging ERC20 tokens. The original idea came from the Reddit post by Vitalik Buterin describing a mathematical formula for liquidity pools. The idea is always to maintain an equal ratio of tokens in the pool contract that is represented by the constant product market maker formula:
B are values of tokens and
k is a constant that is not affected by trades. To buy a token
A, user has to deposit equal value of token
B so that
k remains constant. The value of
k is changed only if users add/remove liquidity to the pool, i.e., deposit/withdraw their tokens in a proportion reflecting the current price. Users are incentivized to provide liquidity to earn trading fees and optional token rewards. You can check out this video by Finematics for an excellent intro to liquidity pools and AMMs. If the AMM tokens are traded on other markets, then an army of arbitrage bots is rebalancing the amount of tokens, so the AMM pool always reflects the current market price.
But, in the case of NAR, Uniswap AMM will be the ultimate source of truth for the current market value. And here comes the promised capitalization hack: If you’re creating a new trading pool, you can determine the initial market price of your token.
Providing initial Uniswap liquidity for ERC20 token
You can create a new Uniswap V2 token pool on this website. You have to select tokens, and if this pair has not existed before, a new
UniswapV2Pair pool contract will be deployed. Here’s a link to the transaction creating NAR/ETH Uniswap pool on the Rinkeby network. Gas usage was ~3x higher than the deployment of our ERC20 contract. It means that the cost of doing it on the Mainnet would be ~$600 and ~$150 on Arbitrum.
For me, that’s the mindblowing feature of permissionless exchanges. Without any formal verification, we’ve just deployed a contract that will forever exist on the blockchain and let everyone buy and sell token that we’ve created. Uniswap may ban and remove some tokens from the frontend layer. Or be banned entirely in a geographical region. But, the pool contract will always be accessible directly in the blockchain, and it’s impossible to censor it. Maybe most of the current use cases of crypto are speculation and scams. But, its uncensorable nature makes me believe that we’re still early adaptooors, and this paradigm is just getting started.
Back to the point, you have to provide liquidity in a ratio that will reflect the initial price. In this case, I’ve deposited 10 ETH and 10k NAR. So one full NAR is initially priced at ~$3.50, and the total market cap is over 3 million USD (!!). Currently, 1% of total NAR capitalization is the liquidity, and we’re sitting on the hefty 99%.
So, apparently, we’ve just printed these three million dollars out of thin air. But there’s a catch. Let’s see what’s the selling price of NAR depending on trade volume. The below table assumes ETH price at $3500 and initial pool liquidity to be ~$70k (10 ETH + 10k NAR).
|Trade volume (NAR)||NAR/1 ETH||USD/1 NAR||Price impact (%)|
You can see that we cannot sell any significant ratio of our holdings without crashing the price. Creators of new tokens always need so-called “exit liquidity” to capitalize their bags. What we did was kind of equivalent to auctioning your hand-drawn NFT on OpenSea for an insanely high minimum price. But NAR is a fungible token, so there’s a better illusion of it holding the manipulated value. If you bootstrapped liquidity on non-test networks and overpriced one of the tokens, arbitrageurs would take advantage of the opportunity. But, since you’re currently the only NAR owner, there’s no way to sell the token but only purchase it for the hacked price.
Now that we understand the basics of ERC20 and decentralized markets, we’re better equipped to detect scams that are not even trying to look genuine.
Analyzing meme coin projects
Am I the only one who invested in the cutest meme coin that turned out to be a rug? This is by no means a comprehensive guide to analyzing tokens, but rather a quick checklist of areas to look into if you’re interested in a project.
1. Available liquidity
Liquidity could be the most critical feature determining if the token should be worth your attention. You might be holding millions worth of the next Doge Floki Moonshot but unable to sell it without obliterating the price. We’ve seen how dead easy it is to artificially inflate capitalization. A simple way to assess liquidity is to investigate the Markets tab on Coingecko. A +2% Depth metric indicates how much USD worth of a token can be traded without moving price by more than 2%.
For example, one of the most popular meme coins, Shiba Inu, currently has a market cap of over 13 billion USD. According to Coingecko, it has a 2% depth of ~two million USD (on trusted markets with some actual trading volume). Let’s compare it to Olympus DAO, a token that pioneered the concept of protocol-owned liquidity. It currently has a ~450 million USD market cap but almost the same 2% depth as Shiba. So, the liquidity depth to market ratio is over 20x better for Olympus, meaning that it’s an order of magnitude more tradeable asset.
For less popular tokens that could be available only on decentralized AMMs, you can always check how much liquidity is in the pool contract. Again, a simple rule is that the more, the better. A bloated market cap with disproportionally shallow liquidity is an obvious red flag against the project.
2. Source of funding
Using Etherscan, you can analyze the history of the address which deployed the token’s ERC20 contract. One thing to look into is the source of funding. Popular centralized crypto exchanges with KYC procedures should not raise your suspicions. But if the wallet was initially founded from a mixer, e.g., Tornado Cash, it’s highly possible that your money will disappear in a similar way.
3. Token distribution
Etherscan displays a Holders tab for each ERC20 contract address. It allows you to get a quick overview of top whale holders, what % of token is in liquidity etc. Here’s the distribution of our NAR on Rinkeby:
Similar disproportion should always raise your awareness. It’s possible that top holders could be addresses of centralized exchange, or a black hole contract, that reduces the token supply. But, if non-contract addresses (EOAs) hold most of the token, you may be dealing with a pump & dump.
You should also analyze the emission mechanics of the token. The initial batch could have been evenly airdropped among the community. But, contract owners could still mint unlimited units of token and dump them on the market. In theory you could check if a contract has a standard
mint method. But, in practice, the inflationary mechanism could be obfuscated in the source code and impossible to detect without knowing Solidity.
This post is a simplified introduction to the ERC20 standard and what determines a token price and capitalization on the permissionless market. But I hope it will come in handy for scrutinizing your next moonshot investment. Crypto scams are often insanely elaborate, but even basic analysis might help you avoid the more obvious ones. Or you can create a new, better Shiba.