How would I create a function where 3% of transactions gets sent to an address I assign?

I am creating an erc20 token that will serve as the currency between online communities, and I want to have an ethereum address that accumulates a 3% fee from all the transactions.

:computer: Environment

Remix

:memo:Details

This function i want to create will be similar to how some tokens burn x% of the transaction, but instead of burning, I'd like the coins to be sent to an address specified in the smart contract.
1 Like

Check out RFI, LIQ, SafeMoon, and many other cloned coins that use similar code for some examples. I’ve linked RFI and LIQ below.

What you will need to do is during a transfer, calculate the fee you want to take. This fee % takes the real amount and stores it somewhere. You transfer the rest of the amount as normal. Later on you transfer that fee amount to a wallet you want it to go to.

1 Like

Hey, welcome!

Just like abcoathup mentioned before:

If you create a fee on transfer or deflationary token (burn a percentage on transfer) 
this can cause issues with use in other contracts such as: 

Also I recommend looking at Points to consider when creating a fungible token (ERC20, ERC777)

1 Like