2

I have written the below code and it runs perfectly. After mining and passing the values along with certain gas value, i get transaction hash as output on the geth console. Now i want to know the output of sha3 function applied in the code?

contract C { 
string a;
string b;
bytes32 d;

function identify(string sm, string bm, bytes32 i) returns (bytes32 hash){
    a = sm;
    b =bm;
    d = i;
    return sha3(sm, bm, i);
}

}

Once mining is done. i type the following command:

c.identify("Bob","Alice",1234);

I get the transaction has i.e

Contract mined! address: 0x1df37eeccc9278b04497b4a3c97388cac3a98e6f    
transactionH
ash: 0x7bf49540c9db92cab84b483514ffebdb600d39889ef2319904bc788d7c87afd9
c.identify("rahul","ankesh",1234,{from:primary,gas:300000})
"0x24d344a11f9aa84d43ccf0e17e635750e3d44fee0c4eaba1c1dea8ebbdaf3376".

Now, where is the output of the sha3 function?

1

Some options, explicitly label the function constant:

function identify(string sm, string bm, bytes32 i) constant returns (bytes32 hash)

or explicitly perform a call:

c.identify.call("Bob","Alice",1234);

I tested in browser-solidity and you should see the value 0xc479d062d8322fb8b4207d9967174220d6d86d90fef3b5c6cefc8ec6577e21c8.

More info: What is the difference between a transaction and a call?

1

The return value of a contract call is ignored unless the call is from another contract. The yellow paper has the following sentences:

Aside from evaluating to a new state and transaction substate, message calls also have an extra component---the output data denoted by the byte array $\mathbf{o}$. This is ignored when executing transactions, however message calls can be initiated due to VM-code execution and in this case this information is used.

If you record an event in Solidity, the event logs are visible in the transaction receipt.

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.