Is it possible to define variables representing addresses contracts with known interfaces which aren't created by the contract referring to them?
For example, could you write an act specification for this?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function transfer(address recipient, uint256 amount) external;
}
contract TransferOneToken {
IERC20 public token;
constructor(IERC20 _tokenAddress) {
require(address(_tokenAddress) != address(0), "Invalid token address");
token = _tokenAddress;
}
function transfer() public {
// Transfer 1 token from the contract to the sender
uint256 transferAmt = 1;
token.transfer(msg.sender, transferAmt);
}
}
Is it possible to define variables representing addresses contracts with known interfaces which aren't created by the contract referring to them?
For example, could you write an act specification for this?