随笔分类 - Solidity
发表于 2022-08-16 00:53阅读:24评论:0推荐:0
摘要:Sending Ether (transfer, send, call) How to send Ether? You can send Ether to other contracts by transfer (2300 gas, throws error) send (2300 gas, ret
阅读全文 »
发表于 2022-08-10 22:09阅读:281评论:0推荐:1
摘要:github网址:https://github.com/ethereum/solc.js 知乎大佬小结:solc编译器分析 - 粒子区块链的文章 - 知乎 https://zhuanlan.zhihu.com/p/164633644 腾讯云大佬总结 https://cloud.tencent.com
阅读全文 »
发表于 2022-08-02 12:10阅读:19评论:0推荐:0
摘要:Events allow logging to the Ethereum blockchain. Some use cases for events are: Listening for events and updating user interface A cheap form of stora
阅读全文 »
发表于 2022-08-01 00:29阅读:17评论:0推荐:0
摘要:Libraries are similar to contracts, but you can't declare any state variable and you can't send ether. A library is embedded into the contract if all
阅读全文 »
发表于 2022-08-01 00:26阅读:16评论:0推荐:0
摘要:Ether WalletAn example of a basic wallet. Anyone can send ETH.Only the owner can withdraw. // SPDX-License-Identifier: MITpragma solidity ^0.8.13; con
阅读全文 »
发表于 2022-08-01 00:26阅读:27评论:0推荐:0
摘要:Modifiers are code that can be run before and / or after a function call. Modifiers can be used to: Restrict access Validate inputs Guard against reen
阅读全文 »
发表于 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: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 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: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
阅读全文 »