7

Is there any API for send and receive Ethers? If not, i am trying to use web3.js in my own server;

  1. What are the technical implications?
  2. Major security concerns?
  3. Can I use the same API for creating address for public?
  4. Are there any trust issues?

3 Answers 3

6
  1. web3.eth.sendTransaction is the API for transferring ether, the transactionObject has a value parameter which you can set: you have to specify the number of wei, and 1 Ether is 10**18 wei.
  2. A security concern is that if you're sending Ether to a contract account, it can reject the Ether using a fallback function.
  3. Another concern is sending to a wrong or mistyped address. The Ether will remain at that address and remain unspendable forever, unless someone has the private key to the address.
  4. Do not use any APIs that ask you to send your private key, seed, or mnemonic.
0
4

Can I use the same API for creating address for public?

No, you cant do this with web3.js as of now.

You can use LightWallet by ConsenSys to create an account. Sample code will be

// generate a new BIP32 12-word seed
var secretSeed = lightwallet.keystore.generateRandomSeed();

// the seed is stored encrypted by a user-defined password
var password = prompt('Enter password for encryption', 'password');
lightwallet.keystore.deriveKeyFromPassword(password, function (err, pwDerivedKey) {

var ks = new lightwallet.keystore(secretSeed, pwDerivedKey);

// generate five new address/private key pairs
// the corresponding private keys are also encrypted
ks.generateNewAddress(pwDerivedKey, 5);
var addr = ks.getAddresses();

// Create a custom passwordProvider to prompt the user to enter their
// password whenever the hooked web3 provider issues a sendTransaction
// call.
ks.passwordProvider = function (callback) {
  var pw = prompt("Please enter password", "Password");
  callback(null, pw);
};

// Now set ks as transaction_signer in the hooked web3 provider
// and you can start using web3 using the keys/addresses in ks!
});
0

Is there any API's for sending ethereum tokens(like: EOS, TRON, OmiseGO etc...) from one address to another

If you wish to accomplish this in web3.js, you will simply need to obtain the contract address of the ERC20 token, as well as the ABI of that contract. Using those two details, we can create an instance of the token contract in our dApp by using:

//we need to obtain the eos token contract abi and address
const eosToken = new web3.eth.Contract(eosABI, eosAddress)

Once we do this, we can use ERC20 functions transfer() and transferFrom() to send tokens to another address.

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