solidity remix(3)
-
Solidity )remix 스마트 컨트랙트 예약 예제
Solidity 예제로 호텔 예약을 스마트 컨트랙트(예제)로 구현해보았다. // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; contract HotelBook { enum Status { Vacant,Occupied } Status currentStatus; address payable public owner; //payable 키워드 계약 계정에 이더를 사용 (입금,송금,송신 등) 할 수 있게 해준다. event Occupy(address _occupant, uint _value); constructor() public { owner = msg.sender; //본인 지갑 currentStatus = Status.Vacant; } modifier..
2021.07.14 -
Solidity)remix 짝수 판별 / 반복문
Solidity remix로 짝수 홀수 구분하는 반복문 배열이 1~10이니 짝수는 5개여서 countEvenNumbers 값이 5 isEvenNumber에 짝수를 입력하면 true 홀수를 입력하면 false
2021.07.14 -
Solidity ) mapping - 조건문
Mapping 일반적인 프로그래밍 언어에서는 해시 테이블이나 사전과 유사하다. key - value 형태로 쌍으로 저장되고 제공된 key를 가지고 value를 얻을 수 있다. mapping(_KeyType=>_ValueType) 같이 선언된다. _KeyType은 매핑, 동적크기 배열, 컨트랙트, 열거형 구조체를 제외한 거의 모든 유형이 될 수 있다. _ValueType은 매핑타입을 포함한 어떤 타입이든 될 수 있다. solidity 5.0 버전이상에서는 string에 memory 선언을 해줘야 한다. msg.sender는 자기 주소이다.
2021.07.14