【区块链时代】智能合约编程语言Solidity合约文件讲解

智能合约编程语言
【区块链时代】智能合约编程语言Solidity合约文件讲解_第1张图片
合约文件一般包括以下:
1、版本申明,告诉编译器使用那个版本编译器来编译这个合约文件。
2、import :指明合约文件会导入那些合约文件
3、合约:包含状态变量、函数、结构类型、事件、函数修改器
4、代码注释

案例代码:

# solidity1.sol
pragma solidity ^0.4.0;

import "solidity_for_import.sol";

// This is a test Contact

contract Test {
    uint a;

    function setA(uint x) public {
        a = x;
        emit Set_A(x);
    }

    event Set_A(unit a);

    struct Position {
        int lat;
        int lng;
    }

    address public owerAddr;

    modifier owner () {
        require(msg.sender == owerAddr);
        _;
    }

    function mine() public owner {
        require(msg.sender == owerAddr);
        a += 1;
    }
}

你可能感兴趣的:(Python,基础(完整版),区块链,Go基础知识(完整版),区块链,智能合约,以太坊)