I need to use the functions of the ERC20 contract in another contract.
The ERC20 contract is from the openZeppelin contract library. I found the following code on a website:
import "../../node_modules/zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
contract Escrow is Ownable {
ERC20 public currency;
address public collectionAddress;
function Escrow(ERC20 _currency, address _collectionAddress) public {
currency = _currency;
collectionAddress = _collectionAddress;
}
}
In this code, ERC20 instance is passed as an argument to the constructor of Escrow. That means that the ERC20 instance is stored in the Escrow contract's state variable at the time of the deployment of the Escrow contract.
I want to know how to write the deployment code for passing one contract instance as an argument to the constructor of another contract in truffle.
Also, should the ERC20 contract be deployed before the Escrow contract in Truffle or can both the contracts be deployed together?
If so, then what would the deployment script in truffle look like ?