I have used geth to setup a local private blockchain. I have been able to setup two accounts and send ether from one to the other and mine the transactions. Now I am trying to deploy a smart contract. I followed this steps:

Used solcjs to generate the .abi and .bin files

Start the miner

Unlocked the account used to deploy the contract

Saved in the geth console the bin and abi with:

var contract = web3.eth.contract(<CONTENTS_OF_ABI_FILE>)
var bytecode = '0x<CONTENTS_OF_BIN_FILE>'

Deploy the smart contract with:

var deploy = {from:eth.accounts[0], data:bytecode, gas: 2000000}
var instance = contract.new(param1,param2,param3, deploy)

Then geth returns undefined and if I execute `instance.address' I still get undefined.

Why is my contract not getting mined?

  • Are running your tests from the geth console? Did the transaction fail or it just ignored (ie it remains in pendings)? I'd try first with a simple contract to discard issues with the gas limit.
    – Ismael
    Commented Mar 23, 2018 at 4:04

1 Answer 1


new will not return the address immediately. What you'll have immediatelly is transaction hash. From there on, you'll have to wait for the transaction to be mined.

From https://github.com/ethereum/wiki/wiki/JavaScript-API :

// Deploy contract syncronous: The address will be added as soon as the contract is mined.
// Additionally you can watch the transaction by using the "transactionHash" property
var myContractInstance = MyContract.new(param1, param2, {data: myContractCode, gas: 300000, from: mySenderAddress});
myContractInstance.transactionHash // The hash of the transaction, which created the contract
myContractInstance.address // undefined at start, but will be auto-filled later

I would suggest to use a framework like truffle. In truffle a transaction will be a promise and you can await the completion.

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.