Hold and Transfer ERC-20 on a Smart Contract
Solidity smart contracts can also hold ERC-20 tokens like it holds native coins such as ETH/MATIC/BNB. Holding ERC-20 in a contract is for multiple purposes. It can be for Staking, Locking and Releasing tokens, Banking and etc.
New to trading? Try crypto trading bots or copy trading on best crypto exchanges
Let’s look at how to make our contract hold ERC-20 tokens and transfer them to an address.
How to create a contract to hold tokens?
Let’s create a simple contract with implementing the ERC20 interface.
We’ve created a simple contract that can hold any ERC-20 tokens and also allows you to withdraw the token whenever needed.
Note: This code is only for demonstration purpose, should not be used in production. Consider Attack on Smart Contract Chapter 1 and Chapter 2 for a better and a secure smart contract development.
Let’s dive into Web3 together 🏊
Let’s get connected
Follow me on Medium, LinkedIn, Twitter, and Instagram
Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing