Solidity学习笔记--基础语法

定义约定俗成:变量小写开头,类型或合约大写开头

基础数据类型
bool
uint256 无符号整型,代表一个不允许负数的整数。
int256 有符号整型,代表一个能取到正数和负数的整数。
bytes32
string
address
合约:也可以作为数据类型去使用
https://binschool.org/solidity-basic/solidity-integer.html
 
转账函数
1 //  transfer 纯转账
2 // send  纯转账
3 // call  可以操作数据 官方建议使用

 

关键字
constant 常量
 
 
内置函数(环境变量)
msg
msg.sender —当前合约的调用者
msg.value —随消息发送的 wei 的数量
https://zhuanlan.zhihu.com/p/340068444(内置函数总结文档)
 
 
函数
public
private 无法被继承
internal
external

 

 
存储模式
storage 永久存储
memory 暂时存储 运行时可以修改 (基础数据类型不需要加memory)
calldata 暂时存储 运行时无法修改(js里的常量)
stack
codes
logs
 
 
基础数据结构:
结构体:struct (js中的类)
数组:array
映射:mapping
 
 
修改器
modifier
posted @ 2025-03-06 08:44  lzhflzjx  阅读(15)  评论(0)    收藏  举报