07 2022 档案
发表于 2022-07-31 22:53阅读:19评论:0推荐:0
摘要:Solidity supports multiple inheritance. Contracts can inherit other contract by using the is keyword. Function that is going to be overridden by a chi
阅读全文 »
发表于 2022-07-31 22:52阅读:13评论:0推荐:0
摘要:Constants are variables that cannot be modified. Their value is hard coded and using constants can save gas cost. // SPDX-License-Identifier: MIT prag
阅读全文 »
发表于 2022-07-31 22:35阅读:17评论:0推荐:0
摘要:There are several ways to return outputs from a function. Public functions cannot accept certain data types as inputs or outputs // SPDX-License-Ident
阅读全文 »
发表于 2022-07-31 22:34阅读:15评论:0推荐:0
摘要:Getter functions can be declared view or pure. View function declares that no state will be changed. Pure function declares that no state variable wil
阅读全文 »
发表于 2022-07-31 22:33阅读:67评论:0推荐:0
摘要:A constructor is an optional function that is executed upon contract creation. Here are examples of how to pass arguments to constructors. // SPDX-Lic
阅读全文 »
发表于 2022-07-31 22:20阅读:38评论:0推荐:0
摘要:An error will undo all changes made to the state during a transaction. You can throw an error by calling require, revert or assert. require is used to
阅读全文 »
发表于 2022-07-31 22:19阅读:23评论:0推荐:0
摘要:Unlike functions, state variables cannot be overridden by re-declaring it in the child contract. Let's learn how to correctly override inherited state
阅读全文 »
发表于 2022-07-31 22:17阅读:29评论:0推荐:0
摘要:When a function is called, the first 4 bytes of calldata specifies which function to call. This 4 bytes is called a function selector. Take for exampl
阅读全文 »
发表于 2022-07-31 22:16阅读:9评论:0推荐:0
摘要:fallback is a function that does not take any arguments and does not return anything. It is executed either when a function that does not exist is cal
阅读全文 »
发表于 2022-07-31 22:02阅读:43评论:0推荐:0
摘要:You can interact with other contracts by declaring an Interface. Interface cannot have any functions implemented can inherit from other interfaces all
阅读全文 »
发表于 2022-07-31 22:02阅读:36评论:0推荐:0
摘要:Functions and addresses declared payable can receive ether into the contract. // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; contract Payabl
阅读全文 »
发表于 2022-07-31 21:58阅读:20评论:0推荐:0
摘要:Functions and state variables have to declare whether they are accessible by other contracts. Functions can be declared as public - any contract and a
阅读全文 »
发表于 2022-07-31 21:57阅读:30评论:0推荐:0
摘要:Parent contracts can be called directly, or by using the keyword super. By using the keyword super, all of the immediate parent contracts will be call
阅读全文 »
发表于 2022-07-31 21:56阅读:20评论:0推荐:0
摘要:原文网址:https://solidity-by-example.org/new-contract/ Contracts can be created by other contracts using the new keyword. Since 0.8.0, new keyword support
阅读全文 »
发表于 2022-07-31 21:55阅读:75评论:0推荐:0
摘要:try / catch can only catch errors from external function calls and contract creation. // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; // Exte
阅读全文 »
发表于 2022-07-31 21:54阅读:17评论:0推荐:0
摘要:You can import local and external files in Solidity. Local Here is our folder structure. ├── Import.sol └── Foo.sol Foo.sol // SPDX-License-Identifier
阅读全文 »
发表于 2022-07-31 21:54阅读:23评论:0推荐:0
摘要:Contract can call other contracts in 2 ways. The easiest way to is to just call it, like A.foo(x, y, z). Another way to call other contracts is to use
阅读全文 »
发表于 2022-07-29 18:39阅读:151评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0//通过合约部署合约,通过代理合约去部署, pragma solidity ^0.8.3; contract TestContract1 { address public owner = msg.sender; function
阅读全文 »
发表于 2022-07-29 17:26阅读:85评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.3; contract Enum { enum Status {//枚举和结构体都是一种类型 None, Pending, Shipped, Completed, Rejected, C
阅读全文 »
发表于 2022-07-29 16:01阅读:116评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.3; contract Structs {//结构体是能够将多种变量格式打包一起的数据格式,以一种类型的形式存在 struct Car { string model;//默认值字符串 u
阅读全文 »
发表于 2022-07-29 12:27阅读:50评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; contract IterableMapping { mapping(address => uint) public balances;//地址对应余额映射 mapping(add
阅读全文 »
发表于 2022-07-28 23:37阅读:211评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; //remove array element by shifting elements to left //[1,2,3,4,5,6] -- remove(2) --> [1,2,
阅读全文 »
发表于 2022-07-28 23:37阅读:69评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; //mapping //how to declare a mapping (simple and nested) //Set, get ,delete //["alice", "b
阅读全文 »
发表于 2022-07-27 12:38阅读:148评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; contract ArrayShift { uint[] public arr; function example() public { arr = [1,2,3]; delete
阅读全文 »
发表于 2022-07-26 22:31阅读:113评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 //array -dynamic or fixed size //Initialization // Insert(push),get, update, delete,pop, length // createing array
阅读全文 »
发表于 2022-07-26 15:33阅读:31评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; contract FunctionOutputs { function returnMany() public pure returns (uint, bool) { return
阅读全文 »
发表于 2022-07-26 11:41阅读:71评论:0推荐:0
摘要:// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; contract Ownable { address public owner; constructor() { owner = msg.sender; } modifier on
阅读全文 »
发表于 2022-07-25 00:43阅读:38评论:0推荐:0
摘要:一些变量的固定值,这些变量的值不能在部署合约后被任何函数修改;管理员地址和特殊编码通常定义为常量。默认常量可以减少gas费消耗
阅读全文 »
发表于 2022-07-23 23:38阅读:639评论:0推荐:0
摘要:chrome谷歌商店搜索sui钱包安装
阅读全文 »
发表于 2022-07-22 23:30阅读:35评论:0推荐:0
摘要:bytes32 public constant INIT_CODE_PAIR_HASH = keccak256(abi.encodePacked(type(UniswapV2Pair).creationCode));
阅读全文 »
发表于 2022-07-20 00:11阅读:781评论:0推荐:0
摘要:multical合约作用:在运行一个交易所/去中心化金融dapp的项目前端时,前端要向区块链读很多数据,也许一个页面就充满了数据,tlv ,币价,挖矿合约,锁仓量。这些数据需要一个个去链上读取一个个合约,一个个方法去读,但是这样会造成大量的对链请求。可以将大量的请求安装以太坊的规则进行封装,然后一次
阅读全文 »
发表于 2022-07-18 22:56阅读:166评论:0推荐:0
摘要:一、新的特性 安全数学:老版本是没有的,会出现数学溢出的。之前的uint无符号正整数有数学溢出,在使用的时候都要引用安全数学的方法,0-1得到的是uint256最大值并不会得-1,因为uint是无符号整数,不会出现-1。 // SPDX-License-Identifier: MIT pragma
阅读全文 »
发表于 2022-07-11 10:14阅读:21评论:0推荐:0
摘要:JavaScript 异步编程:https://www.runoob.com/js/js-async.html JavaScript Promise 对象:https://www.runoob.com/w3cnote/javascript-promise-object.html , https://
阅读全文 »
发表于 2022-07-04 18:33阅读:199评论:0推荐:0
摘要:react中,ReactDOM.render{<Persion{...P}>} 此花括号是做一个分隔符再用,这里的...P JS原生中是用来浅拷贝 (Shallow-cloning,不包含 prototype) 和对象合并,https://developer.mozilla.org/zh-CN/do
阅读全文 »
发表于 2022-07-03 17:46阅读:41评论:0推荐:0
摘要:官方严格模式介绍:https://react.docschina.org/docs/strict-mode.html 查看严格模式网址,在F12控制台一般可以找到https://babeljs.io/repl JSX其实就是JS的语法糖 //2.渲染组件到页面 ReactDOM.render(<My
阅读全文 »