5afe / safe-indexer

MIT License
3 stars 2 forks source link

Get logs for incoming ETH #5

Open jpalvarezl opened 3 years ago

jpalvarezl commented 3 years ago

Steps to obtain log-able data:

Resources:

jpalvarezl commented 3 years ago

Using the following payload:

{
  "jsonrpc":"2.0",
  "method":"eth_getLogs",
  "params":[
    {
      "fromBlock":"earliest",
      "address":"0xd6f5Bef6bb4acD235CF85c0ce196316d10785d67",
      "topics": [["0x93696b0f0c5a22fabb96908c9f5d60196caf41fdb2ddc6180cb99680dc5731ad"]]
    }],
  "id":1
}
jpalvarezl commented 3 years ago

I was using the wrong hashing algorithm

jpalvarezl commented 3 years ago

Correct payload:

{
  "jsonrpc":"2.0",
  "method":"eth_getLogs",
  "params":[
    {
      "fromBlock":"earliest",
      "address":"0xd6f5Bef6bb4acD235CF85c0ce196316d10785d67",
      "topics": [["0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d"]]
    }],
  "id":1
}
jpalvarezl commented 3 years ago

This currently returns (rinkeby):

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "address": "0xd6f5bef6bb4acd235cf85c0ce196316d10785d67",
            "blockHash": "0x79e633fefb92282c0c433ffc92d16a666355f9903d4565881fabc1bd3f3990f4",
            "blockNumber": "0x8c08c5",
            "data": "0x000000000000000000000000000000000000000000000000016345785d8a0000",
            "logIndex": "0x7",
            "removed": false,
            "topics": [
                "0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d",
                "0x0000000000000000000000004d3101d77aac1b90ae42efa38d235a81af270d40"
            ],
            "transactionHash": "0x712b3ef44756b0e0833aaf9819fba5090328a069317cdd15e2051e5ab86f2c16",
            "transactionIndex": "0x5"
        },
        {
            "address": "0xd6f5bef6bb4acd235cf85c0ce196316d10785d67",
            "blockHash": "0x7be6f3d19259fd68b2317be5095e82bf79e55a03a7facc3038ea713a7a971d4c",
            "blockNumber": "0x8c1f9e",
            "data": "0x00000000000000000000000000000000000000000000000000038d7ea4c68000",
            "logIndex": "0x9",
            "removed": false,
            "topics": [
                "0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d",
                "0x0000000000000000000000004d3101d77aac1b90ae42efa38d235a81af270d40"
            ],
            "transactionHash": "0xd03fd029ebe83a64ce56260db5d3c9c230b8f8417d0650bc7b5ab7386d2eaaac",
            "transactionIndex": "0x6"
        }
    ]
}
jpalvarezl commented 3 years ago

Using eth_getTransactionByHash like so:

{
  "jsonrpc":"2.0",
  "method":"eth_getTransactionByHash",
  "params":["0xd03fd029ebe83a64ce56260db5d3c9c230b8f8417d0650bc7b5ab7386d2eaaac"],
  "id":1
}

We get all the details:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "accessList": [],
        "blockHash": "0x7be6f3d19259fd68b2317be5095e82bf79e55a03a7facc3038ea713a7a971d4c",
        "blockNumber": "0x8c1f9e",
        "chainId": "0x4",
        "from": "0x4d3101d77aac1b90ae42efa38d235a81af270d40",
        "gas": "0xa021",
        "gasPrice": "0x59682f09",
        "hash": "0xd03fd029ebe83a64ce56260db5d3c9c230b8f8417d0650bc7b5ab7386d2eaaac",
        "input": "0x",
        "maxFeePerGas": "0x59682f0d",
        "maxPriorityFeePerGas": "0x59682f00",
        "nonce": "0xa3",
        "r": "0xca5e889add82c78e2206aba3d746ab20071a266c8c22fe876d441375498295ac",
        "s": "0xe89e87d66467714dd67f6dac9c0d4116ee0f42d51559fd93dad38b47b3d3534",
        "to": "0xd6f5bef6bb4acd235cf85c0ce196316d10785d67",
        "transactionIndex": "0x6",
        "type": "0x2",
        "v": "0x1",
        "value": "0x38d7ea4c68000"
    }
}
jpalvarezl commented 3 years ago

A call to eth_getBlockByNumber would return us a timestamp. Payload ( blockNumber needed, set to true for more details)

{
  "jsonrpc":"2.0",
  "method":"eth_getBlockByNumber",
  "params":["0x8c08c5", false],
  "id":1
}

