728x90

스마트컨트랙트

 

 

객체지향언어의 class와 비슷하다

 

멤버 필드하나

생성자 하나

단일 클래스 만들어서 샐행하고 사용해보자

 

 

코드자동 컴파일

 

 

 

 

pragma solidity ^0.4.0;
contract SimpleCoin {
    //멤버 필드
    //public int num
    //map 변수 타입
    mapping (address => uint256) public coinBalance ;
    //mapping(string => addresss) public tenDatabase;
   // 생성자

    constructor() public {
        coinBalance
        [msg.sender] = 10000; //멤버필드 초기화
    }

    //메서드
    //해당주소에 얼마만큼 보내겟다
    function transfer(address _to, uint256 _amount) public {
        coinBalance[msg.sender] -= _amount;
        coinBalance[_to] += _amount;
    }
}

 

 


좀비 클립토에 있던 내용

솔리디티는 지수 연산도 지원하지 (즉, "x의 y승", x^y이지):

uint x = 5 ** 2; // 즉, 5^2 = 25

 

 

 

728x90

+ Recent posts