I've built a token sale contract for my new token but i can't figure out how to implement usdc as an acceptable exchange coin for my token
Asked
Active
Viewed 61 times
1 Answers
1
Could do something like this:
function sale(bool isUSDC, uint amount) external {
if(isUSDC) {
IERC20(USDCaddress).safeTransferFrom(msg.sender, address(this), amount);
uint tokenAmount = calculatePricePerUSD(amount);
IERC20(token).safeTransfer(msg.sender, tokenAmount);
} else {
require(msg.value == amount, "Received funds not sufficient");
uint tokenAmount = calculatePricePerETH(amount);
IERC20(token).safeTransfer(msg.sender, tokenAmount);
}
}
Nal Luksic
- 1,127
- 4
- 17