If I understand your question correctly you want to be able to see who has deposited Eth to your contract address. This is what event logs are for.
(1) Create a contract where there is an event every time there is a transaction. e.g something like:
contract someContract {
address public owner;
// Set the owner of the contract to be the creator of the contract i.e. you
function someContract() {
owner = msg.sender;
}
// This is an event
event DepositMade(address _from, uint value);
event WithdrawalMade(address _to, uint value);
//Catch all function
function() {
// generate an event when someone sends you Eth
if (msg.value > 0)
DepositMade(msg.sender, msg.value);
}
// Only the owner of the site can withdraw Eth
modifier admin { if (msg.sender == owner) _ }
function withdraw(uint amount, address recipient) admin {
if(recipient.send(amount))
WithdrawalMade(msg.sender, msg.value);
else throw;
}
}
The important bits are defining an event type event DepositMade(address _from, uint value)
and generating an event when something happens DepositMade(msg.sender, msg.value);
these events are stored in the event log associated with the address of the deployed contract instance.
(2) You retrieve the events on this contract using rpc eth_newFilter
or web3.eth.filter
e.g something like:
var filter = web3.eth.filter({fromBlock:0, toBlock: 'latest', address: contractAddress, 'topics':['0x' + web3.sha3('DepositMade(hexstring,uint256)')]});
filter.watch(function(error, result) {
if(!error) console.log(result);
})
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.
Best Answer
Th ere are two types of accounts in Ethereum:
Here accounts refer to EOAs. EOAs are able to hold and transfer ethers but they can't display the incoming transactions.However, they can display the transactions send from account, like transferring ethers or contract execution.
For eg, If you transfer some ethers from etherbase(Account1) to other account, say Account2. Account 1 will show the transaction details but account will not show anything under
Latest Transactions
Tab.However if you have to keep track of incoming transactions to an account you have to create a wallet contract.
Now if you transfer ethers from Account1 to your walletContract(say it be WalletContract1), both Account1 and WalletContract1 will show the transactions.
So, Wallet Contracts also keep a list of incoming transactions whereas EOAs don't.
There are differen types of wallet contracts like :
which offer a lot better features than normal EOAs. But creating a wallet contract requires transaction fee (gas). Read full description here.
Read the difference between EOAs and Wallet Contracts here.