# How do I add multiple fees to get sent to two separate addresses?

**URL:** <https://forum.openzeppelin.com/t/how-do-i-add-multiple-fees-to-get-sent-to-two-separate-addresses/13151>\
**Category:** Contracts\
**Created:** [July 28, 2021, 7:30am UTC](https://forum.openzeppelin.com/t/how-do-i-add-multiple-fees-to-get-sent-to-two-separate-addresses/13151 "2021-07-28T07:30:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldlaz](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@oldlaz](https://forum.openzeppelin.com/u/oldlaz)\
**Post date:** [July 28, 2021, 7:30am UTC](https://forum.openzeppelin.com/t/how-do-i-add-multiple-fees-to-get-sent-to-two-separate-addresses/13151/1 "2021-07-28T07:30:06Z")

</div>

Hi,  
Hopefully this post title was appropriate to what I'm asking which is - how do I add a percentage fee to be sent to two different addresses with all token transactions? For example, a basic token with a 1% fee to be sent to one address and another 1% fee to be sent to another address? If the below code is indeed appropriate for doing this for a 1% fee to one address, I was wondering if someone can please tell me how to then go ahead and add the second fee and address to the same token? Thanks!

````auto
' ```
// pay 1% of all transactions to target address
    address payable target = ENTERANADDRESSHERE;

    // state variables for your token to track balances and to test
    mapping (address => uint) public balanceOf;
    uint public totalSupply;

    // create a token and assign all the tokens to the creator to test
    constructor(uint _totalSupply) public {
        totalSupply = _totalSupply;
        balanceOf[msg.sender] = totalSupply;
    }

    // the token transfer function with the addition of a 1% share that
    // goes to the target address specified above
    function transfer(address _to, uint amount) public {

        // calculate the share of tokens for your target address
        uint shareForX = amount/100;

        // save the previous balance of the sender for later assertion
        // verify that all works as intended
        uint senderBalance = balanceOf[msg.sender];
        
        // check the sender actually has enough tokens to transfer with function 
        // modifier
        require(senderBalance >= amount, 'Not enough balance');
        
        // reduce senders balance first to prevent the sender from sending more 
        // than he owns by submitting multiple transactions
        balanceOf[msg.sender] -= amount;
        
        // store the previous balance of the receiver for later assertion
        // verify that all works as intended
        uint receiverBalance = balanceOf[_to];

        // add the amount of tokens to the receiver but deduct the share for the
        // target address
        balanceOf[_to] += amount-shareForX;
        
        // add the share to the target address
        balanceOf[target] += shareForX;

        // check that everything works as intended, specifically checking that
        // the sum of tokens in all accounts is the same before and after
        // the transaction. 
        assert(balanceOf[msg.sender] + balanceOf[_to] + shareForX ==
            senderBalance + receiverBalance);
    }
}

````

```auto

```
