【发布时间】:2021-12-29 11:30:49
【问题描述】:
我正在尝试像这样可靠地编写付费功能:
contract GetFee {
address payable public feeCollector = 0x59c0f4Bea65c99C281A0107C86beE309b20b3B49;
function payFee() public payable {
feeCollector.transfer(100000000000000000);
}
}
但是当我点击它时,我得到以下错误:
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
如果我确实在部署和运行中插入任何数量,例如 1 ETH,它可以工作,但我不想这样做。
我想要一个功能,当点击它时,只需将特定金额发送到该特定地址,而无需用户插入任何其他内容。
怎么做?
【问题讨论】:
标签: solidity smartcontracts web3 web3js remix