How to Create Deflationary CRC20 Token “Coinex Smart Chain”


Maybe you are still confused about the concept of deflation (deflationary) in traditional finance or cryptocurrencies, deflation in traditional finance is a very bad thing, but it becomes a positive in cryptocurency finance. Deflation in traditional finance refers to a decrease in the price of an asset due to certain conditions or due to over minting.

Deflation in cryptocurrencies is a good thing, it is a decrease in the supply of a token or crypto coin over time. This factor implies that the development team and token users participate in supply reduction activities, usually this model does automatic burning to reduce supply.

 

How Does Token Deflation Work?

As I mentioned earlier, deflation in cryptocurrencies is a mechanism that involves burning tokens out of circulation, it’s not a literacy activity that locks tokens into a specific wallet, but it actually removes some of the supply, so that part of the supply is completely destroyed. .

An example of the mechanism is the automatic burning of tokens when a user makes a transaction, for example User1 sends a token to User2, then some tokens will be burned automatically, the number of tokens burned depends on the consensus or developer requirements. For example, TokenA has 1% auto burn when the user makes a transaction, then every transaction such as “send, stake, swap” will be burned automatically (1% of the amount traded)

 

The Benefits of Deflation in Cryptocurrencies

There are several advantages for users or token holders of deflation:

  • Increasing Token Value: The basic law of the crypto market is “supply and demand”, when the demand is higher than the supply, the token value will soar, but conversely if the supply is higher than the demand, the token value will decrease. Deflation will increase demand because the supply of tokens will continue to decrease over time.
  • Decrease in Supply: The deflation mechanism will reduce the supply of each transaction, the more transactions on the token, the faster the supply will decrease.
  • More Holders: Due to the deflation mechanism in each transaction, it will trigger a “long hold time” for investors, because they are very confident that deflation tokens will BOOM in the future. Users prefer HOLD because they avoid a decrease in the supply of tokens in their wallet, and they believe the price will increase over time.

 

How to Create a Deflation Token?

In this article I will give a tutorial on how to create a Deflationary CRC20 Token “Coinex Smart Chain”. I chose the CSC “coinex smart chain” blockchain to create a deflation token, because it is faster, has a high TPS and very low transaction fees. Check out the tutorial below to make token deflation in CSC

# Prepare CET Wallet & Coin

You can use the metamask wallet, the wallet is easier to use. Next you have to prepare some CET coins, CET is the native coin of the Coinex Smart Chain blockchain. You can buy CET coins at Coinex Exchange and send it to the address metamask

 

# Prepare a Deflationary Smart Contract

There are many smart contracts that you can use, you are free to use any smart contract, if you don’t have a deflation smart contract, you can use the smart contract below

pragma solidity ^0.6.12;
// SPDX-License-Identifier: MIT
interface IERC20 {

function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Burn(address indexed from, uint256 value);
}

library SafeMath {

function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");

return c;
}

function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}

function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;

return c;
}

function mul(uint256 a, uint256 b) internal pure returns (uint256) {

if (a == 0) {
return 0;
}

uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");

return c;
}

function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}

function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold

return c;
}

function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}

function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}

contract TTD1 is IERC20 {
using SafeMath for uint256;
string internal _name;
string internal _symbol;
uint8 internal _decimals;
uint256 internal _totalSupply;
uint8 internal _brate;
address internal _admin;
mapping (address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;

constructor() public {
_admin = msg.sender;
_symbol = "TTD1";
_name = "TTD1";
_decimals = 6;
_brate = 1;
_totalSupply = 1000000* 10**uint(_decimals);
balances[msg.sender]=_totalSupply;

}

function changeBurnRate(uint8 brate) public {
require(msg.sender==_admin);
_brate = brate;

}

function brate() public view returns (uint8)
{
return _brate;
}

function name() public view returns (string memory) {
return _name;
}

function symbol() public view returns (string memory) {
return _symbol;
}

function decimals() public view returns (uint8) {
return _decimals;
}

function totalSupply() public view override returns (uint256) {
return _totalSupply;
}

function balanceOf(address account) public view override returns (uint256) {
return balances[account];
}

function transfer(address _to, uint256 _value) public virtual override returns (bool) {

require(_to != address(0) && _value > 0);
uint burn_token = (_value*_brate)/100;
require(_value+burn_token > _value);
require(_value + burn_token <= balances[msg.sender]);
balances[msg.sender] = (balances[msg.sender]).sub(_value - burn_token);
balances[_to] = (balances[_to]).add(_value - burn_token);
emit Transfer(msg.sender, _to, _value - burn_token);
require( burn(burn_token));
return true;
}

function transferFrom(address _from, address _to, uint256 _value) public virtual override returns (bool) {
require(_to != address(0) && _from != address(0) && _value > 0);
uint burn_token = (_value*_brate)/100;
require(_value+burn_token > _value);
require(_value + burn_token <= balances[_from]);
require(_value + burn_token <= allowed[_from][msg.sender]);
balances[_from] = (balances[_from]).sub(_value - burn_token);
balances[_to] = (balances[_to]).add(_value - burn_token);
allowed[_from][msg.sender] = (allowed[_from][msg.sender]).sub( _value - burn_token);
emit Transfer(_from, _to, _value - burn_token);
require( burn(burn_token));
return true;
}

function approve(address _spender, uint256 _value) public virtual override returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}

function allowance(address _owner, address _spender) public view virtual override returns (uint256) {
return allowed[_owner][_spender];
}

function burn(uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
_totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}

/**
* Destroy tokens from other account
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowed[_from][msg.sender] -= _value; // Subtract from the sender's allowance
_totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}

//Admin can transfer his ownership to new address
function transferownership(address _newaddress) public returns(bool){
require(msg.sender==_admin);
_admin=_newaddress;
return true;
}

}

 

# Open Remix Ethereum

Open website remix ethereum , for the token creation process or to deploy tokens to the coinex smart chain blockchain, make sure your metamask wallet is already using the RPC coinx smart chain. Create a new file on the ethereum remix & paste the smart contract above.

 

# Compile Smart Contract

Before deploying, compile your smart contract and make sure there are no errors or warnings in the ethereum remix. Before deploying, please check first, Name, Supply, Symbol and Decimal token

 

# Deploy Token Deflasi

After compiling is complete and there are no errors in the smart contract, please deploy your smart contract.

 

# Test Token Deflationary

The tokens in this tutorial use the Auto Burn 1% mechanism for each transaction, every transaction made on the token will delete 1% of the total token traded.

I tested sending 10000 tokens to another address, after the transaction is confirmed, 1% of the total number of tokens traded is deleted automatically, and that address only receives 9900 tokens

 


Alif Fahmi

hi , I'm Alif, I'm a blockchain & cryptocurrency lover, I love writing & learning, my job is web developer & crypto trader