Solidity-firstSteps – 坚实的第一步区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Solidity-firstSteps – 坚实的第一步区块链毕设代写 是一篇很好的国外资料

Solidity-firstSteps

Variables

There is no null or undefined (U)Int = 0 Bool = false String = “”

For memory location —> modifiers memory and storage

Uint8 to Uint256 in 8 bit increments uint is an alias for uint256

Fixed Point Numbers —> they don’t exist

Address and address Payable

Strings

String is a byte array, but doesn’t have a length or index-access. They are expensive

Limited resources Variable initialization A public variable automatically creates a getter function in solidity

Mappings

  • All values are initialized by default.
  • Mappings don’t have a “length”.
  • Iterable mappings can be implemented using libraries.

Structs

  • Syntax similar to structs in C language.
  • Allow to define your own data type.
  • For gas cunsumption —> It’s better to define structs than objects.
  • Mapping and structs are a powerful combination.

Arrays

  • Fixed or dynamic size.
  • More intuitive (length, push), but mappings are more used because of the gas consumption.

Enums

  • Will be integers internally.
  • Up to 256 values —-> uint8 is used
  • More than 256 values —-> uint16 is used

Re-Entrancy and Checks-Effects-Interaction Pattern

As a rule of thumb: You interact with outside addresses last, no matter what. Unless you have a trusted source. So, first set your Variables to the state you want, as if someone could call back to the Smart Contract before you can execute the next line after .transfer(…). Read more about this here: https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html


坚固性第一步

变量

内存位置没有null或未定义的(U)Int=0 Bool=false String=“”

—>以8位增量修改内存和存储Uint8到Uint256 uint是Uint256的别名;它们不存在

地址和地址

字符串

字符串是字节数组,但没有长度或索引访问权限。它们是昂贵的

有限的资源变量初始化一个公共变量会自动创建一个稳定的getter函数

作为一个经验法则:不管发生什么,您最后与外部地址进行交互。除非你有可靠的消息来源。因此,首先将变量设置为所需的状态,就像有人可以在执行.transfer(…)之后的下一行之前回调智能合约一样。请在此处阅读更多信息:https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html

Limited resources Variable initialization A public variable automatically creates a getter function in solidity

映射

  • 所有值都由默认值
  • 映射没有“长度”
  • 可以使用库实现Iterable映射

结构

  • 允许定义自己的数据类型
  • 用于天然气消耗—>最好定义结构而不是对象
  • 固定或动态大小
  • 更直观(长度、推力),但由于气体消耗,映射被更多地使用

数组

  • 在内部将是整数
  • 最多256个值—>uint8的使用量大于256个值–>使用uint16

枚举

  • Will be integers internally.
  • Up to 256 values —-> uint8 is used
  • More than 256 values —-> uint16 is used

重入和检查效果交互模式

As a rule of thumb: You interact with outside addresses last, no matter what. Unless you have a trusted source. So, first set your Variables to the state you want, as if someone could call back to the Smart Contract before you can execute the next line after .transfer(…). Read more about this here: https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/23158.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Solidity-firstSteps – 坚实的第一步区块链毕设代写

提供最优质的资源集合

立即查看 了解详情