14

I would like to know how to send ether from multiple accounts. For example, suppose I have 3 accounts with 5 ether in each account, how do I send the total (15 ether) to an account in a single transaction? I'm asking because from what I understand the "from" parameter in "sendTransaction" only accepts a single account.

The reason I'm asking this is because I need to accept Ether payments in my system and I would like to generate a unique account for each deposit, but I'm not sure how to spend the Ether I receive without having to send multiple transactions.

Thanks!

8

This is a fundamental difference between Bitcoin and Ethereum.

In Ethereum having multiple accounts is not like having multiple unspent transactions in Bitcoin, because each Ethereum account has it's own private key and a balance.

Therefore you would have to separately sign each payment from each account - in effect creating a separate transactions everytime.

There are two points that I see with this, the first is that with short block times, you are not penalised in terms of lost time if you are creating multiple payments, and the second is that the fees for each payment are applicable for each payment rather than one overall calculated fee.

If all the accounts were part of a multisig-ring payment this might work however, but it is not very flexible if you only wanted to use one account for something.

  • If that is true, how the new Jaxx HD wallet works? It has a new address for each incoming transaction, but it does not send multiple transactions if you spend the total balance. – Hristo Hristov Apr 15 '16 at 13:20
  • 2
    Ouch, it does?!? I have just tested, and it sends a transaction for each incoming transaction... That's crazy. If you receive 100 transactions on successive addresses it shows you, and you spend it all at once, you will pay 100 transaction fees. Crazy. – Hristo Hristov Apr 15 '16 at 13:33
  • This is one other reason why I think we should not be thinking of Ethereum like bitcoin. In fact a token with a specially designed contract would do this a whole lot cheaper. – T9b Apr 15 '16 at 18:37
  • How would a new token help? To me, it seems that (currently) HD wallets and accumulating payments are just not feasible... But, there is certainly demand of such applications. Maybe this is addressed in future releases. – Hristo Hristov Apr 15 '16 at 18:41
  • It's not a question of helping, but more like not thinking of Ethereum as a currency for the sake of being a currency and operating like a currency. That is not it's purpose, bitcoin achieves that purpose, however a token could also achieve that purpose with much more potential functionality than bitcoin or Ethereum itself for that matter. – T9b Apr 15 '16 at 22:00
6

The reason I'm asking this is because I need to accept Ether payments in my system and I would like to generate a unique account for each deposit,

Don't put ether in raw accounts on a client node, treat a smart contract as an account holder and track the accounts in your smart contract. See multi-sig wallet and other examples on how to track multiple users.

When you wish to send ether, you are sending it from your smart contract, which is one transaction.

It's also more secure to keep ether this way. That's why the multi-sig wallet was invented.

[EDIT, further requirements from comments].

If you just want to track the balance by sender, you would do this in solidity (pseudo-code). If you want to track by customer ID hopefully that's obvious how to change the code.

struct Deposit {
    uint customer_id;
    uint value;
}
mapping (address => Deposit) depositers;
function deposit() { 
    depositsers[msg.sender].value = msg.value;
}
  • 1
    I see. And when the smart contract receives a payment, how does it know who should receive the credit? I can't rely on the source because that payment may come from anywhere (e.g. a shared account like an exchange), and even if the source is a personal account I would require some mechanism to map that account to my user list (e.g. ask each of my users his or her Ethereum account ID which is a bit inconvenient). Ideally I would like to provide different deposit addresses/accounts to different users. How do you suggest I do this using smart contracts? Thanks. – Paul Apr 14 '16 at 12:03
  • 1
    well those are new requirements... I added pseudo-code to show how to track by source address. Ethereum doesn't provide a built in mechanism for unique identification other than by address. With Homestead you can transparently proxy that address easily so that address is useful. If you need your own customer ID setup, you need to set that up. That might be a good separate question: "How do I generate unique customer identification given exchanges and other aggregations of funds by addresses". I think the answer might be "don't aggregate", but try asking it, someone else will answer. – Paul S Apr 14 '16 at 15:47
  • 3
    The question is: "How to spend ether from multiple accounts?" Possible answers are: "It's not possible", or, "In this way". You are answering a question that is not asked. – Hristo Hristov Apr 15 '16 at 13:14
3

depends what you're trying to do. It is theoretically possible to do running on multiple geth instances...but I take it you likely don't want to do that. There is a fundamental difference between Bitcoin's transaction transfer and Ethereum's transaction transfer. For an article that goes further in depth look here:

https://medium.com/@ConsenSys/thoughts-on-utxo-by-vitalik-buterin-2bb782c67e53#.cioo9ab7g

but in the short of it, if you're operating off of one ethereum instance, you would need to execute the transactions sequentially from multiple accounts. There is nothing "multisig like" in this iteration of Ethereum...but there is talk of it happening come Serenity. Stay tuned.

3

No,

In Ethereum, all transactions have a single source and a single destination. The source must be a real account (the one where gas will be removed from). The destination can be a real account or a contract. If it's a contract, the contract code can generate transactions that will send ether to other accounts, other contracts or even can call other contracts in the same transaction.

May be what you should do is send the money to a single account or contract and then do a single transactions from there.

1

Easiest way to do this IMO is to Send/Forward incoming ( ur user/customer) payments to one account and bite the bullet on the (1 extra trans fee) At less than 1 cent usd its not a game breaker LOL

  • 2
    I don't know if you are a native english writer, but please make an effort... – Nicolas Massart Jun 15 '16 at 16:24

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.