Results in the following response: (notice timestamp)

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "baseFeePerGas": "0x9b197",
        "difficulty": "0x2",
        "extraData": "0xd883010a07846765746888676f312e31362e36856c696e757800000000000000f2c1467cae45289586424d8ce570406b6eb17b1428d7ba5e91f17c405be877754d9781f8301b7abea49ab93bdb46cd59ac85e861dbe9de0092c58fce12e2742100",
        "gasLimit": "0x1c950d9",
        "gasUsed": "0x14ff518",
        "hash": "0x79e633fefb92282c0c433ffc92d16a666355f9903d4565881fabc1bd3f3990f4",
        "logsBloom": "0x0090440000810000014000008200401108000804040010000180004000012000000200800080001080000c06020080050800000001200280020002400030190100000441001090d218000008002080120081010200004000040020000810044000000000020001200081000122400a01a000000100044008881c101002102040180000000040014800020400000021080008a00002000201008000110440000042008004100012000120004440000004080080000800008902010800001104084020800a62000000100000000440880802040004000400120003000080002000081008800024080c080002c00000610002800080618002000000000803800000",
        "miner": "0xd6ae8250b8348c94847280928c79fb3b63ca453e",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0000000000000000",
        "number": "0x8c08c5",
        "parentHash": "0xc1e25457b09ffbd17c81b0a295fd59e55a8f64caf1d03a567062c57b311945a9",
        "receiptsRoot": "0x43de53ddc66c3290bbfb9a680f17e2dc6368541c4ebb9cf0c8425dbfdb288406",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "size": "0x4689",
        "stateRoot": "0x38e79350b73da23344443785d923cd3a328f9220e45315857aac4c31a04bebe7",
        "timestamp": "0x61265072",
        "totalDifficulty": "0xedae35",
        "transactions": [
            "0x04d2a15d78e50fa441e06af7e5eeb0ce01e3134619fb6b7e17e9322cd3806012",
            "0x9f62b38567d59c392f19a3cd2829947a4aab5102c691d5a5d2326003c5462ea5",
            "0xf8f693b6290defe1acdba7ed4bafd1b4f4120087deab058c20ec0bc9599c8563",
            "0xf5b3ee3c009f1ad337ed036a4b69ba6a4471935fd9cf316ecc6b78768c7f75c8",
            "0x11b0e2bcb7f1a744e15bb5946cba68e5aa5f82d0cb4350985d56d3692ceec432",
            "0x712b3ef44756b0e0833aaf9819fba5090328a069317cdd15e2051e5ab86f2c16",
            "0xf4aef32483a922c265cece54081fd08a0c5895b0b672e633422bbe864790d4aa",
            "0xa1d47e56e5f309710092550866bdb8cc646d347cc772d56a7c34247e5c72105a",
            "0x1d00cb6dc63f03ba4811cab09b7906beb0352944fc08c6f7da7cb4569b73e1df",
            "0xff6f10533b0cf78fedaed58f62ab837948f02deaca39d6ea319312431e80f7fa",
            "0x81e59ce1a7d15952ca3990189f65002b8b4877551f0611e6f8aeafb65cfb1fa3",
            "0x847b8b527a4a12ded8aea050a8a38b08ad3e34068942e7ac910d124c8c6d3216",
            "0xbaaae81eac98c1170918cb99d95b805f268d448db067a44e70f188ef5761dd27",
            "0x28aab118749e5db5cd894071c56929ff0c33d911c959501ba16e370aacdd3f68",
            "0x1687c1ceb3434800afbb6c0f1ebe5e6f7a776f9691c31218e8a6c6cb40de50c2",
            "0x9ae5279d5afcd83a91627f59243ff642cc942d9878a4318ab5051ab88a627ee2",
            "0xc0800090138619935a2b82f7481d64795e8102a74eabbbafc0b50f91c5d0b981",
            "0x28de5b46eba0ef7a8046b2d7b26cf022e704420d1731ae21746dcdf58d97f8ee",
            "0x3bdf9978cec8442ec0d70b4d4ac507fe31b8e8bd748932c763f5ae94a72bd335",
            "0x8e4bd18f3005f4a62ccb17cf2f905df3606747c7df2995e3b93c10b908040116",
            "0xa8dbd1262087d102ade8a58a3c629b122c7ae7c57c09ea6ffdd8ca9c7662eb6d"
        ],
        "transactionsRoot": "0x5afbcac57ee1481ca86b75ab8313deaa0ad440b62d05ced9b8b349c5b35270b8",
        "uncles": []
    }
}
jpalvarezl commented 3 years ago

Done.

jpalvarezl commented 2 years ago

Correct topic for SafeMultisigTransaction signature for hashing:

SafeMultiSigTransaction(address,uint256,bytes,uint8,uint256,uint256,uint256,address,address,bytes,bytes)