2

I have this contract:

pragma solidity ^0.4.0; 
contract Proof { 
    function register(bytes32 hash) { 
        if (hashToDate[hash] != 0) return; 
        hashToDate[hash] = now; 

    } 
    function dateOf(bytes32 hash) constant returns (uint date) { 
        return hashToDate[hash]; 

    } 
    mapping (bytes32 => uint) hashToDate; 
}

I deployed this contract successfully. I can call dateOf successfully as well, since it is a constant function (return value 0 is intended, since the hash has not been registered, yet):

> proof.dateOf("0x492...fee7d")
0

Now I want to call register(bytes32).

This is what I have from the documentation, but I don't know where to include the argument.

var tx = proof.register.sendTransaction(proof.address, 0, {from:eth.accounts[0]})
2

proof.register.sendTransaction(hashToRegister, {from:eth.accounts[0]})

Which can just be:

proof.register(hashToRegister, {from:eth.accounts[0]})

Because register is not labelled constant.

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.