Hello! Please advise me on Solidity :) I have ERC20Burnable token, I want to perform operations with token in separate contract and burn it through burn() function. But this function is not in SafeERC20, how can i burn tokens from outside :)
Aug 12, 2022, 12:05 PM
Okey.
Look, I have a contract in which I exchange my ERC20 tokens. When I exchange my tokens for other crypto I want to burn them. My ERC20 token has the extension ERC20Burnable. I want to call burn() to reduce the totalSupply of my token. I can use IERC20 (SafeERC20) to handle the token, but there is no burn() function, how can I call burn function from my ERC20Burnable token from other contract.
Look, I have a contract in which I exchange my ERC20 tokens. When I exchange my tokens for other crypto I want to burn them. My ERC20 token has the extension ERC20Burnable. I want to call burn() to reduce the totalSupply of my token. I can use IERC20 (SafeERC20) to handle the token, but there is no burn() function, how can I call burn function from my ERC20Burnable token from other contract.
Aug 12, 2022, 12:10 PM
call it from the token contract, not using safeERC20. so instead of "safeERC20.burn()" use "tokenContractName(contractAddress).burn()"
Aug 12, 2022, 12:13 PM
Depends on the context you're running it in? why cant you just call the burn method inside your contract after the exchange?
Aug 12, 2022, 12:13 PM
if the swap isn't directly connected you will need an interface
Aug 12, 2022, 12:13 PM
yes exactly. Is it directly connected?
Aug 12, 2022, 12:13 PM
you mean I need import my token contract ?
No, its different contracts
Aug 12, 2022, 12:14 PM
just put a basic interface in the contract to call your token
Aug 12, 2022, 12:14 PM
good idea, I try
Aug 12, 2022, 12:15 PM
interface iToken {
function burn() external;
}
^ literally all you need. just attach an address to that and it will work
function burn() external;
}
^ literally all you need. just attach an address to that and it will work
Aug 12, 2022, 12:15 PM
yes exactly. Add an interface in your contract for the burn function, and attach the address of the token you wanna burn
anyway, more complex things. Has anyone implemented a call from a chainlinkRequest contract? to another contract?
Aug 12, 2022, 12:19 PM
interface iERC20Burnable {
function burnFrom(address account, uint256 amount) external;
}
Is working 👍👍👍👍
function burnFrom(address account, uint256 amount) external;
}
Is working 👍👍👍👍
Aug 12, 2022, 12:28 PM