dYdX has an event called LogDeposit(address indexed accountOwner, uint256 accountNumber, uint256 market, BalanceUpdate update, address from) within their SoloMargin contract. I am trying to get the signature hash for this using the following code:

from Crypto.Hash import keccak
keccak_hash = keccak.new(digest_bits=256)

This produces the following signature hash: ad66b490ac5d24d41e7e33a2a9ac6645bf66b577553f31d1e2917df2f83f15a6. However, I do not think it is right. When I search for this topic in etherscan nothing is returned.

I am wondering if it has to do with the BalanceUpdate parameter. I am used to searching for the other types such as address and uint256, but this one I haven't seen and do not know if I am doing this right.

  • Can you edit your question to show what BalanceUpdate is composed of? dYdX contains many contracts, I'm not easily able to find it. Nov 8, 2019 at 19:03
  • I updated the original question. It is within their Solo Margin contract. The Balance update is a struct that contains the following: ` struct BalanceUpdate { Types.Wei deltaWei; Types.Par; }`
    – Brandon
    Nov 8, 2019 at 20:52

2 Answers 2


When calculating the signature of an event that uses structs, each struct is represented as a tuple of the types of the variables it contains. To create the tuple for your question, we need to look at the source of SoloMargin.

Based on the source published to Etherscan, I extracted the code needed to create the event:

pragma solidity 0.5.7;
pragma experimental ABIEncoderV2;

contract SoloMiningLogEvent {

    struct Wei {
        bool sign;
        uint256 value;

    struct Par {
        bool sign;
        uint128 value;

    struct BalanceUpdate {
        Wei deltaWei;
        Par newPar;

    event LogDeposit(
        address indexed accountOwner,
        uint256 accountNumber,
        uint256 market,
        BalanceUpdate update,
        address from


We can see that BalanceUpdate is composed of two structs:

  • Wei, a tuple of (bool,uint256)
  • Par, a tuple of (bool,uint128)

So our tuple representation for BalanceUpdate is:


Thus the entire signature to generate the hash is written as:


which results in a hash of:


This event's signature is:


This is keccak256 hash of the following string:


Your Answer

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

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