Skip to main content

Data decoding


Data decoding is the first step towards data transformation and enrichment to make the blockchain transactions more human readable. Lets get to know some basic terms before we get an understanding of how data is decoded.


What Is a Smart Contract?


Smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network.


What is an ABI?


ABI (Application Binary Interface) stands for a specification that defines the encoding/decoding of data types and a standard for exposing and invoking methods in a smart contract.

Verified contracts have ABIs. Let's take one contract from etherscan.io

  • Contract name: Bored Ape Yacht Club
  • Contract address: 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D

In the "Contract" column of this page, if we scroll down, we would see Contract ABI for the given contract.

  • Contract ABI:
    [{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},
    {"internalType":"uint256","name":"maxNftSupply","type":"uint256"}, ... ]```

Using these interfaces, the system parses method names and signatures for each validated contract.


The system flow


The data-decoding flow contains 4 main parts:

  1. The Propellyr Data Collectors save data (blocks and transaction information).
  2. The Propellyr Decoder finds respective ABIs for particular transaction's contract address.
  3. The platform automatically pulls ABI from thirdparty API providers for newly added contracts.
  4. The Propellyr Decoder matches needed method information with the help of method signatures that was executed.
  5. Parsed data stored in other table in database

Example


Below is a sample transaction performed by an “EOA” (from) on Multichain Smart contract address (to) to initiate a transfer of tokens from Ethereum to the chainID 56 (BSC).

{
…..
"from": "0xd545f4e3f42f5b1f5a913401ced078e7d55fb4cf",
"gas": "0x1d3a6",
"gasPrice": "0x1623463e12",
"hash": "0xc45ca69cab499cf40c562ceda49d106adec3c89758662c27e8e5c436d8172b29",
"input": "0xedbdf5e200000000000000000000000022648c12acd87912ea1710357b1302c6a4154ebc000000000000000000000000ec812a6b4bcd47aa66e3ded01cd945ccdcf2df8d0000000000000000000000000000000000000000000000000000000c4ea3bff20000000000000000000000000000000000000000000000000000000000000038",
"to": "0x6b7a87899490ece95443e979ca9485cbe7e71522",
"value": "0x0"
……
}

The log event for transfer of token across the chain is captured in the below logs:

  {
"address": "0x6b7a87899490ece95443e979ca9485cbe7e71522",
"blockHash": "0x79955bfa7ec1f6e6849549c774c1d9cbcee316974efd1a33619f770138b36dd0",
"blockNumber": "0xec5f5c",
"data": "0x0000000000000000000000000000000000000000000000000000000c4ea3bff200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000038",
"logIndex": "0x5e",
"removed": false,
"topics": [
"0x97116cf6cd4f6412bb47914d6db18da9e16ab2142f543b86e207c24fbd16b23a",
"0x00000000000000000000000022648c12acd87912ea1710357b1302c6a4154ebc",
"0x000000000000000000000000d545f4e3f42f5b1f5a913401ced078e7d55fb4cf",
"0x000000000000000000000000ec812a6b4bcd47aa66e3ded01cd945ccdcf2df8d"
],
"transactionHash": "0xc45ca69cab499cf40c562ceda49d106adec3c89758662c27e8e5c436d8172b29",
"transactionIndex": "0x40"
}

The Propellyr Decoder Engine decodes the log event’s “topics” and “data” information using the ABI and this is what the event reveals:

{
……
"decoded": {
"contractName": "AnyswapV4Router",
"decodedValues": {
"amount": "52858961906",
"from": "0xd545F4E3f42F5B1f5A913401CEd078E7D55fB4cF",
"fromChainID": "1",
"to": "0xEc812A6b4BcD47aa66E3DeD01CD945CCdcF2Df8d",
"toChainID": "56",
"token": "0x22648C12acD87912EA1710357B1302c6a4154Ebc"
},
"entrySignature": "LogAnySwapOut(address,address,address,uint256,uint256,uint256)",
……
}