0

Is that possible to develop a own ethereum wallet without metamask that should connect to main ethereum network. Just like in blockchain.info user clicks the account by just giving email address and password an account will be created in the backend and wallet address will send to the email address. To access my accounts from metamask i am writing this code.

    const provider = new HDWalletProvider(
  '12 mnemonics',
  'https://rinkeby.infura.io/authid',
);
const web3 = new Web3(provider);
const accounts = await web3.eth.getAccounts();

  console.log('Attempting to deploy contract from ', accounts[1]);

Got the answer for my first question 12 mnemonics but

how do i call a payable function which is written in solidity without metamask? I have created new question here How to make transactions without metamask

  • Check for default GAS price and limit in web3js. – kherwa Mar 30 '18 at 12:57
2

Now my question is how can i dynamically get the new 12 mnemonics without metamask

You can use BIP39 npm package to generate mnemonic.

var mnemonic = bip39.generateMnemonic();

and use this mnemonic to generate HD wallet.

  • thanks for your comment. So what i understand is if i can get the mnemonics from BIP39 package i can use those to get the accounts using web3 and i can connect to the ethereum main network by changing the url in the hdwalletprovider pointing to main network right? – Trinu Mar 30 '18 at 11:46
  • yes, actually this 12 word mnemonic will be used to create a seed using this seed you can create BIP 32 (HD wallet). But, i have not used metamask. – kherwa Mar 30 '18 at 12:00
  • How do you make transactions with these generated mnemonics? – Trinu Mar 30 '18 at 12:43
1

If you want to use web3 you can use web3.eth.accounts.create([entropy]); to generate accounts locally. The entropy parameter is optional.

It returns something like this

{
    address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",
    privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",
    signTransaction: function(tx){...},
    sign: function(data){...},
    encrypt: function(password){...}
}

Once you do this you can send ETH to this address. You don't need to connect the address to the main network (or any network in any way). You can generate valid, real accounts while offline. There's no registration / login / connect process. The generated account will work on all Ethereum networks.

  • Thanks for comment. Can you please provide me more clear example. What should i pass inside entropy?. And after account got created how to connect that account to main ethereum network? so that i can send and money real ether to this account. – Trinu Mar 30 '18 at 11:41
  • I've added more info about entropy and main network – cleanunicorn Mar 30 '18 at 12:32
  • Thanks cleanunicorn for the clarification. First answer i got it. Now my next question is how do i call a payable function in solidity? I tried by calling like this const accounts = await web3.eth.getAccounts(); await campaign.methods.contribute().send({ from: accounts[0], value: web3.utils.toWei('0.001, 'ether') }); But i am getting this error "intrinsic gas too low". Earlier with metamask extension it used to ask confirmation if i click submit from metamask then the transaction used to get success. Now since metamask is not there i am getting some error . – Trinu Mar 30 '18 at 12:39
  • Please create a new questions for this – cleanunicorn Mar 30 '18 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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