Developers Forum for XinFin XDC Network

Phill Menezes
Phill Menezes

Posted on

Unwanted behavior while using standard XDCPay RPC endpoints and web3 library

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: '',
  51: ''
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode


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: '',
  51: ''
Enter fullscreen mode Exit fullscreen mode

XDCPay Config

Fortunately, using these endpoints is enough to avoid the compatibility error with the web3 library.


My suggestion would be to make Ethereum Compatible endpoints a native feature on XDCPay:

XDCPay Config 2

This issue is also being tracked on Github
@blocksscanio @blocksscan @walterblueu

Discussion (3)

menezesphill profile image
Phill Menezes Author

To reproduce the error, you can run my example staking dapp locally:

git clone
cd ./xdc-staking-dapp/front-end
Enter fullscreen mode Exit fullscreen mode

Install dependencies:

npm install
Enter fullscreen mode Exit fullscreen mode

and run the app:

npm run dev
Enter fullscreen mode Exit fullscreen mode

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).

blocksscanio profile image

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.

mogithehurt profile image

Great job @menezesphill
And i added new rpc and it works fine.