I am trying to create a dividend function for my token. This is in the first part of the contract for my coin:
mapping (address => uint256) private _SavedDividend;
Here is the constructor code:
constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_mint(msg.sender, _totalSupply);
_SavedDividend = 0;
}
Here is my view and withdraw dividend function:
function ViewDividend(address staker) public view returns (uint256) {
require(msg.sender != (address(0)));
_SavedDividend = _balances[this].div(_totalSupply).mul(_balances[msg.sender]);
return _SavedDividend;
}
function WithdrawDividend() public {
emit Transfer(address(this), msg.sender, _SavedDividend[msg.sender]);
_balances[this] = _balances[this].sub(_SavedDividend[msg.sender]);
_SavedDividend[msg.sender] = 0;
}
I get a multitude of errors with these including:
TypeError: Mappings cannot be assigned to. _SavedDividend = 0;
TypeError: Type int_const 0 is not implicitly convertible to expected type mapping(address => uint256). _SavedDividend = 0;
TypeError: Mappings cannot be assigned to. _SavedDividend = _balances[this].div(_totalSupply).mul(_balances[msg.sender]);
TypeError: Type contract Miasma is not implicitly convertible to expected type address. _SavedDividend = _balances[this].div(_totalSupply).mul(_balances[msg.sender]);
TypeError: Type uint256 is not implicitly convertible to expected type mapping(address => uint256). _SavedDividend = _balances[this].div(_totalSupply).mul(_balances[msg.sender]);
TypeError: Return argument type mapping(address => uint256) is not implicitly convertible to expected type (type of first return variable) uint256. return _SavedDividend;
I don't understand what these mean. How do I fix this?
_SavedDividend[msg.sender]
in those places? The code you've written doesn't really make sense, so this is just a guess as to what you're trying to do.