Connect to binance smart chain fails

hey there,

I wanna connect to metamask binance chain but it doesnt work. It reutrns undefinied on bsc.

            let web3Js = new Web3(new Web3(https://bsc-dataseed1.binance.org:443));
            let walletAddress = (await web3Js.eth.getAccounts())[0];

Why is it doing this. I thought I would just have to change the rpc and all would work like on ethereum

you have to set it as a string probably, it should work with the right syntax

nah i just typed it here. Ofc it is a string xd

that is only a web3 instance that first line tries to do, there is not account associated with that web3 instance for the second line to work

i mean with ethereum it works. Its just a partial

what was the syntax that was working with ethereum?

on ethereum it returns the address. When I try to interact with a bsc contract it says no account .
ERC20 catch error: Error: Returned error: unknown account So maybe it was because of the error i mentioned above

with ethereum everything works perfectly

maybe it is something different with eth, I would not expect for that code to work with eth either, I don’t see anything relating to setting an account in that code

Can you post more of your code (not typed). Your syntax is a bit unusual with using two new Web3. E.g. from web3.js docs:

let web3Js = new Web3("https://bsc-dataseed1.binance.org");

What do you get when you console.log await web3Js.eth.getAccounts() on Ethereum?

Also make sure your wallet is connected to Binance Smart Chain.