当前位置:网站首页>solidity转账函数的实现(基于transfer)
solidity转账函数的实现(基于transfer)
2022-07-28 17:02:00 【CSDN】
contract cs{
address public creator;
constructor()public payable{
creator = msg.sender;
}
function getETH()public{
require(
address(this).balance>=0.01 ether,
"合约没钱了,给合约打钱"
);
address _owner = msg.sender;
_owner.transfer(0.01 ether);
}
function()payable{
}
}
Note:
使用这个合约的时候需要合约里面有以太
不然合约将无法给调用者发送以太
可以在创建合约时给合约发送一定的以太来测试
边栏推荐
- Openmv (II) -- ide installation and firmware download
- Tips -- understanding of the physical meaning of convolution
- 视频号一场书法直播近20万人观看
- 频谱仪原理简介一
- 通过公众号等私域渠道,为视频号直播引流
- Openmv (I) -- basic introduction and hardware architecture
- 沪硅产业上半年营收8.5亿元,同比增长30.53%!各类产品认证正在加速
- Some methods of realizing video account
- 企业微信和视频号的关联
- Outdoor activities in hot weather are exquisite! Here comes the safety guide for citizens' fitness in midsummer
猜你喜欢

七个步骤,深入解读数据含义

Five key considerations for network security budget planning in 2023

Leetcode--45. jumping game II (greed)

Openmv (II) -- ide installation and firmware download

Digital filter (IV) -- converting analog filter into digital filter

个人制作:AD库、元件库、封装库及3D模型,免费

频谱仪原理简介二

矢量网络分析仪(矢网)的校准

Power adapter global definition

Openmv (VI) -- STM32 realizes object recognition and handwritten digit recognition
随机推荐
Functions brought by the binding of official account and video Number
Members who have opened a website need to download e-book messages for free
Openmv (II) -- ide installation and firmware download
Digital filter (VI) -- design FIR filter
沪硅产业上半年营收8.5亿元,同比增长30.53%!各类产品认证正在加速
Application of Internet of things in smart city
[dry goods] how to establish a close relationship between support and products?
Ren Zhengfei's latest voice: American politicians hope Huawei will die, and the desire to survive inspires Huawei
ADS仿真 之 直流仿真示例
开了一个网站的会员,需要下载电子书的留言即可,免费帮下载
Apple supplier JDI plans to sell Baishan LCD plant and equipment for us $675million
示波器探头详解
Live video Number supports product playback
Digital filter (I) -- basic structure and matlab implementation of IIR and fir
视频号电商未来的前景如何?
横向listview的最佳实现——RecycleView
苹果供应商JDI拟以6.75亿美元出售白山LCD工厂和设备
Advanced Design System(ADS)2009 射频仿真入门
DC-DC开关电源
中芯国际上半年净利13.86亿元,N+1工艺已进入客户产品验证阶段