Programming Language/Solidity
Solidity - Variables
Yongari
2022. 12. 21. 21:39
There are 3 types of variables in Solidity
Solidity에는 세 가지 유형의 변수가 있습니다.
- local
- declared inside a function : 함수 내부에 선언한 로컬 변수
- not stored on the blockchain : 블록체인에 저장되지 않는 로컬 변수
- state
- declared outside a function : 함수 밖에서 선언된 스테이트 변수
- stored on the blockchain : 블록체인에 저장된 스테이트 변수
- global (provides information about the blockchain) : 블록체인에 대한 정보를 표시하는 글로벌 변수
// SPDX-License-Identifier: MIT
// 라이선스 표시
pragma solidity ^0.8.13;
//솔리디티 버전 명시
contract Variables {
// State variables are stored on the blockchain.
// 스테이트 변수는 블록체인에 저장됩니다.
string public text = "Hello";
uint public num = 123;
function doSomething() public {
// Local variables are not saved to the blockchain.
// 로컬 변수는 블록체인에 저장되지 않습니다.
uint i = 456;
// Here are some global variables
// 여기에 있는 변수는 글로벌 변수입니다.
uint timestamp = block.timestamp; // Current block timestamp 현재 블록 타임스탬프
address sender = msg.sender; // address of the caller 호출한 사람의 주소
}
}
Remix 솔리디티 주소 : 링크