Summary: While using XDCPay standard RPC endpoints to connect to decentralized apps using the web3 npm package, dApps are unable to check for transactions receipt due to incompatibility with the Ethereum Standard RPC.
Reproducing the error
It is possible to use XDCPay injected provider to create a web3modal
that can be used for ReactJS/Next.js dapps using web3 npm package. This would be the natural pathway to interact with decentralized apps in EVM-based networks, this is the case for XDC Network too.
By using XDCPay HttpProvider, however, we are using the XDC compatible endpoints:
50: 'https://xdcpayrpc.blocksscan.io/',
51: 'https://apothemxdcpayrpc.blocksscan.io/'
Which, at first glance, is not a problem since it does not prevent us from accessing web3 methods. We can still send and fetch blockchain data using a Web3 object created using XDCPay injected provider.
However, the problem is when we expect a transaction receipt to update our front-end information or compute transaction outcomes. We get the following message error:
Uncaught (in promise) Error: Failed to check for transaction receipt:
{}
at Object._fireError (web3.min.js?2efa:9:16886)
at eval (web3.min.js?2efa:10:25360)
Fix
To check if this behavior only occurred with RPC endpoints that are not fully compatible with the Ethereum standard, I have configured XDCPay to use the Ethereum-compatible alternative RPCs:
50: 'https://erpc.xinfin.network/',
51: 'https://erpc.apothem.network/'
Fortunately, using these endpoints is enough to avoid the compatibility error with the web3 library.
Sugestion
My suggestion would be to make Ethereum Compatible endpoints a native feature on XDCPay:
This issue is also being tracked on Github
@blocksscanio @blocksscan @walterblueu
Discussion (3)
To reproduce the error, you can run my example staking dapp locally:
Install dependencies:
and run the app:
I added a
faucet
button so you can get test tokens and try the dapp for youself, you will get the error whenever you try to Deposit and/or withdraw tokens from the staking card. And only when using standard XDC endpoints (works fine with erpc endpoints).We have test eth.getTransactionReceipt function on both RPC for mainnet and Testnet and it works, Can you share txhash / step to reproduce at our end?
Here is attached images for ref.
xdc.dev/uploads/articles/je51hpuan...
xdc.dev/uploads/articles/2x1dqefbv...
Great job @menezesphill
And i added new rpc and it works fine.