-2

I want to derive Address of my own wallet developed using web3 frameworks without looking onto etherscan for the Address.

 var Web3 = require("web3");
 var url = 'https://ropsten.infura.io';
 var web3 = new Web3(url);
 var address = '0x8690F1feff62008A396B31c2C3f380bD0Ca6d8b8';
 var balance = web3.eth.getBalance(address);
 var wallet = web3.utils.toWei(balance, 'ether');

Here, I want not to provide Address, but, access it by some codes in Web3. May I know the steps to be followed?

5
  • What code??????? – goodvibration Jul 25 '20 at 12:01
  • Yeah, I got that part. But where is your code that you are asking us to help you with??? – goodvibration Jul 25 '20 at 12:21
  • First of all, you did not post that additional link up until now, so please don't play innocent. Second, what does "I want to develop the following code" even mean??? What's stopping you from developing it? Heck, why do you even need to develop a code, which has obviously already been developed? You actually shared a link to it! Please do some work, then, whenever you run into a specific technical problem, post it here, along with a detailed explanation of what the problem is, your preliminary findings while debugging it, and what you've attempted in order to solve it yourself. – goodvibration Jul 25 '20 at 12:28
  • It is not clear what are you trying to accomplish. Do you want to get your wallet's balance using infura instead of etherscan? – Ismael Jul 25 '20 at 18:52
  • @goodvibration and Ismael : This is the possible answer, I was looking for to access and work on my wallet or accounts. ethereum.stackexchange.com/a/85284/55270 – Ank_247shbm Jul 26 '20 at 9:12
0

Finally, I got the answer:

It is by two different method:

Method-I:

var Web3 = require("web3");
var web3 = new Web3('https://mainnet.infura.io');
var wallet = web3.eth.accounts.wallet.create(1);

console.log(wallet['0'].address); 

Output:

0x798bd25e7e299a6621a4a8e7fa31926d9fc27d0c

Method-II:

var Web3 = require("web3");
var url = "https://mainnet.infura.io/v3/60968ff3b2f84a0ebdff7a993f4d080b";
var web3 = new Web3(url);
var wallet = web3.eth.accounts.wallet.create(5);
var encryptKey = web3.eth.accounts.wallet.encrypt('Aditi');

var keys = encryptKey.map((accounts)=>{console.log('0x' + accounts.address)});

Output:

0x798bd25e7e299a6621a4a8e7fa31926d9fc27d0c
0x9039ecca623fd6e16eb8550085ae0575b6e15763
0xf5008447d7abb3fad1fcfef9a6f85b84ab64732e
0x829126afab3894a0da0cb0b0949c8e8e736466c0
0x97ebdc82777bd6650e316de8e59f8e7de0076e82
0xda81d921ec088c2bf4627e94e99c5c2a8dccf00d

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