我正试图在本地机器上部署sushiSwap。但我不知道我应该在构造函数中传递什么论点..。密码就像..。
pragma solidity 0.6.12;
import "./IERC20.sol";
import "./ERC20.sol";
import "./SafeMath.sol";
contract SushiBar is ERC20("SushiBar", "xSUSHI"){
using SafeMath for uint256;
IERC20 public sushi;
constructor(IERC20 _sushi) public {
sushi = _sushi;
}
// Enter the bar. Pay some SUSHIs. Earn some shares.
function enter(uint256 _amount) public {
uint256 totalSushi = sushi.balanceOf(address(this));
uint256 totalShares = totalSupply();
if (totalShares == 0 || totalSushi == 0) {
_mint(msg.sender, _amount);
} else {
uint256 what = _amount.mul(totalShares).div(totalSushi);
_mint(msg.sender, what);
}
sushi.transferFrom(msg.sender, address(this), _amount);
}..。等等
发布于 2020-11-28 07:08:30
每当您需要传递契约实例(或描述实例的接口)时,都会传递一个address。因此,您只需要传递一个实现IERC20的契约的地址。
在您的例子中,我不确定对于_sushi到底应该是什么有一些额外的要求--任何IERC20在语法上都是正确的,但是它可能还有其他一些要求(可能是LP标记吗?)
https://ethereum.stackexchange.com/questions/90570
复制相似问题