3

I have my contract address = "0x70094cae9a74c9ae08aa2ae643bcfdd9fa9edfee"

My contract pay back ether to some account: msg.sender.send( amountToGain ) For example msg.sender should gain amountToGain amount. I would like to see this payment using geth if possible.

How could I view the list of value(ether) sent from my contract address to other addresses? The addr.send(amnt)'s act/transaction from=>to (value) does not show up on the block explorer. So by using this function we can anonymously sent money to other addresses and FBI cannot track us.

I have used this script(Common useful JavaScript snippets for geth) but it does not return anything when I used my contract address and msg.sender.send( amountToGain ) action is actually performed.

For example I view following:

  tx hash          : 0x98fb1385453e7f22662789dde2fb88fc4d9312371fc9326f5113599f6d036728
   nonce           : 8247
   blockHash       : 0x942aececdc56a5bdd3265f3c9e898152fdb66d7ea6e91ba1377896a46daf1c25
   blockNumber     : 1346471
   transactionIndex: 0
   from            : 0x6af0204187a93710317542d383a1b547fa42e705
   to              : 0x70094cae9a74c9ae08aa2ae643bcfdd9fa9edfee
   value           : 0
   time            : 1498054743 Wed, 21 Jun 2017 14:19:03 GMT

But the transaction: from contract(0x70094cae9a74c9ae08aa2ae643bcfdd9fa9edfee) to client(0x6af0204187a93710317542d383a1b547fa42e705) there is money has been transferred, which I cannot view as a transaction.

So basically we cannot trace/proof the sent money amount and whom the contract sent to.

[Q] Could we verify the value has been sent to specific account using web3.debug.traceTransaction( tx )?

Example Contract:

pragma solidity ^0.4.0;

contract TestSend {

    uint public balance ;

    function TestSend() {
        balance = 0 ; 
    }

    function () {
        throw ;
    }

    function pay() payable public  {
        balance += msg.value ; 
    }

     function withdraw(address addr,uint amnt)  public  {

        balance -=  amnt  ; 

        if (! addr.send(amnt)) {
              balance +=  amnt ; 
        }
    }     
}
  • IMO sending value is an important state change, so a contract should emit an event for that. In that case, you can use an event listener. – Rob Hitchens - B9lab Jun 21 '17 at 15:30
  • I do that, event returns the value(amountToGain), is there any other solution without the event listener? @Rob Hitchens – alper Jun 21 '17 at 15:40
  • I don't think I understand the aversion to events. The whole idea is the event can be anything you want if you author the contract. You can put the relevant information you want there, or even better, include all relevant information anyone, anywhere will ever want. – Rob Hitchens - B9lab Jun 21 '17 at 18:46
  • 1
    @Avatar are you experiencing 'flaky' event listening? I've run into that problem with geth sometimes. A slower alternative is to iterate through all the transaction hashes in the block range you're interested in and looking at logs in the return value from getTransactionReceipt(). – carver Jun 25 '17 at 16:30
3
+50

In my opinion, it's more of a contract design issue than a free service at the protocol level.

Have a look here: https://etherscan.io/tx/0x8857bd2a976fe61de0039da0becf3b4da0fe48e5e33b8973468742e0736a173a

You can see "internal transactions", but ...

... have a look here: How to get contract internal transactions

Main takeaway: Those "internal" transactions are not explicitly shown anywhere you can easily access. They come from running the contract and watching what it does.

Technically, there is no such thing as an "internal transaction." There are "Transactions" that originate with signed messages from Externally Owned Accounts, and there are messages which are internal invocations when contract functions communicate - always started by a "Transaction". Also (important), no nesting of "Transactions".

You construct your contract so it emits events with each and every significant state change including, but not limited to, value transfer. No exceptions. You prove that with the contract source code.

Suppose Alice arrives with a transaction hash and claims she wasn't paid. I suppose Bob wants to prove the claim is invalid, or else Alice will want more money.

Events related to transaction: https://etherscan.io/tx/0x8857bd2a976fe61de0039da0becf3b4da0fe48e5e33b8973468742e0736a173a#eventlog

Does your contract source prove that no event could be emitted without a corresponding value transfer? If it's hard to be certain, then I suppose life will get messy. That's not the ideal, not how it should be. It should be plain to see that a) there is an event and b) the debate is settled.

You want to arrange the event logs so the complete state history of the contract can, in theory, be reconstructed from the logs. You should be able to convincingly demonstrate that no value transfer is possible without a corresponding event and no event is possible without a corresponding value transfer.

Hope it helps.

1

The transaction that you sent to your contract will be a different contract than the one that the contract itself creates and publishes that sends the funds back to you. So, looking up data for the specific transaction hash of you triggering the payment method on the contract won't get you the information you need. Instead you'll need to query for transactions send by the contract address, which should show a separate transaction with the payment.

  • How could I query for transaction, by event? @MidnightLightning – alper Jun 21 '17 at 21:08
  • The Transaction hash of the in-progress transaction is not exposed to the smart contract code, so any Event emitted during the run of that transaction can't know that bit of data, but could include something else that can help identify the transaction it belongs to, but wouldn't by default. So, if all you have is the Event, I'm not sure how you would be able to get back to the transaction that emitted it. – MidnightLightning Jun 21 '17 at 21:35
1

This is how you do it, but do not expect it to be easily implementable into a webinterface without a considderable amount of work.

  1. When the contract makes a transfer, fire an event.
  2. Watch for the event like this or in truffle, like that .
  3. You can store the ID of the respective transaction and take a close look at it's data, where you can find / parse the information of events or the transaction from the contract to the recipient itself. Try it out: Make your contracts transfer the same amount of ETH to different recipients, and then keep the recipient the same an change only the amount. Pitfall: The transfer value is encoded in hex.

Or if your users are a bit tech-savvy, you can show them your contract code, where you ensure through if-conditions:

mapping public (address => int[]) allTransfersToThatUser;
if (transferSuccessfull) {
allTransfersToThatUser[0x1234theRecipient].push(theTransferedSum);
}

Have fun!

1

QuickBlocks provides full, accurate lists of both internal and external transactions. We're currently in pre-alpha, but hoping to release something soon.

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.