I have created an ERC-20 token with basic functionalities and it works fine and as expected. Now I want to add require() for error handling for frozen accounts.
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
I am using above in my internal function but it gives me an error as below
I am new to solidity and programming. Plz help me with this.
Below is my complete code for internal function
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value >= balanceOf[_to]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
//Declared Variables at the contract beginning
contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 3;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// Constructor function
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
// declared frozen account
mapping (address => uint256) public frozenAccount;
Is this the right way ?
frozenAccount
variablefrozenAccount
declaration in your code!!!