0

I was wondering if I e.g. use balanceOf(account[1]) += tax if the amount will also updated on Metamask and TrustWallet?

Here is an example code which I found where the addresses will be in mapping and the dividends will be incremented. But not sure if I need to do something else to update the values at Metamask and other Wallets?

pragma solidity 0.8.2;

contract TaxedToken {
    
    
    mapping(address => uint) internal balances;
    mapping(address => bool) internal isTokenHolder;
    uint totalTaxedAmount = 0;
    uint totalUniqueUsers = 0;
    uint tax = 10;
    address public owner;
    
    constructor() {
        owner = msg.sender;
        balances[owner] = 100;
        totalUniqueUsers = 1;
    }
    
    function balanceOf(address account) public view returns (uint) {
        return balances[account] + (totalTaxedAmount / totalUniqueUsers);
    }
    
    function transfer(address _to, uint _value) public {
        require(balanceOf(msg.sender) >= _value, "Insuficient funds");
        balances[msg.sender] =  balances[msg.sender] - _value;
        balances[_to] = balances[_to]  + _value - tax;
        if(!isTokenHolder[_to]) {
            isTokenHolder[_to] =  true;
            totalUniqueUsers++;
        }
        totalTaxedAmount += tax;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.