Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tronweb is not getting default address or not opening for new address connection #570

Open
thinkguru opened this issue Nov 5, 2024 · 1 comment

Comments

@thinkguru
Copy link

thinkguru commented Nov 5, 2024

window.tronWeb.defaultAddress.base58 is giving false, and for new address tronlink extention is not opening to initiate a new connection and get default address data.
i am using tronweb 6.0 from cdn for javascript in php project.

// code function
let checkWalletInterval = setInterval(async () => {
if (window.tronWeb && window.tronWeb.defaultAddress.base58) {
tronWeb = window.tronWeb;

                console.log("TronWeb is connected:", tronWeb.defaultAddress.base58);

                // Set the wallet address to display on the UI
                document.getElementById("txtwalletaddress").value = tronWeb.defaultAddress.base58;
                clearInterval(checkWalletInterval);
            } else {
                console.log("Waiting for TronLink to be connected...");
            }
        }, 1000); 
@Satan-web3
Copy link
Contributor

You have to connect to tronlink extension before you can get the address. I recommend you to use TronWallet Adapter. That is convenient to connect with less code. If you don't want to use it, please use code below to connect:

const res = await window.tron.request({ method: 'eth_requestAccounts' });
const address = res[0];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants