0

enter image description here

pragma solidity ^0.4.13;

contract OwnedI {
    /**
     * Event emitted when a new owner has been set.
     * @param previousOwner The previous owner, who happened to effect the change.
     * @param newOwner The new, and current, owner the contract.
     */
    event LogOwnerSet(address indexed previousOwner, address indexed newOwner);

    /**
     * Sets the new owner for this contract.
     *     It should roll back if the caller is not the current owner.
     *     It should roll back if the argument is the current owner.
     *     It should roll back if the argument is a 0 address.
     * @param newOwner The new owner of the contract
     * @return Whether the action was successful.
     * Emits LogOwnerSet.
     */
    function setOwner(address newOwner) returns(bool success);

    /**
     * @return The owner of this contract.
     */
    function getOwner() constant returns(address owner);

}

pragma solidity ^0.4.13;

import "./OwnedI.sol";

contract Owned is OwnedI {
    address public owner;
    function Owned() {
        owner = msg.sender;
    }

    modifier fromOwner() {
        require(msg.sender == owner);
        _;
    }
    /**
     * Sets the new owner for this contract.
     *     It should roll back if the caller is not the current owner.
     *     It should roll back if the argument is the current owner.
     *     It should roll back if the argument is a 0 address.
     * @param newOwner The new owner of the contract
     * @return Whether the action was successful.
     * Emits LogOwnerSet.
     */
    function setOwner(address newOwner) fromOwner returns(bool success) {
        require(msg.sender != address(0));
        require(newOwner != owner);
        address previousOwner = owner;
        LogOwnerSet(previousOwner, newOwner);
        owner = newOwner;
        return true;
    }

    /**
     * @return The owner of this contract.
     */
    function getOwner() constant returns(address outputOwner) {
        return owner;
    }
}

    pragma solidity ^0.4.13;

import "./Owned.sol";

contract CheckOwner is Owned {

    int public check ;

    function CheckOwner () {
        check = 1;
    }

    function setCheck() fromOwner {
        check++;

    }
}

I call setOwner(). When I remove the indexed keyword from OwnerI for LogOwnerSet, I am able to see the parameters in my transaction. However, if I keep the indexed parameter, in my transaction, my event parameters only show the first letter in the address.

Here is with indexed:

{
        "topic": "a1d2149652d81eb35c360c115fc7ac594124cb1ea8a5a33e9a7f5768c62869fb",
        "event": "LogOwnerSet",
        "args": [
            [
                "0xc"
            ],
            [
                "0x1"
            ]
        ]
    }

Here is without indexed:

[
    {
        "topic": "a1d2149652d81eb35c360c115fc7ac594124cb1ea8a5a33e9a7f5768c62869fb",
        "event": "LogOwnerSet",
        "args": [
            "0xca35b7d915458ef540ade6068dfe2f44e8fa733c",
            "0x14723a09acff6d2a60dcdf7aa4aff308fddc160c"
        ]
    }
]

As you can see, it returns just the 1st character of the address. I need the event log to be indexed.

Am testing in remix

Edit: I tried this with another Event(address out, bool paused) and transaction log parameter has similar problems. The address returns first char and the bool returns "0000000000000000000000000000000000000000000000000000000000000001" which is true. Am I missing some info on how indexed works?

4
  • Can you provide more information about how you're viewing the generated events? When I try very similar code, I'm able to see the full (indexed) address arguments.
    – user19510
    Dec 29, 2017 at 5:58
  • I am using browser remix solidity. When calling a function, you are able to see the transaction that is broadcasted. In the transaction, under the logs sections, you can see any events broadcasted during the call. I have added a screenshot above. Dec 29, 2017 at 6:25
  • Got it. I tested via web3.js and saw the full arguments. Perhaps a Remix bug?
    – user19510
    Dec 29, 2017 at 6:27
  • might be, i was testing using javascript vm Dec 29, 2017 at 8:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.