Get in touch with us! We’re here to assist you. Please fill out the form below, and we’ll respond to your inquiry as soon as possible.

Կարդալ և գրել վիճակի փոփոխականին

Վիճակի փոփոխական գրելու կամ թարմացնելու համար անհրաժեշտ է գործարք ուղարկել:

Մյուս կողմից, դուք կարող եք կարդալ վիճակի փոփոխականները, անվճար, առանց գործարքի վճարի:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract SimpleStorage {
    // Վիճակի փոփոխական՝ թիվը պահելու համար
    uint public num;

    // Դուք պետք է գործարք ուղարկեք՝ վիճակի փոփոխականին գրելու համար:
    function set(uint _num) public {
        num = _num;
    }

    // You can read from a state variable without sending a transaction.
    function get() public view returns (uint) {
        return num;
    }
}

Փորձեք Remix-ում

What are your feelings