IDE:Atom 插件:autocomplete-solidity 代码自动补齐 linter-solium,linter-solidity代码检查错误 language-ethereum支持solidity代码高亮 1. 合约文件结构 版本号 : import 合约 :contract pragma solidity ^0.4.0; import "solidity_for_import.sol"; // this is a test contract contract T
库(Libraries) 库类似合约,实现仅在专门地址部署一次,使用EVM的DELEGATECALL的功能重复使用的目的.意思是当库函数被调用后,代码执行在被调用的合约的环境.例如,使用this调用合约,可以访问的调用合约的storage.孤立的库代码仅能访问变量,不能修改变量 pragma solidity ^0.4.16; library Set { struct Data { mapping(uint => bool) flags; } function insert(Data stora
函数过载 合约内允许定义同名函数,但是输入参数不一致 pragma solidity ^0.4.17; contract A { function f(uint _in) public pure returns (uint out) { out = 1; } function f(uint _in, bytes32 _key) public pure returns (uint out) { out = 2; } } pragma solidity ^0.4.16; contract A { f
View Functions 函数声明为视图,将无权修改状态 pragma solidity ^0.4.16; contract C { function f(uint a, uint b) public view returns (uint) { return a * (b + 42) + now; } } 以下操作属违规操作 1. Writing to state variables. 2. Emitting events. 3. Creating other contracts. 4. U
输入参数 pragma solidity ^0.4.16; contract Simple { function taker(uint _a, uint _b) public pure { // do something with _a and _b. } } 输出参数 pragma solidity ^0.4.16; contract Simple { function arithmetics(uint _a, uint _b) public pure returns (uint o_sum,
输入参数 pragma solidity ^0.4.16; contract Simple { function taker(uint _a, uint _b) public pure { // do something with _a and _b. } } 输出参数 pragma solidity ^0.4.16; contract Simple { function arithmetics(uint _a, uint _b) public pure returns (uint o_sum,