Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't transfer tokens #2764

Closed
vanzay opened this issue May 1, 2019 · 19 comments
Closed

Can't transfer tokens #2764

vanzay opened this issue May 1, 2019 · 19 comments

Comments

@vanzay
Copy link

vanzay commented May 1, 2019

Description

I'm trying to transfer tokens like this

const Web3 = require('web3');
const abi = require('human-standard-token-abi');

async function testSend() {
  let url = 'http://127.0.0.1:8545';
  let contractAddress = '0x6031ab93c5e436dfc6f4db819bf50f67e7b1289d';
  let from = '0x76b4514ceb23475be392e1305877a834401bdde8';
  let secret = 'secret';
  let to = '0xe63fb07be1bbc1d84c7e41554faf5457a1c4327e';
  let amount = 5 * 10 ** 18;
  let gas = 100000;

  let web3 = new Web3(new Web3.providers.HttpProvider(url));
  let contract = new web3.eth.Contract(abi, contractAddress);
  let gasPrice = await web3.eth.getGasPrice();
  await web3.eth.personal.unlockAccount(from, secret, null);
  let tx = await contract.methods.transfer(to, `${amount}`).send({from, gas, gasPrice});
  console.log(tx);
}

and I'm receiving an error "Invalid params: invalid type: null, expected a block number or 'latest', 'earliest' or 'pending'."

RPC calls traces

  1. eth_gasPrice
{ jsonrpc: '2.0', id: 0, method: 'eth_gasPrice', params: [] }
{ jsonrpc: '2.0', result: '0x3b9aca00', id: 0 }
  1. personal_unlockAccount
{ jsonrpc: '2.0',
  id: 1,
  method: 'personal_unlockAccount',
  params:
   [ '0x76b4514ceb23475be392e1305877a834401bdde8',
     '734873kjn873',
     null ] }
{ jsonrpc: '2.0', result: true, id: 1 }
  1. eth_sendTransaction
{ jsonrpc: '2.0',
  id: 2,
  method: 'eth_sendTransaction',
  params:
   [ { from: '0x76b4514ceb23475be392e1305877a834401bdde8',
       gas: '0x186a0',
       gasPrice: '0x3b9aca00',
       data:
        '0xa9059cbb000000000000000000000000e63fb07be1bbc1d84c7e41554faf5457a1c4327e0000000000000000000000000000000000000000000000004563918244f40000',
       to: '0x6031ab93c5e436dfc6f4db819bf50f67e7b1289d' } ] }
{ jsonrpc: '2.0',
  result:
   '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545',
  id: 2 }
  1. eth_getTransactionReceipt
{ jsonrpc: '2.0',
  id: 3,                                                                                                                                                                                                      15:40
  method: 'eth_getTransactionReceipt',
  params:
   [ '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545' ] }
{ jsonrpc: '2.0',
  result:
   { blockHash: null,
     blockNumber: null,
     contractAddress: null,
     cumulativeGasUsed: '0x96b9',
     from: null,
     gasUsed: '0x96b9',
     logs: [ [Object] ],
     logsBloom:
      '0x0000000000100000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000800000000000000000000000000000000010000000000000000
0000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000002000000000000000000100000000000000000000000000000000000000000010000000000000000000000000000002000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000002',
     root: null,
     status: '0x1',
     to: null,
     transactionHash:
      '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545',
     transactionIndex: '0x0' },
  id: 3 }
  1. eth_getBlockByNumber
{ jsonrpc: '2.0',
  id: 4,
  method: 'eth_getBlockByNumber',
  params: [ null, false ] }
{ jsonrpc: '2.0',
  error:
   { code: -32602,
     message:
      'Invalid params: invalid type: null, expected a block number or \'latest\', \'earliest\' or \'pending\'.' },
  id: 4 }

Versions

  • web3.js: 1.0.0-beta.53
  • nodejs: v10.12.0
  • parity: 2.4.5 (ropsten network)
@nivida
Copy link
Contributor

nivida commented May 1, 2019

Thanks for opening this issue! As it looks like is partiy not returning a block number in the transaction receipt:

