1. DMCC Tokens Deployed on the Ethereum Blockchain
DMCC tokens utilize Solidity smart contracts. The Solidity-compliant DMCC smart contract implements the following key functions
a. TotalSupply and BalanceOf Return: These functions return the total number of available tokens and the total amount of tokens owned by an account. The caller can transfer tokens to another address using these functions.
b. Delegated Transfer: One of the notable features of DMCC tokens is the ability to allow one address to transfer tokens on behalf of another. This delegated transfer uses the transferFrom and approval functions together.
c. Approval Functionality: DMCC token holders can grant permission to another user (the 'receiver') to use their tokens. The receiver can then transfer DMCC on behalf of the token holder using the transferFrom function. The amount that the receiver can withdraw is queried through the allowance function, and events are triggered as a result of transfer, approval, and transfer execution operations.
d. Smart Contract Interaction: If there is no code in the smart contract to interact with the tokens, errors can occur, resulting in token loss. Therefore, DMCC tokens use a combination of the approve and transferFrom functions.
The Solidity standard for DMCC tokens defines a set of functionalities that can be implemented by all Solidity tokens to ensure integration with other contracts, wallets, or marketplaces.
//solidity
function totalSupply() public view virtual override(IERC20, IERC777) returns (uint256) {
return _totalSupply;
}
function balanceOf(address tokenHolder) public view virtual override(IERC20, IERC777) returns (uint256) {
return _balances[tokenHolder];
}
function allowance(address holder, address spender) public view virtual override returns (uint256) {
return _allowances[holder][spender];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_send(_msgSender(), recipient, amount, "", "", false);
return true;
}
function approve(address spender, uint256 value) public virtual override returns (bool) {
address holder = _msgSender();
_approve(holder, spender, value);
return true;
}
function transferFrom(
address holder,
address recipient,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(holder, spender, amount);
_send(holder, recipient, amount, "", "", false);
return true;
}
//
Using these Solidity functions, external users (e.g., cryptocurrency wallet apps) can check user balances and transfer funds between authorized users. The smart contract defines two specifically defined events.
solidity
//solidity
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
event Transfer(address indexed from, address indexed to, uint tokens);
//
In addition to standard Solidity functions, many Solidity tokens have additional fields. The following example shows additional fields.
//solidity
string public constant name;
string public constant symbol;
uint8 public constant decimals;
//
Some naming conventions related to Solidity include
-Public functions: DMCC's public functions can interact with DMCC's smart contract if other tokens have public functions.
-View functions: The view keyword indicates that the function does not alter the internal state of the contract.
-Events: Events allow DMCC's Solidity to notify clients (e.g., front-end applications) about specific occurrences within the contract.
Last updated