上一页 1 ··· 4 5 6 7 8 9 10 11 下一页
摘要: A合约调用B合约 合约B contract B { uint public x; uint public value; function setX(uint _x) public returns (uint){ x = _x; return x; } function setXandSendEthe 阅读全文
posted @ 2022-06-08 23:29 apeNote 阅读(380) 评论(0) 推荐(0) 编辑
摘要: delegateCall 用于重定向父合约; A 合约越来调用B1, 将地址改为 B2 就可以调用 B2 合约B1 contract B { uint public num; uint public value; function setVars(uint _num) public payable{ 阅读全文
posted @ 2022-06-08 22:10 apeNote 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 例子 receive contract ReceiveTest { event Received(address caller, uint256 amount, string msg); function getBalance() public view returns(uint256){ retu 阅读全文
posted @ 2022-06-08 11:52 apeNote 阅读(87) 评论(0) 推荐(0) 编辑
摘要: test pragma solidity >=0.7.0 <0.9.0; contract ReceiveTest { string public data; receive() external payable{ data = "receive call"; } fallback() extern 阅读全文
posted @ 2022-06-08 09:55 apeNote 阅读(25) 评论(0) 推荐(0) 编辑
摘要: recieve 接收token函数 pragma solidity >=0.7.0 <0.9.0; contract ReceiveTest { receive() external payable{ } fallback() external payable{ } function getBala 阅读全文
posted @ 2022-06-06 15:21 apeNote 阅读(270) 评论(0) 推荐(0) 编辑
摘要: payable 的使用 合约可以接受 token, 也可以发送 token 通过使用 payable 关键字。 1、通过修饰方法, 例子1 一个充值函数,一个体现函数 pragma solidity >=0.7.0 <0.9.0; contract Payable { mapping(address 阅读全文
posted @ 2022-06-06 09:59 apeNote 阅读(424) 评论(2) 推荐(0) 编辑
摘要: Solidity 语法里面用到的两种变量类型 Memory 和 Storage 的关系就像电脑的内存和硬盘的,memory 是和内存一样是暂时存储,storage 像硬盘一样是永久存储。 memory 是值传递,storage 是引用类型 在合约里面,函数外的变量默认通过 storage 存储,函数 阅读全文
posted @ 2022-05-13 21:57 apeNote 阅读(492) 评论(0) 推荐(0) 编辑
摘要: Map 例子 contract MapTest { mapping(address => uint256) public account; function getAccount(address _addr) public view returns (uint256){ return account 阅读全文
posted @ 2022-05-09 22:31 apeNote 阅读(284) 评论(0) 推荐(0) 编辑
摘要: 数组 例子 contract ArrayTest { uint256[] public array01; uint256[] public array02=[1,2,3]; function push(uint256 i) public{ array01.push(i); } function po 阅读全文
posted @ 2022-05-09 22:18 apeNote 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 循环代码 contract LoopTest { uint256 public counter; function loopTest(uint n) public { for(uint i=0; i<n; i++){ counter += 1; } } } 输出 阅读全文
posted @ 2022-05-05 08:59 apeNote 阅读(62) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 下一页