入门智能合约

    1. // demo1.sol
    2. // SPDX-License-Identifier: GPL-3.0
    3. pragma solidity >=0.6.0 <0.7.0;
    4. contract SimpleStorage {
    5. uint storedData;
    6. uint256 price;
    7. function set(uint x) public {
    8. storedData = x;
    9. }
    10. function get() public view returns (uint) {
    11. return storedData;
    12. }
    13. function setPrice(uint256 x) public {
    14. price = x;
    15. }
    16. function getPrice() public view returns (uint256) {
    17. return price;
    18. }
    19. }