0

How i can send one ETH from my one wallet to another wallet using API. If i have only one ETH in wallet can i send that ETH or i have to manage balance in my wallet, GAS fee will cost to me not? I have Private key of account from which i have to send ETH.

Can i test this functionality in Testnet like Ropston ?

0

How i can send one ETH from my one wallet to another wallet using API.

You need an ethereum node (geth or parity). You can host your own node or use a third party node (I am not sure about any). You can then use web3.js to send transaction using api. A sample code could be like:

custom_func.prototype.SENDETHER=function(from,to,password,amount){
    return new Promise(function(fullfill,reject){
        web3.eth.personal.unlockAccount(from, password).then(function (result) {
            web3.eth.sendTransaction({from:from,to:to,value:web3.utils.toWei(amount,"ether")})
                .on('transactionHash', function(txHash){
                    console.log("Transaction hash : "+txHash);
                    fullfill(txHash);
                }).catch(function(err){
                    console.log(err);
                    reject("Unable to send transaction");
                });
            }).catch(function(err){ //catch of unlock account
                console.log(err);
                reject("Unable to unlock sender's account with given passphrase");
            });
    });
} 

f i have only one ETH in wallet can i send that ETH or i have to manage balance in my wallet, GAS fee will cost to me not?

You have to calculate gas by yourself. You can not send exact 1 ETH, if you have just 1 ETH in your account. You can calculate the eth for gas by given formula:

fee_in_wei = gas * gasPrice

For sending eth, gas in 21000 and let's say you decide to send a gas price if 3 GWei. So fee = 21000*3000000000 wei => 0.000063 ETH.

So amount you will send is 0.999937. (Do check calculation by yourself).

I have Private key of account from which i have to send ETH.

If you want to send this to another wallet of yours, think about importing private key. Not sure if this is what you need.

7
  • can you please provide any third part node, which i can check, I want to test ETH Transfer on Ropsten Network at present. – Rushabh Madhu Apr 30 '18 at 7:25
  • have you develop such code in nodejs, i am planning to develop code using nodejs – Rushabh Madhu Apr 30 '18 at 7:26
  • I am not sure of any such third party node. Also, third party nodes are not reliable in terms of security. If you want to build ad Dapp or deal with payments, better host your own geth instance. You can definitely use node.js for building such apps as web3.js is a javascript liberary. – Prashant Prabhakar Singh Apr 30 '18 at 9:30
  • How i can use web3 for using ether API, it is required to deploy blockchain server to local before use ? Is there any other live end points which can be helpful to me – Rushabh Madhu Apr 30 '18 at 11:20
  • If you want to use for development purpose, there is no need to sync to a full blockchaim. You can set-up a private blockchain as explained here. But for production, you need to run a geth/parity node to sync blockchain. – Prashant Prabhakar Singh May 1 '18 at 5:43

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.