Solidity 038Constructor

// SPDX-License-Identifier: MIT

// Specifies the license under which this contract is made available; MIT License in this case

pragma solidity ^0.8.9;

// Specifies the compiler version this contract is compatible with

// Define a contract named HelloWorld

contract HelloWorld {

  // Declare a private state variable of type uint (unsigned integer)

  // This variable is not accessible outside of this contract directly

  uint private simpleInt;

  // Constructor function that's called when the contract is deployed

  // Sets the initial value of simpleInt to 5

  constructor() {

    simpleInt = 5;

  }

  // Public function that returns the current value of simpleInt

  // Marked as view because it doesn't modify the contract's state

  function GetValue() public view returns (uint) {

    return simpleInt;

  }

  // Public function that allows updating the value of simpleInt

  // Takes an unsigned integer _value as input

  function SetValue(uint _value) public {

    simpleInt = _value;

  }

}

// Deploy:

相关推荐

  1. FAQ:Constructors

    2024-02-05 23:14:02       43 阅读
  2. solidity(16)

    2024-02-05 23:14:02       35 阅读
  3. Kotlin关键字二——constructor和init

    2024-02-05 23:14:02       64 阅读
  4. prototype、__proto__、constructor、原型、原型链

    2024-02-05 23:14:02       67 阅读
  5. iOS 中 attribute((constructor)) 修饰的函数

    2024-02-05 23:14:02       27 阅读
  6. Solidity学习教程

    2024-02-05 23:14:02       49 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-05 23:14:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-05 23:14:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-05 23:14:02       82 阅读
  4. Python语言-面向对象

    2024-02-05 23:14:02       91 阅读

热门阅读

  1. Docker

    Docker

    2024-02-05 23:14:02      43 阅读
  2. Postgresql PostGIS扩展

    2024-02-05 23:14:02       45 阅读
  3. 每日一题 力扣292 Nim游戏

    2024-02-05 23:14:02       40 阅读
  4. 流媒体传输开源协议SRT

    2024-02-05 23:14:02       59 阅读
  5. 深度学习的进展:人工智能时代的里程碑

    2024-02-05 23:14:02       50 阅读
  6. LeetCode 热题 100 | 链表(下)

    2024-02-05 23:14:02       54 阅读