when I query my accounts on my local test rpc, I get this:

> web3.eth.accounts[0]


All good, but when I try to create an instance of a contract I created, I get this:

> deployedContract = VotingContract.new(['Larry','Curly','Moe'], { data: contract.bytecode, from: web3.eth.accounts[0], gas: 4700000})

Error: invalid argument 0: missing 0x prefix for hex data
    at Object.InvalidResponse (C:\Users\dude\AppData\Roaming\npm\node_modules\web3\lib\web3\errors.js:38:16)
    at RequestManager.send (C:\Users\dude\AppData\Roaming\npm\node_modules\web3\lib\web3\requestmanager.js:61:22)
    at Eth.send [as sendTransaction] (C:\Users\dude\AppData\Roaming\npm\node_modules\web3\lib\web3\method.js:145:58)
    at ContractFactory.new (C:\Users\dude\AppData\Roaming\npm\node_modules\web3\lib\web3\contract.js:228:33)
    at repl:1:38
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:313:29)
    at bound (domain.js:280:14)

What is the correct format for the address in this case?

1 Answer 1


The problem wasn't with the address, it was with the bytecode. I just needed to prefix the bytecode with '0x', i.e.:

> deployedContract = VotingContract.new(['Larry','Curly','Moe'], { data: '0x'.concat(contract.bytecode), from: web3.eth.accounts[0], gas: 4700000})

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.