2

I am in the process of developing a custom ETH wallet, I am able to generate the public/private keys by using vanity eth. After receiving the amount in this wallet, I need to send ETH to another wallet for which I am trying to use web3. How do I do this? The wallet currently have few ETH in it but when I try to check the balance with web3 code it shows zero balance. So how do I transfer ETH from one wallet to another using web3 code, please advice.

My code for get balance of my wallet address is as below.

<script src="./node_modules/web3/dist/web3.min.js"></script>
<script type="text/javascript">
    var Web3 = require('web3');
    var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
    console.log("Balance = " + web3.fromWei(web3.eth.getBalance('Wallet_address'), 'ether').toNumber());
</script>
TylerH
  • 20,799
  • 66
  • 75
  • 101
Dhara Chauhan
  • 51
  • 1
  • 3

1 Answers1

2

Try this.

web3.eth.sendTransaction({from: acct1, to:acct2, value: web3.toWei(1, 'ether'), gasLimit: 21000, gasPrice: 20000000000})

This is how I performed an ether transaction in a previous project. Also in the future posting here, for the time being, may get you a quicker response https://ethereum.stackexchange.com/

Lucas Hendren
  • 2,786
  • 2
  • 18
  • 33
  • thanks for your suggestion, I already did this but it's working in web3 generated ether address not working into vanity generated ether address. My wallet address have 6 ether balance,But when i checked that using web3 code which is given below, It shows me balance 0.If it gives balance 0 then how can web3 will send ether to other wallet? Here is my code to get balance of ether wallet. web3.fromWei(web3.eth.getBalance('Wallet_address'), 'ether').toNumber() – Dhara Chauhan Sep 13 '17 at 05:29
  • Are you positive Vanity is actually populating/creating the addresses correctly? Im looking more into it currently but want to clarify – Lucas Hendren Sep 13 '17 at 05:41
  • Yes, vanity-eth is generating address pair currectly. – Dhara Chauhan Sep 13 '17 at 07:32
  • How are you adding in the initial ether to the account? – Lucas Hendren Sep 13 '17 at 07:42
  • Using coinpayment – Dhara Chauhan Sep 13 '17 at 09:32
  • and still looking into it, so does coinpayment work for web3 generated wallets? – Lucas Hendren Sep 13 '17 at 15:50
  • @DharaChauhan did created user ether wallet address?? and u made any transactions & exchange?? – shankar Mar 09 '18 at 11:37