Following the tutorial here, I know how to use oo7-parity to deploy a new contract. https://github.com/paritytech/parity/wiki/Tutorial-Part-9

deploy () {
    let tx = bonds.deployContract(CounterCode, CounterABI);

The example contract Counter has no contract constructor, so it can be deployed with only contract byte code and ABI.

However, suppose a contract has a constructor function and initialization variables like the following one, how should I put the variable (_greeting) in the bonds.deployContract function?

contract greeter{
    string greeting;
    function greeter(string _greeting) public {
        greeting = _greeting;

2 Answers 2


The docs state:

You'll need to either get your own byte code from the compiler

So you can either user browser solidity or the javascript compiler.

  • Indeed, the byte code can be generated through the compiler. But the initialization variables still needs to be specified after that, even on browser solidity. photo Commented Sep 7, 2017 at 3:01

so here's how I do it. You'll need web3js 0.20.0, use it's getData function to generate the new byte code which contains encoded initialization variables.

const web3 = new Web3()
let MyContract = web3.eth.contract(MyABI)
let _greeting = "my init variable"
let newByteCode = MyContract.new.getData(_greeting, {data: oldByteCode})
let tx = bonds.deployContract(newByteCode, MyABI)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.