Conflux-Chain / ConfluxWeb

Conflux JavaScript API, under active development
GNU Lesser General Public License v3.0
7 stars 5 forks source link

Error: Account 0x123261f955d54fb8 epoch_number=LatestState does not exist #7

Closed saarshah closed 4 years ago

saarshah commented 4 years ago

I have run your example code, this code can deploy contract successfully. But when program reached at line where we are calling cfx.getCode, it gives us following error.

here is your code, which i am using

  const contractAddress = await contract.constructor(10)
    .sendTransaction({
      from: account,
      gas: estimateDeployGas, // if not set gas, will use 'cfx.defaultGas'
    })
    .deployed();
  console.log("Contract Address: ", contractAddress); // 0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404

  contract.address = contractAddress;

  const getCode = await cfx.getCode(contract.address);
  console.log(getCode); // same as 'code'

here is output with error

Contract Address:  0x123261f955d54fb83655f8beb008733dbd6c3e1a
{ data:
   { jsonrpc: '2.0',
     id: '15746515897556105262',
     method: 'cfx_getCode',
     params:
      [ '0x123261f955d54fb83655f8beb008733dbd6c3e1a', 'latest_state' ] },
  error:
   { code: -32602,
     message:
      'Account 0x123261f955d54fb83655f8beb008733dbd6c3e1a epoch_number=LatestState does not exist' },
  duration: 1095 }
{ Error: Account 0x123261f955d54fb83655f8beb008733dbd6c3e1a epoch_number=LatestState does not exist
    at HttpProvider.call (C:\Users\amirali\Desktop\temp\node_modules\conflux-web\lib\provider\http.js:44:13)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: -32602 }

you can see the contract 0x123261f955d54fb83655f8beb008733dbd6c3e1a is created, but when this is given to cfx.getCode , it gives error. However, if i give directly the above address of contract like this cfx.getCode('0x123261f955d54fb83655f8beb008733dbd6c3e1a'), it works perfectly..

GeekBerry commented 4 years ago

We get some problems in full node caused user can not get a contract code after deploy immediately. You need to wait a few seconds to get code after contract deployed in current test net. Thank you for your feedback, we are trying to fix it.

saarshah commented 4 years ago

@GeekBerry thanks ... if you have time, please answer my query posted in issue # 5. I shall be very thankful

GeekBerry commented 4 years ago

We think in most case, user will not getCode immediately after successful deploy a contract. So we will not support this situation recently. Thank you for your issues again and I will remove this code from example file after close this issues soon.

saarshah commented 4 years ago

I think this issues should be remained opened and labeled as "Enhancement", only if your team has plan to resolve/provide it in future.