Loading...
If you have not deployed your ERC20 token yet you can deploy it using openzeppelin as described in this smartbook.
If you want to implement any token functions that is already deployed , say it you want to use link, usdt, or any other tokens in your smart contract it can be easily done with IERC20 interface. here is coed explaining the contract and using interface function of other tokens function in our own contract.
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract DEX {
IERC20 token;
constructor() public {
token = IERC20(0x01BE23585060835E02B77ef475b0Cc51aA1e0709);
// this token address is LINK token deployed on Rinkeby testnet
// You can use any other ERC20 token smart contarct address here
}
function getbalanceheer(address _address) public view returns(uint256){
return token.balanceOf(_address);// balancdOf function is already declared in ERC20 token function
}
/* Similar to the above function you can directly use transfer, approve, transferFrom , etc function and
use the token in your custom contract */
}