{ jsonrpc: '2.0',
  result:
   { blockHash: null,
     blockNumber: null,
     contractAddress: null,
     cumulativeGasUsed: '0x96b9',
     from: null,
     gasUsed: '0x96b9',
     logs: [ [Object] ],
     logsBloom:
      '0x0000000000100000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000800000000000000000000000000000000010000000000000000
0000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000002000000000000000000100000000000000000000000000000000000000000010000000000000000000000000000002000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000002',
     root: null,
     status: '0x1',
     to: null,
     transactionHash:
      '0xd1e0cf24bb077418b1836470b2d225c37568b373490b1b2087987c2ec8c06545',
     transactionIndex: '0x0' },
  id: 3 }

Could you open an issue in the parity repository?

@vanzay
Copy link
Author

vanzay commented May 1, 2019

Opened openethereum/parity-ethereum#10623
Thanks

@vanzay
Copy link
Author

vanzay commented May 1, 2019

BTW with 1.0.0-beta.36 the source piece of code works well.

@nivida
Copy link
Contributor

nivida commented May 1, 2019

Yes, because there isn't a check if a new block got mined if you use the HttpProvider. The fix in the latest version would be to use the WebsocketProvider.

Edit: TransactionObserver

@vanzay
Copy link
Author

vanzay commented May 1, 2019

Will the issue be fixed for the HttpProvider?

@vanzay
Copy link
Author

vanzay commented May 2, 2019

I've changed the source code with the WebsocketProvider. Now it hangs on the line:

let tx = await contract.methods.transfer(to, `${amount}`).send({from, gas, gasPrice});

@nivida
Copy link
Contributor

nivida commented May 2, 2019

@vanzay The HttpProvider issue got already fixed and will be released today.
Did you configure the transaction confirmation workflow as documented in the documentation?

Btw.: Could you ask further question in our gitter channel, on StackOverflow or the community-driven discord server?

@vanzay
Copy link
Author

vanzay commented May 3, 2019

In 1.0.0-beta.54 the HttpProvider still doesn't work.

@nivida
Copy link
Contributor

nivida commented May 3, 2019

Could you add a GitHub repository or all required code snippets to reproduce it?

@vanzay
Copy link
Author

vanzay commented May 3, 2019

@nivida
Copy link
Contributor

nivida commented May 3, 2019

Did you also test it with a configured transaction confirmation workflow as described in the documentation?

@vanzay
Copy link
Author

vanzay commented May 3, 2019

Also tried this way:

  let web3 = new Web3(new Web3.providers.HttpProvider(url), null, {
    transactionBlockTimeout: 50,
    transactionConfirmationBlocks: 24,
    transactionPollingTimeout: 480
  });

the same result.

@nivida
Copy link
Contributor

nivida commented May 3, 2019

You have to wait for 24 blocks and then the transaction will resolve.

@nivida nivida closed this as completed May 3, 2019
@vanzay
Copy link
Author

vanzay commented May 3, 2019

But why do I receive an exception? How to avoid it?

@vanzay
Copy link
Author

vanzay commented May 6, 2019

@nivida Why has the issue been closed? It's not resolved yet (see the comment above).

@kael-shipman
Copy link

I agree, I'm still getting this issue. The issue shouldn't be closed until there's a satisfactory resolution for it. Please re-open.

@imbenwolf
Copy link

imbenwolf commented Jun 24, 2019

I am currently not happy:

and now, when i finally figured all that out:

  • apparently, to transfer tokens, beta.36 needs to be used?? otherwise there is no clean way to support parity or am i wrong?

what is going on @nivida?

@nivida
Copy link
Contributor

nivida commented Jun 25, 2019

Could you reference a GitHub repository? @imbenwolf

@imbenwolf
Copy link

hi @nivida please see referenced issues in my comment. here a short summary:

  • httpprovider returns "Uncaught TypeError: Cannot read property 'node' of undefined." when under beta.51 as per your comment
  • ganache-cli does not support eth_chainid rpc endpoint thus not working with web3 (bad!). It is unfortunate that the truffle team does not fix such issues quickly but why not calculate for a fallback? this way nobody can use ganache-cli to develop with web3!
  • after some experimenting, i realized that what you were suggesting "You have to wait for 24 blocks and then the transaction will resolve." can be achieved with setting "web3.transactionConfirmationBlocks = 24" in the future i would suggest constructively not closing an issue without also providing a working resolution as it will make it very hard for developers to keep up with all these issues while working for a company. I do appreciate the work & help you are giving though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants