声明 @payable的功能可以接收以太币。
# @version ^0.3.7
event Deposit:
sender: indexed(address)
amount: uint256
@external
@payable
def deposit():
log Deposit(msg.sender, msg.value)
@external
@view
def getBalance() -> uint256:
# Get balance of Ether stored in this contract
return self.balance
owner: public(address)
@external
@payable
def pay():
assert msg.value > 0, "msg.value = 0"
self.owner = msg.sender
Yanbo的Twitter|Web3Club的Twitter
加入Web3Club 官方讨论群:YanboTravelAllWorld(微信号)