My contract is

pragma solidity ^0.4.11;

contract UserBasic {
    struct Record {
        bytes32 _id;
        address _addedBy;
        uint _dateAdded;
        bytes32 _transactionHash;
        bytes32 _type;
        bytes32 _hash;
        bytes32 _signature;
    // Type to records array
    mapping(bytes32 => bytes32[]) typeRecords;
    // Record ID to record
    mapping(bytes32 => Record) idRecord;
    // Add a record
    function addRecord(bytes32 _type, bytes32 _id) {
        var _new = Record(_id, tx.origin, now, "", _type, "", "");
        idRecord[_id] = _new;

Whenever someone calls addRecord I'd like that transaction's hash to be the

bytes32 _transactionHash;

of the new record being created. I looked through the solidity docs but couldn't find anything there. Is this possible?


1 Answer 1


Looking through the available EVM opcodes, there's nothing there that is able to access the transaction's hash. And some of the parameters you'd need if you wanted to recalculate it (such as the nonce) are not available either, so that's not possible. So, unfortunately, there's no chance of being able to do this in Solidity.

Not the answer you're looking for? Browse other questions tagged or ask your own question.