Promise is pending , does not resolves and hangs after calling send() on a contract. It happens using ganache-cli or geth as local node.
I can get the transaction hash and also tried:
....send().on('transactionHash', (hash) => {
const tx = await web3.eth.getTransactionReceipt(); // <--- hangs here.
});
Calling await contract.methods.method().send(); should return a resolved or rejected Promise.
Calling await contract.methods.method().send(); hangs waiting for promise to resolve.
I'm sending a transaction to a contract that calls another (ERC20) contract transferFrom() methods.
Transaction: 0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8
Gas usage: 202210
Block Number: 44
Block Time: Tue Jun 18 2019 21:06:43 GMT-0300 (Argentina Standard Time)
eth_getTransactionReceipt
> {
> "jsonrpc": "2.0",
> "id": 204,
> "method": "eth_getTransactionReceipt",
> "params": [
> "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8"
> ]
> }
< {
< "id": 204,
< "jsonrpc": "2.0",
< "result": {
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "transactionIndex": "0x0",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "from": "0x95ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "to": "0xa94b7f0465e98609391c623d0560c5720a3f2d33",
< "gasUsed": "0x315e2",
< "cumulativeGasUsed": "0x315e2",
< "contractAddress": null,
< "logs": [
< {
< "logIndex": "0x0",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x000000000000000000000000000000000000000000000000001aa535d3d0c000",
< "topics": [
< "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "0x000000000000000000000000ffcf8fdee72ac11b5c542428b35eef5769c409f0"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x1",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000dc6117dd3934000",
< "topics": [
< "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x2",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x000000000000000000000000000000000000000000000000003e2c284391c000",
< "topics": [
< "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "0x000000000000000000000000e11ba2b4d45eaed5996cd0823791e0c93114882d"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x3",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000d87e55590018000",
< "topics": [
< "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x4",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000d87e55590018000",
< "topics": [
< "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x5",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000000000000000000",
< "topics": [
< "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x6",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000000000000000000",
< "topics": [
< "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33",
< "0x000000000000000000000000630589690929e9cdefdef0734717a9ef3ec7fcfe"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x7",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000d87e55590018000",
< "topics": [
< "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33",
< "0x000000000000000000000000630589690929e9cdefdef0734717a9ef3ec7fcfe"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x8",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000d87e55590018000",
< "topics": [
< "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33",
< "0x000000000000000000000000630589690929e9cdefdef0734717a9ef3ec7fcfe"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0x9",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa57b8a5584442b467b4689f1144d269d096a3daf",
< "data": "0x0000000000000000000000000000000000000000000000000000000000000000",
< "topics": [
< "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33",
< "0x000000000000000000000000630589690929e9cdefdef0734717a9ef3ec7fcfe"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0xa",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0x26b4afb60d6c903165150c6f0aa14f8016be4aec",
< "data": "0x0000000000000000000000000000000000000000000000000022a392c68f6000",
< "topics": [
< "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
< "0x000000000000000000000000630589690929e9cdefdef0734717a9ef3ec7fcfe",
< "0x000000000000000000000000a94b7f0465e98609391c623d0560c5720a3f2d33"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0xb",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa94b7f0465e98609391c623d0560c5720a3f2d33",
< "data": "0x000000000000000000000000a57b8a5584442b467b4689f1144d269d096a3daf00000000000000000000000026b4afb60d6c903165150c6f0aa14f8016be4aec",
< "topics": [
< "0x02c75aaeccbc9d026b1b2533c77a817a373175e4f0cd22bf7b2e32aa3f47a667",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0xc",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0x8265dd2885e3a9b5f49c2631bd24aef7c9824d1f",
< "data": "0x000000000000000000000000000000000000000000002b5aef3868dc24dfca22",
< "topics": [
< "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
< "0x0000000000000000000000000000000000000000000000000000000000000000",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc"
< ],
< "type": "mined"
< },
< {
< "logIndex": "0xd",
< "transactionIndex": "0x0",
< "transactionHash": "0x5c2cdd2a27dcf04200f95df5e5cf0f2775d45ca8598221d939b99d46d62b76c8",
< "blockHash": "0x6851474025edf87431404563bdcf6e61352227a4eef26e2feca07144539abfb0",
< "blockNumber": "0x2c",
< "address": "0xa94b7f0465e98609391c623d0560c5720a3f2d33",
< "data": "0x000000000000000000000000000000000000000000002b5aef3868dc24dfca220000000000000000000000000000000000000000000000000d87e55590018000",
< "topics": [
< "0x7614bfd0ad5ba76e8e3a1466849d7c7284ecbbd705f3b7835503c42c8e0196a1",
< "0x00000000000000000000000000000000000000000000000000000000000003e8",
< "0x0000000000000000000000000000000000000000000000000000000000000000",
< "0x00000000000000000000000095ced938f7991cd0dfcb48f0a06a40fa1af46ebc"
< ],
< "type": "mined"
< }
< ],
< "status": "0x1",
< "logsBloom": "0x00000000000020000000000020000000000000000000000000000000000002001800040000000000002000000000000000000000000000000000000000a000000000000000000400000000090000000000000000000000000000000000000000000000000200000000000000000008000000000000000000080010100000000000000002000000000000001000000300010000000000c0000000000800000002020000080000000002000002000000001200000000000000040000000000000000000002000000000400000000000000000000000040000080000000000020004010000002020000000000000000000020000000020000000000000000000000",
< "v": "0x1b",
< "r": "0x7101488633873b0654c98d11da4f36061c97ddb6a66276e389e9e1b00803540b",
< "s": "0x4ac1e27e6a4a7dc473dc024beae023eca5e4dbd3c76cc0577b7f869855021de4"
< }
< }
Thanks for opening this issue! Could you provide a GitHub repository to reproduce your issue?
Thanks for opening this issue! Could you provide a GitHub repository to reproduce your issue?
Hi @nivida . Yes. You can try this: https://github.com/tradestars-app/tradestars-cards
I think I have a similar issue. You may want to have a look at
https://github.com/dappuniversity/eth-todo-list-react/issues/1
It's within a small project which should be easy to run and test.
I had the same issue. I hope my solution can solve yours. Here is the link
Transaction was mined, but took 5 minutes to get the result
Cheers!
If the transaction receipt isn't existing directly after the call does web3 start a newHeads subscription or it does polling for the receipt. The subscription gets started on the usage of a WebsocketProvider or IpcProvider and polling is in usage for the HttpProvider. How long it should wait and what the maximum of confirmations is can get configured as described here.
Totally get it @nivida. Still doesn't work by setting transactionConfirmationBlocks = 1.
I've solved similar to @jonassunandar .
const txHash = await new Promise((resolve, reject) => {
contract.methods.method().send()
.on('transactionHash', (x) => { resolve(x); })
.catch((err) => { reject(err); })
});
await web3.eth.getTransactionReceipt(txHash);
Most helpful comment
I had the same issue. I hope my solution can solve yours. Here is the link
Transaction was mined, but took 5 minutes to get the result
Cheers!