I am trying to initiate provider from the window.BinanceChain object injected by Binance Wallet chrome extension as I did it with the MetaMask extension before:

let provider = new ethers.providers.Web3Provider(window.ethereum);

But I have noticed that on page load I have initiated window.ethereum object, but undefined window.BinanceChain object:


The result is:

enter image description here

What is the proper way to initiate Binance Smart Chain provider on page load?

  • Did you manage to solve this?
    – Majd TL
    Mar 19, 2021 at 12:53

1 Answer 1


I had the same issue and I noted that window.BinanceChain object is not available as early as window.ethereum, so you need to wait for it. My solution was to add an additional state check:

   document.onreadystatechange = () => {
     if (document.readyState == "complete") {
       window.web3 = new Web3(window.BinanceChain);
       // do stuff

Tip: you can check if the object is available after the page is loaded by typing console.log(window.BinanceChain); inside the browser's developer tools in the console to see if it gets initialized at some point at all?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.