上一页 1 ··· 5 6 7 8 9 10 11 下一页
摘要: 例子 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 阅读(104) 评论(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 阅读(42) 评论(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 阅读(359) 评论(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 阅读(480) 评论(2) 推荐(0)
摘要: Solidity 语法里面用到的两种变量类型 Memory 和 Storage 的关系就像电脑的内存和硬盘的,memory 是和内存一样是暂时存储,storage 像硬盘一样是永久存储。 memory 是值传递,storage 是引用类型 在合约里面,函数外的变量默认通过 storage 存储,函数 阅读全文
posted @ 2022-05-13 21:57 apeNote 阅读(539) 评论(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 阅读(304) 评论(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 阅读(133) 评论(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 阅读(80) 评论(0) 推荐(0)
摘要: assert contract ErrorTest { uint256 public balance; function deposit(uint256 _amount) public{ balance = balance + _amount; } function withdraw(uint256 阅读全文
posted @ 2022-05-05 08:54 apeNote 阅读(21) 评论(0) 推荐(0)
摘要: test contract EventTest { event Log1(address sender, uint256 val); string log; function test() external{ emit Log1(msg.sender, 100); log = 'logTest'; 阅读全文
posted @ 2022-05-05 00:41 apeNote 阅读(36) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 下一页