React - How do I implant msg.value in this2

Using some code I found online I was able to do some stuff (In this case Approve....) But is there any way I can add a "fee" to this say 1 ether which will be sent to a specific address?

const transferHandler = async (e) => {
		let transferAmount =;
		let recieverAddress =;

		let txt = await props.contract.approve(recieverAddress, transferAmount);
		setTransferHash("Transfer confirmation hash: " + txt.hash);

Can I set a "let fee = 1; and include this in the let txt = await props.con.......?

Charging fees in the front end is bad practice.
Charging fee on an approval is Worst.

When you transfer a token the call is sent to the token contract that moves the token. Any msg.value sent with your transfer will go to the token contract.

The correct way to do this would be to call a function that is payable and deal with the value it received.

1 Like