这可能是我错过的一个简单错误,但我一生都无法弄清楚如何在这个合同中设置 msg.value 变量。我在网上读到这个值是与交易相关的 wei 数量,但是作为合约的调用者,我如何具体设置该值。这是我正在努力处理的合同。
杂注坚固性 0.8.7;
合同自动售货机 {
// Declare state variables of the contract
address public owner;
mapping (address => uint) public cupcakeBalances;
// When 'VendingMachine' contract is deployed:
// 1. set the deploying address as the owner of the contract
// 2. set the deployed smart contract's cupcake balance to 100
constructor() {
owner = msg.sender;
cupcakeBalances[address(this)] = 100;
}
// Allow the owner to increase the smart contract's cupcake balance
function refill(uint amount) public {
require(msg.sender …Run Code Online (Sandbox Code Playgroud)