ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • General Information
    Blockchain Security/solc 2022. 7. 16. 16:59

    solc --version

     버전 확인이 가능하다. 

     

    solc --license

     solc이랑 관련된 license 정보가 다 나온다.

     

    solc --input-file "arg"

     solc 로 input file에 대해 compile의 유무를 확인하고 arg 자리에는 파일명을 입력해주면 된다. 지금 내 파일 안에 subcurrency.sol 파일을 예시로 삼아서 했고, 그 결과는 위 사진처럼 나온다.

     일단 이 명령어가 실행되려면 문법이 어긋나서는 안되고, pragma solidity '숫자버전'의 유무도 중요하다고 생각한다. subcurrency.sol 코드는 아래와 같다.

     

    • subcurrency.sol
    // SPDX-License-Identifier: GPL-3.0
    pragma solidity ^0.8.4;
    
    contract Coin {
        // The keyword "public" makes variables
        // accessible from other contracts
        address public minter;
        mapping (address => uint) public balances;
    
        // Events allow clients to react to specific
        // contract changes you declare
        event Sent(address from, address to, uint amount);
    
        // Constructor code is only run when the contract
        // is created
        constructor() {
            minter = msg.sender;
        }
    
        // Sends an amount of newly created coins to an address
        // Can only be called by the contract creator
        function mint(address receiver, uint amount) public {
            require(msg.sender == minter);
            balances[receiver] += amount;
        }
    
        // Errors allow you to provide information about
        // why an operation failed. They are returned
        // to the caller of the function.
        error InsufficientBalance(uint requested, uint available);
    
        // Sends an amount of existing coins
        // from any caller to an address
        function send(address receiver, uint amount) public {
            if (amount > balances[msg.sender])
                revert InsufficientBalance({
                    requested: amount,
                    available: balances[msg.sender]
                });
    
            balances[msg.sender] -= amount;
            balances[receiver] += amount;
            emit Sent(msg.sender, receiver, amount);
        }
    }

     

    'Blockchain Security > solc' 카테고리의 다른 글

    solc 0.4.25 with Docker  (0) 2022.08.07
    Input Options  (0) 2022.07.24
    solc introduction  (0) 2022.07.16
Designed by Tistory.