Metamask: Is there a way to output a list of Metamask account names and addresses?

Displaying accounts and addresses of metamaska ​​

While working with Metamask, managing many accounts can be troublesome. In this article, it contains a step -by -step guide on the listing of the list of accounts and address names using the API interface of the internet portfolio.

preliminary requirements

  • Make sure that a metamask has been installed on the device and you generated a phrase of seeds.

  • You must have the “Metamask” package installed: “NPM Install Metamask”

  • Read the documentation of the API interface in Metamask Web Portfolio

Step 1: Get your accounts and address

Use the following code to recover the names and addresses of the account:

`Javascript

const {web3provider} = requires ("web3");

Const provider = new web3provider ('http: // localhost: 8545'); // replace the local network supplier

Async getaccountsandadresses () {function

Const bills = wait for the supplier.Getaccounts ();

Let the address = '';

for (let i = 0; i

console.log (account $ {i+1}:, accounts [i]);

address +=address: $ {bills [i]} \ n;

}

Return {accounts, address};

}

Getaccountsandadresses (). Then ((result) => {

Console.log ('starting:');

console.log (result.address);

// You can also derive a list of account names

result.

console.log (conct $ {conct.index}:, account.name);

});

});

Explanation

  • We create a new “Web3Provider” instance and connect to the local network supplier (replace it http: // Localhost: 8545).

  • We use the “Getaccounts () method for downloading a number of accounts.

  • ITEMNE via an account board and register each account name and address individually.

  • Finally, we return the object containing both a list of accounts and address names.

Step 2: Issue a simple list

To make a simple list of accounts and address names, you can use the “console.log” function:

`Javascript

const {web3provider} = requires ("web3");

Const provider = new web3provider ('http: // localhost: 8545'); // replace the local network supplier

Async getaccountsandadresses () {function

Const bills = wait for the supplier.Getaccounts ();

Let the address = '';

for (let i = 0; i

console.log (account $ {i+1}:, accounts [i]);

address +=address: $ {bills [i]} \ n;

}

Return {addresses: address, accounts};

}

Getaccountsandadresses (). Then ((result) => {

Console.log ('starting:');

// You can also derive a list of account names

result.

console.log (conct $ {conct.index}:, account.name);

});

});

Example of use cases

  • Share your accounts and Metamask addresses in the team or customer.

  • Automatize tasks by sending notifications to specific accounts and addresses.

  • Create non -standard reports and navigation desktops that display account information.

By following these steps, you can easily derive the list of accounts and address names Metamask. Remember to mention the URL “HTTP: // Localhost: 8545` if necessary.

Coin Blockchain

Leave a Comment

Your email address will not be published. Required fields are marked *