pragma solidity ^0.5.0;

contract HelloWorld {

uint256 counter = 100;

function add() public { counter++; }

function subtract() public { counter--; } }

I used solcjs to compile a contract and get the binary of the contract in hex:

solcjs --bin mycontract.sol

then I put the hex value in the


function as the code parameter of runtime.Execute(). Then I run


But it return an array of number: enter image description here

So I think that's how to run smart contract using geth source code but what if I want to run some specific function of the contract ? And how can I get the state(or the return of contract) of the contract ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.