Deploying My First Ethereum Smart Contract for Fun and Profit

Locking your Ethereum crypto coins in smart contract is represented by a lock Photo by Erik Mclean on Unsplash

I’m the kind of person that buys $500 worth of Dogecoin, and one day later, panic sells with a 30% loss. Recently, I’ve deployed my first Ethereum smart contract to help optimize this buy high, sell low investment strategy. Read on if you want to learn about my first steps in the ETH and blockchain ecosystem.

Disclaimer: The information provided in this blog post is for educational purposes only and should not be treated as investment advice.

How to forget about your cryptocurrencies?

I’ve been buying small amounts of different crypto coins for a couple of years now. I can never stand the pressure of losing 5% of an investment, compulsively check prices every day, and usually sell just before it bounces back. The single-time when I’ve managed to monetize a decent profit was when I forgot about one of my wallets for over two years. That’s how I’ve realized that forgetting about your crypto could be the perfect investing strategy.

Since you cannot forget on demand, I’ve decided to lock my assets so that even I cannot access them unless specified conditions are met. I knew that Ethereum Smart Contracts should be able to fulfill this requirement. I want to lock away my ETH tokens and only be able to withdraw if USD price has reached predetermined value or enough time has passed. This approach sacrifices liquidity for a peace of mind and for me that’s a perfect tradeoff!

I suspect dozens of DeFi/staking projects offer the same feature with more bells and whistles like additional guaranteed profit. But, reinventing the wheel is always fun if you’re a developer.

Let’s now explain the steps I took to develop and deploy my first Ethereum smart contract.

How to learn the basics of the Ethereum Blockchain stack?

Video courses are my preferred way to pick up new knowledge. I usually watch them with an increased speed, and it’s easy to skip parts that are not relevant. I can recommend Udemy’s Ethereum and Solidity course by Stephen Grider. It’s around 30h of videos, but I could skip 1/3 because I did not care about building the React frontend. As an addition, I can recommend Ethereum Developer Masterclass by Raghu Thiyagharajan. It covers some topics that the first out missed out (Truffle, OpenZeppelin, and ERC20). Pricing on Udemy is a steal with ~10€ for a dozen hours’ worth of content.

These sources worked for me to pick up enough basics to start working on my own. However, both free and paid materials are abundant, so you should be able to find one that suits you best.

Basics of Solidity are relatively quick to pick up. But, for me, the complexity of developing and deploying smart contracts hides in security, infrastructure, and tooling.

My impressions on the development ecosystem

Smart Contracts are sometimes called self-funding bug bounty programs. Every security loophole is guaranteed to be exploited by malicious bots or hackers. Also, even a simple mistake could cause your tokens to get stuck forever. Since I want to lock a non-trivial amount of Ether in my contract, I’ve decided to go all-in on unit testing. I was surprised by how mature, and pleasant to work with the Solidity testing toolkit is.

Truffle Suite allows you to configure local testing environment quickly. You can write unit tests in NodeJS, and there’s even support for more advanced features like time traveling and mocking external dependencies. My contract code is open-source, so it was possible to configure a free CI pipeline with CircleCI.

Deploying Smart Contract to the Mainnet

In theory, you could deploy your contract only on the test networks. However, knowing that I’ll keep real money in a contract forced me to consider the crucial aspects of Ethereum development like security and costs. There are multiple security scanners available. I doubt they can detect all the potential loopholes, but they helped me spot a few minor issues. In the end, I’ve used a free Slither scanner from the Ethereum Security Toolbox for the development process and bought a few scans with Mythx.

I’ve deployed the contract when gas prices were exceptionally low at ~11 gwei, costing only $15 for its ~80 LOC. I’ve used Remix IDE to do the deployment. I’m not sure if this is a proper way for production contracts. But, I liked the feature of estimating the expected gas cost upfront.

I’m a bit discouraged by withdrawal costs that are currently estimated to be ~$80. I have no idea why so it’s expensive to execute a ten-line-long method. But, it’s a one-time fee on a “huge pay-off day” so probably acceptable.

Monetizing the project

I’ve briefly considered trying to monetize the idea of this contract. I imagine there could be more panic-sellers like myself who could be interested in using it. I suspect there are better ways to long-term hold your crypto. But for me, eliminating the risk of a chosen DeFi going broke is worth the sacrifice of a potential additional income. The business model could take a one-time cut for each deposit or rely on donations.

I could probably bridge the gap in my lack of Solidity experience by ordering a professional security audit before releasing a final product. What discouraged me from pursuing it, for now, are potential KYC/AML related formalities. I wouldn’t dare to approach it as a one-man show without an army of lawyers to back me up.


Developing this contract was one of the more fun projects I’ve done in a while. The additional pressure of knowing that I could irreversibly lose my money if I get something wrong was something totally new for me. I’m used to doing a hotfix release if I mix something up on production. But, on the blockchain there’s no Edit/Undo button.

Creating an app that provides real value to at least one user is the best way to get familiar with the new tech stack. I’ve read dozens of articles about Smart Contracts but creating one was eye-opening. Blockchains can enforce the rules that even the app creator cannot cheat and modify. My ETH is now safely locked away. I don’t have to worry about panic selling and can patiently wait for lambo to arrive in a couple of years.

My contract is open-sourced on GitHub. This is my first production Ethereum project, so feedback is appreciated. I’m currently working on the next version that will hold ERC20 tokens since I want to diversify my frozen portfolio. [Update: The support for ERC20 is now implemented.] I don’t think I’ll drop web development to focus on blockchain but getting to know this obscure and exotic stack was an invaluable experience. I highly encourage you to try it yourself. The barrier of entry is probably much lower than you might have imagined.

[Update] You can check out my new post for more tips for beginner Ethereum blockchain developers.

Back to index