Closed RoeiBenZeev closed 1 week ago
I don't quite understand. The tx.wait()
returns a TransactionReceipt, and if the transaction failed (mined, but with a status of 0) throws an error.
It should never return an Array. What would you expect the Array to be of?
not an array
is the error being thrown by ethers.js
I'm getting the same error (also on BSC), here's the full stack
Error: not an array
at Object.logs (/usr/src/app/node_modules/@ethersproject/providers/lib/formatter.js:408:23)
at Function.Formatter.check (/usr/src/app/node_modules/@ethersproject/providers/lib/formatter.js:373:40)
at Formatter.receipt (/usr/src/app/node_modules/@ethersproject/providers/lib/formatter.js:325:32)
at JsonRpcProvider.<anonymous> (/usr/src/app/node_modules/@ethersproject/providers/lib/base-provider.js:1707:70)
at step (/usr/src/app/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
at Object.next (/usr/src/app/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
at fulfilled (/usr/src/app/node_modules/@ethersproject/providers/lib/base-provider.js:20:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
what is happening is that the RPC node returns an empty body (null
) if the transaction receipt is not available
We are not using wait()
so our temporary fix / hack will be different (you can always replace wait by calling getTransactionReceipt until you get an answer)
export async function getTransactionReceipt(hash: string): Promise<TransactionReceipt | null> {
try {
return await bscProvider()
.getTransactionReceipt(hash)
} catch (err) {
// When the transaction is not present, the RPC returns an empty body
if (err.code === 'SERVER_ERROR' && err.body === null) {
return null
}
throw err
}
}
Closing older issues. But if this is still happening in v6, please re-open or start a new issue.
Thanks! :)
const buyAction = async (tokenToBuyWith, tokenToPurchase) => { console.log("In buy action") try { const amountIn = data.BNBAmount; const amount = await router.getAmountOut(amountIn, tokenToBuyWith, tokenToPurchase, { 'gasLimit': data.gasLimit, 'gasPrice': data.gasPrice }); const amountOutMin = (amount.mul(100 -
${data.Slippage}
).div(100));}
this is the code im running to swap BNB to WBNB on bsc.
my code fail on tx.wait() and throwing and Error: not an array
im hard to find what is wrong with the code / the parameters im sending.