1 Star 0 Fork 0

zhupeng911/solidity

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
19-test_contractAPI.sol 790 Bytes
一键复制 编辑 原始数据 按行查看 历史
朱鹏 提交于 2018-11-12 16:54 +08:00 . 合约API
pragma solidity ^0.4.25;//声明编译器版本,^表示向上兼容
//合约API
contract testContractAPI{
address owner;
constructor() {
owner=msg.sender;
}
function Hello() public view returns (string){
return "Hello";
}
//销毁合约 但是存在安全隐患
function destroyContract() public{
this.Hello();
selfdestruct(owner);
}
//合约的销毁者必须是合约的创建者
function killContract() public{
require(msg.sender==owner);
selfdestruct(owner);
}
}
contract testCall{
function Hello() public view returns (string){
return "Hello";
}
function call(address a){
a.delegatecall(bytes4(sha3("destroyContract()")));
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhupeng911/solidity.git
git@gitee.com:zhupeng911/solidity.git
zhupeng911
solidity
solidity
master

搜索帮助