[Ethereum] Is an additional transaction fee possible in the ERC20 token

transactions

Is it possible to create a token contract that pays a tiny transaction fee in the ERC20 token to a third party?

This transaction fee has nothing to do with the ETH fees which will be paid first and foremost. This is a tiny fee on every transaction paid by the receiver at the time of the payment, like a credit card transaction fee off the top of the token value coming into the receiver's wallet.

Can a tiny part of each payment be diverted to a central account?

Let's just say as an example:

1% of each payment is skimmed off the top of each payment and sent or collected into a central wallet. Is this possible?? (this is not related to the ETH transaction fee)

Best Answer

Yes. That's pretty possible. It depends on the code of your smart contract. You can have a function that transfers 1% of the fee to a central account. You can have a function like this:

function transfer(address _to, uint256 _value) {
        require(_value%100 == 0);
        uint fee = _value/100; // for 1% fee
        require (balanceOf[msg.sender] > _value) ;                          // Check if the sender has enough balance
        require (balanceOf[_to] + _value > balanceOf[_to]);                // Check for overflows
        balanceOf[msg.sender] -= _value;                                    // Subtract from the sender
        balanceOf[_to] += (_value-fee);                                           // Add the same to the recipient
        balanceOf[thirdPartyAddress] += fee;
    }