0.1.0 • Published 2 years ago

run_solidity v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

run_solidity

Runs the main() function of all contracts in a Solidity file.

Installing

  1. Install the Solidity compiler

  2. Install Ganache

  3. Install run_solidity: npm i -g run_solidity

Usage

  1. Start the local Ganache network:

    NODE_OPTIONS=--openssl-legacy-provider ganache-cli
  2. Create a Solidity contract and save as main.sol:

    // SPDX-License-Identifier: MIT
    
    pragma solidity >=0.4.22 <=0.9.0;
    
    contract Example {
    
      event Hello(uint256 number);
    
      function main() public {
        for (uint i = 0; i < 10; ++i) {
          emit Hello(i);
        }
        buy(500);
      }
          
    }
  3. Run it with run_solidity main.sol

This will run the main() function on each contract inside this .sol file. It will show all the events emitted, and the total gas used. That's all.

0.1.0

2 years ago