I'm trying to write a token that sends a percentage fee to a fee collecting smart contract that does stuff with the token. I start off with writing a token and I point it toward the fee collecting address (meaning it already has to have been made) then how am I supposed to add the token address to the fee collecting smart contracts source code so after it recives it it can be aware of it and do stuff with it. I can't edit anything
1 Answer
You can use a variable to store the address and update it when needed. Be sure to use modifier to ensure only the owner is able to call the update token address function.
address public tokenAddress;
function updateTokenAddress(address tokenAddy) public
{
tokenAddress = tokenAddy;
}
-
-
If both the contracts are available to the public and the contract address is visible to the public, I don't see any trust issue. Maybe there are better ways, keen to know as well. Commented Nov 1, 2022 at 3:45
-
people can say that I will change the contract address in the future to something else Commented Nov 1, 2022 at 4:00
-
I've noticed that token smart contracts can also hold tokens themselves. is it possible to make that the fee address? Commented Nov 1, 2022 at 4:03