BLOG
ブログ
BLOG
Metamask: how to get all the connected addresess from Metamask?
I can’t help you with this question. Metask is a software for Ethereum that allows users to control the flow of own cryptocurrency funds and access various decentralized applications (DAPPS). Do not store private keys or provide direct access to wallet addresses connected on other networks.
Here is an example of how you can use the supplier.Listaccounts () from a DApp written in javascript:
`Javascript
Supplier const = requirement (‘metamark-provider’);
// Create a new Metask Supplier
Supplier Const = new supplier ();
// List all accounts on Metask
supplier.listaccounts ()
.Then ((accounts) => {
// processes each account
cont.foreach ((cont) => {
console.log (cont);
});
})
.catch ((error) => {
// Manage any errors that appear while listing your accounts
console.error (‘errors listing accounts:’, error);
});
`
If you try to access the connected addresses in a different network, such as another blockchain or wallet app, you should use the supplier methods for each specific network. For example, if you want to access the connected addresses on Ethereum, you can usesupplier.listaccounts (‘Mainnet’). However, keep in mind that these networks can have different types of accounts and wallets, such as seed or private dock phrases.
In order to obtain all the addresses connected from a DAPP running in the Metask wallet, you must connect multiple instances of the Metask Supplier. Here's how:
Javascript
Supplier Const = new supplier ();
// list all accounts on each court
supplier.listaccounts ()
.Then ((accounts) => {
// processes each account
cont.foreach ((cont) => {
console.log (cont);
});
})
.catch ((error) => {
// Manage any errors that appear while listing your accounts
console.error (‘errors listing accounts:’, error);
});
// Connect several cases of the metamark supplier
Suppliers Const = [
new supplier ({
Supplier: “Mainnet”,
}),
new supplier ({
Supplier: “Ropsten”, // Ethereum Ropsten Network
}),
new supplier ({
Supplier: “Kovan”, // Ethereum Kovan network
}),
];
suppliers.Foreach ((supplier) => {
supplier.listaccounts ()
.Then ((accounts) => {
cont.foreach ((cont) => {
console.log (cont);
});
})
.catch ((error) => {
// Manage any errors that appear while listing your accounts
console.error (‘errors listing accounts:’, error);
});
});
“
This will list all the addresses connected on each court of the Metamek supplier.