Please excuse if the title is not perfectly accurate but I had a hard time fitting my problem into 1 question. If you have a better title please feel free to suggest it and i will edit it.

I want to "deploy" a smart contract in the genesis file of my blockchain so that the contract is available when creating the chain.

Problem: The smart contract requires a constructor argument that I have to include in the bytecode. When I compile the smart contract in Remix with the arguments set, it works perfectly fine.

Unfortunately, I'm working on a Ubuntu VM so using Remix to compile the contract is not an option.

Any suggestions?

1 Answer 1


You can do it programmatically via web3.js (tested with v1.2.1):

const Web3 = require("web3");

const web3 = new Web3();
const contract = new web3.eth.Contract(YourAbiArray);
const options = {data: YourByteCode, arguments: [YourArgs]};
const transaction = contract.deploy(options);

Note that YourByteCode should start with 0x.

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.