Remix IDE(a.k.a Browser-Solidity) 사용

in browser-solidity •  6 years ago 

1. Browser-Solidity 다운로드
https://github.com/ethereum/browser-solidity/ 에서 zip 파일을 다운로드 한다.

2. 실행
다운로드한 zip 파일을 적당한 곳에 풀고 index.html을 크롬 부라우저로 연다.

3. Contract 작성
좌측 상단의 (+) 기호를 클릭하여 새파일을 생성한다.

  • 파일명은 HelloWorld.sol 입력
  • 내용은
pragma solidity  ^0.4.8;

contract HelloWorld {
    string name;
    uint number;
    
    constructor (string _name) public{
        name = _name;
    }

    function getName() public constant returns (string) {
        return name;
    }

    function getNumber() public constant returns (uint) {
        return number;
    }

    function setNumber(uint _number) public {
        number = _number;
    }
}



4. 컴파일
우측상단의 [Compile] 탭 클릭 , 컴파일 화면에서 컴파일 및 error 및 warning 확인



5. 테스트

  • 오른쪽 [Run] 탭에서 Environment : JavaScript VM 을 확인하고
  • 계약을 생성하기 위한 초기값을 입력하고 [Create] 버튼을 클릭하여 생성한다.
    [주의할 점은 HelloWorld의 경우 생성자의 인수값이 string 이므로 반드시 쌍따옴표(") 를 사용하여 입력해야 한다.]

  • 계약이 생성된후 모습

  • 우측에 표시된 계약에 정의된 함수들을 실행해본다.
    [getNumber, getName, setNumber 등의 함수가 기대대로 정상적인 작동을 하는지 확인]



6. 이더리움 노드 접속 및 계약 배포, 실행

6.1 로컬 노드 실행 및 account unlock

  • 로컬노드 실행
    C:\Geth>geth --networkid 1185 --nodiscover --maxpeers 0 --datadir C:\Geth\dev_data --rpc --rpcaddr "0.0.0.0" --rpcport 8545 --rpccorsdomain "*" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" console 2>> C:\Geth\dev_data\geth.log

  • 사용할 account unlock
    >personal.unlockAccount(eth.accounts[0], "pass0", 0)

6.2 이더리움 노드 접속

  • 오른쪽 상단 메뉴중 [Run] 선택
  • Environment : [Web3 Provider] 선택
  • Web3 Provider Endpoint : http://localhost:8545 입력
    (로컬에 8545 포트로 Geth 실행중인 경우)

6.3 계약 배포

  • 초기값 입력 후 [Create] 클릭

  • Geth 노드가 mining을 아직 실행하지 않은 경우 pending 상태

  • mining이 완료되어 계약이 배포된 상태

  • 우측에 표시된 계약에 정의된 함수들을 실행해본다.
    [getNumber, getName, setNumber 등의 함수가 기대대로 정상적인 작동을 하는지 확인]

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @bluezoid! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard - Witness Update
Vote for @Steemitboard as a witness to get one more award and increased upvotes!