solrun

0.0.7 • Public • Published

solrun

toolstack for blockchain projects

  • solrun Run Solidity Contract
  • solabi Parse ABI from Solana program's code

Install

npm install solrun -g

solrun

  • default solc complier version is 0.6.12

Usage

solrun test.sol

test.sol

contract Coin {
    address public owner;
    mapping(address => uint) public balances;

    constructor(address miner) {
        owner = miner;
    }

    function mint(uint amount) external {
        balances[owner] += amount;
    }

    function balanceOf(address who) external view returns (uint) {
        return balances[who];
    }
}


contract Test {

    event Log(string);
    event Log(uint);

    string public state;
    Coin coin;
    address public coinerOwner;

    constructor() {
        state = "constructor";
        coinerOwner = address(0);
        coin = new Coin(coinerOwner);
    }

    // solrun will auto call this main function 
    function main() external {
        emit Log(state);
        if (2 > 1) emit Log("failed");
        emit Log("hello world");
        setState("set newSate");

        coin.mint(1000);
        uint balance = coin.balanceOf(coinerOwner);

        emit Log(balance);

        string memory curSate = getState();
        emit Log(
            string(
                abi.encodePacked("state:", curSate)
            )
        );
    }

    function setState(string memory newState) public {
        state = newState;
    }

    function getState() public view returns (string memory) {
        return state;
    }
}

Output

Log(constructor)
Log(failed)
Log(hello world)
Log(1000)
Log(state:set newSate)

Roadamp

  • [x] Run contract
  • [x] Support display require message
  • [ ] Support import
  • [ ] Call specify Contract and method
  • [ ] Multiple method call
  • [ ] Switch solc compiler vesion

Package Sidebar

Install

npm i solrun

Weekly Downloads

2

Version

0.0.7

License

ISC

Unpacked Size

33.7 MB

Total Files

20

Last publish

Collaborators

  • lljxx1