自学以太坊智能合约,一知半解之下碰到很多问题,遂记录下,方便以后查找。
第一个智能合约(Faucet)
观看的B站尚硅谷的深入掌握以太坊核心技术-智能合约入门,仿着写个水龙头的智能合约
// Version of Solidity compiler this program was written for
pragma solidity ^0.4.19;
// Our first contract is a faucet!
contract Faucet {
// Give out ether to anyone who asks
function withdraw(uint withdraw_amount) public {
// Limit withdrawal amount
require(withdraw_amount <= 100000000000000000);
// Send the amount to the address that requested it
msg.sender.transfer(withdraw_amount);
}
// Accept any incoming amount
function () public payable {}
}
编译通过:
但是该学习视频已经是两年前的了,用的编译版本比较旧,remix上的例子里,版本都是
// SPDX-License-Identifier: GPL-3.0
pragma solidity >&#