im facing a problem deploying a simple smart contract.

When i use ganacha-cli, the program enter in a loop of confimation event, counting from 1. Thats the first problem.


Account: 0xd5f75a4F58da4dF050F84dedF07d24f7bf388F8F
trans hash: 0x1ab65a58debce4859a7df358ba54653fe0727b25f9d483622ab412ea7c49a56d
receipt: [object Object]
Contract address: 0xd2039ADAE2a61fADd65C4bec6a7791b2B6e56d08
confirmation: 1
confirmation: 2
confirmation: 3
confirmation: 4
confirmation: 5

And when i use a blockchain runing with geth in a server, the send method never is resolved. Only transaction hash is fired, and the contract is created in the blockchain. The second and main problem.


Account: 0xb5cF1ee3481B45d1A1cB939921f3f6E3f0C97f80
trans hash: 0x387a881262fbfee430bf761724bb5e21706fc2c76bb86dfd69aff526c46b985f

Code (web3 version 1.2):

var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.HttpProvider('http://XXX.XXX.XXX.XXX:PPPP'));

var account = '0xb5cF1ee3481B45d1A1cB939921f3f6E3f0C97f80'

console.log('Account: ' + account);

web3.eth.personal.unlockAccount(account, "dos", 50000)

const deployedContract = new web3.eth.Contract([{"constant":true,"inputs":[],"name":"displayMessage","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"displayMessagex","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]);

    data: '0x6060604052341561000f57600080fd5b6101ad8061001e6000396000f30060606040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632d59dc128114610050578063910dc524146100da575b600080fd5b341561005b57600080fd5b6100636100ed565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561009f578082015183820152602001610087565b50505050905090810190601f1680156100cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156100e557600080fd5b61006361012e565b6100f561016f565b60408051908101604052601281527f5768616c652068656c6c6f2074686572652100000000000000000000000000006020820152905090565b61013661016f565b60408051908101604052601781527f5768616c652068656c6c6f2074686572655858585858210000000000000000006020820152905090565b602060405190810160405260008152905600a165627a7a723058208eeb846120df236de217b296df57febcc6f992caf709d5cb6d4637c86b9427a40029'
    from: account,
    gas: 10000000
.once('confirmation', function(confirmationNumber, receipt){
    console.log('confirmation: ' + confirmationNumber)
.on('transactionHash', function(hash){
    console.log('trans hash: ' + hash)
.on('error', function(error){
    console.log('error: ' + error)
.on('receipt', function(receipt){
    console.log('receipt: ' + receipt.toString())
.then(function(contract) {
    console.log('Contract address: ' + contract.options.address);
.catch(function(error) {

Geth command:

geth --port 3000 --networkid 87936 --nodiscover --datadir=. --maxpeers=0  --rpc --rpcport 8543 --rpcaddr --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock


After start mining the main problem convert in the first problem (is an advance), changed the on('confirmation') to once('confirmation') the output now is:

Account: 0xb5cF1ee3481B45d1A1cB939921f3f6E3f0C97f80
trans hash: 0xc5a2dc489815c205a53658bf5ebcde95593e83da4ead07355fcae4d722636c12
confirmation: 0
receipt: [object Object]
Contract address: 0x6b4A76Ab26e487Fdc502779Abc438d0cF59299bc
  • you run geth on your private chain or ethereum mainnet?
    – Ha ĐANG
    Jul 25, 2019 at 11:54
  • On private chain.
    – Gabriel
    Jul 25, 2019 at 14:06
  • 1
    Make sure that your chain is mining?
    – Ha ĐANG
    Jul 25, 2019 at 14:17
  • lol i forgot to start mining. But now, never end the call.
    – Gabriel
    Jul 25, 2019 at 14:34
  • What do you mean about the never end?
    – Ha ĐANG
    Jul 25, 2019 at 15:51

1 Answer 1


The .on method attaches an event handler to the deploy function, which listens to all the confirmation events fired when a new block is created after your deployment transaction gets mined.

Change .on to .once will let the code proceed.

  • Thanks, thats solve the problem with ganacha, but not the main problem
    – Gabriel
    Jul 25, 2019 at 14:34
  • Let me get it clear. Your "main problem" is that the send method is not resolved. However, you mentioned that there's a new contract instance deployed, which means that send is effective. Did I understand correctly? Jul 26, 2019 at 16:37
  • This didn't work for me Sep 6, 2021 at 8:31

Your Answer

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

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