1

I have deployed a contract as follows and determined its balance to be 5000 wei (value: 5000):

const thisContract = new web3.eth.Contract(abi);
thisContract.deploy({  
    data: bytecode,
    arguments: [ "0x84f0c8fC2F6bc8394EB77BaAAe89cB6e12C048C2", 86400]
}).send({
    from: "0x3455D7167A2EE2d660EE85F8e90C6b3B1cCB7163",
    gas: 5000000 ,
    gasPrice: '3000000000',
    value: 5000 // here I have determined the balance.
}, function(error, transactionHash) {
    console.log(error);
    console.log(transactionHash);
    console.log('function exec');
}).then(function(newContractInstance) {
    console.log('Contract Instance:' + newContractInstance.options.address);
});

I have deployed this contract on Tobalaba blockchain (its github is here.)

The balance of the address by which I developed this contract is 20000000000000000000 wei as follows :

> web3.eth.getBalance('0x3455D7167A2EE2d660EE85F8e90C6b3B1cCB7163').then(console.log)
Promise {
  <pending>,
  domain: 
   Domain {
     domain: null,
     _events: 
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
> 20000000000000000000

However, when I get the balance of the contract, it's 0 as follows:

> web3.eth.getBalance('0xd227398f81bad20882b46ccdffc71058025df341').then(console.log)
Promise {
  <pending>,
  domain: 
   Domain {
     domain: null,
     _events: 
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
> 0

And here is the information of deployment of this contract:

https://tobalaba.etherscan.com/address/0xd227398f81bad20882b46ccdffc71058025df341

Acoording to which the contract address is 0xD227398f81bAD20882B46ccdFfC71058025df341

Is something wrong?

IMPORTANT NOTE: I have developed this contract: https://programtheblockchain.com/posts/2018/02/23/writing-a-simple-payment-channel/

Meanwhile, when I get the contract address it returns null!

> thisContract.options.address
null

Whereas, regarding to this information (https://tobalaba.etherscan.com/tx/0xb9834bd2ebbbb930208dbb17462169441c6b63542a01a43e3992ecf803cb0734) it have to be deployed, isn't it ? (Please see the screen shot bellow)

enter image description here

  • 1
    What node are you connected to? Are you sure it's up-to-date? – user19510 Jul 11 '18 at 17:52
  • 1
    As to why thisContract.options.address is null, it's because you never assigned an address. You could use thisContract.options.address = newContractInstance.options.address in that callback if you want. – user19510 Jul 11 '18 at 18:00
  • @smarx Thank you, I am using this node : enode://63c8ce2905100932230c1760fb29d36d08646979d1fd7abfa8393f5e7feaade3c9a078fd85b194ca040c8a0b2c541537f96deb76a7412c87e36cec16fe543e9f@192.168.136.128:30303 – Questioner Jul 11 '18 at 20:14
  • 1
    So you're using a local Parity node? Check its block number and compare to the one on Etherscan to make sure your node is up-to-date. – user19510 Jul 11 '18 at 20:32
  • @smarx Thank you, Yes I just got its balance again and fortunately it's now 5000 wei here: tobalaba.etherscan.com/address/… It was apparently because of synchronization. Thanks – Questioner Jul 11 '18 at 20:40
0

balance = await web3.eth.getBalance(contract_address);

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.