How to decode timelock

getUnrekt
Coinmonks
4 min readDec 24, 2020

--

It’s been a few weeks since we started publishing and keeping logs on Acryptos.com timelock. Many are still confused about how our parser and the underlying smart contract decodes such transactions.

In response to various requests, here’s a detailed ‘howto’ that should decode most of the timelock transactions within the various EVM compatible chains (Ethereum, Binance Smart Chain for example)

We take this sample transaction as an example :

Types of Timelock transaction

These are the 2 common transactions :

  • queueTransaction()
  • executeTransaction()

As executeTransaction() actions previously queued requests, we are only interested in the queueTransaction().

sample queueTransaction().

Decoding queueTransaction()

The decoded queueTransaction() split the Input Data into the following:

We’re interested in the following field :

target: 96c8390ba28eb083a784280227c37b853bc408b7

(which is ACSI Farm Contract)

data: 64482f79000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000000

Decoding data field

  1. Identify the function call

Take the first 8 hexadecimal number of the data and look up at such lookup database like 4bytes.directory, which covers 95% of the function signatures. (I’ve my own method for those odd ball, complicated)

https://www.4byte.directory/signatures/?bytes4_signature=64482f79

the lookup decodes the function to :

set(uint256, uint256, bool)

which takes 3 inputs.

2. Split the inputs

Split the data to the following :

64482f79
0000000000000000000000000000000000000000000000000000000000000002
00000000000000000000000000000000000000000000000000000000000001f4
0000000000000000000000000000000000000000000000000000000000000000

which translates to

input 1: 0000000000000000000000000000000000000000000000000000000000000002

input 2:

00000000000000000000000000000000000000000000000000000000000001f4

input 3:

0000000000000000000000000000000000000000000000000000000000000000

3. Convert the inputs from hexadecimal to decimal

https://www.binaryhexconverter.com/hex-to-decimal-converter

input 1: 2

input 2: 500

input 3: 0

4. Interpret the function

The set function now reads

set(2, 500, 0)

which from the ACSI Farm Contract we get to know that this action involved setting the pool weight for pid=2 with 500 allocPoint

(500 allocPoints means 500/100 = 5x)

https://bscscan.com/address/0x96c8390ba28eb083a784280227c37b853bc408b7#writeContract (DO NOT CLICK WRITE!!)

5. Identify pool id 2

Use the ACSI Farm Contract (read contract), use item 12. poolinfo to query for pool id 2.

From there we found pool2 = 0xEb7Dc7b3bfF60A450EfF31Edf1330355361EA5ad

which is ACS4VAI

6. Decoded

We have decoded the timelock to read

set(ACS4VAI pool, 5x, 0)

which determines that the timelock action is to change the pool ACS4VAI to 5x multiplier for farm reward.

Exceptions

There are exceptions that might hinder your decoding process:

  • New functions yet to be populated within 4bytes directory
  • function name clashes within 4bytes directory, means only the first one get recorded

for example:

set(uint256, uint256, bool) vs

set(uint256, uint256, uint256)

Also, Read

Get Best Software Deals Directly In Your Inbox

--

--

Coinmonks
Coinmonks

Published in Coinmonks

Coinmonks is a non-profit Crypto Educational Publication.

getUnrekt
getUnrekt

Written by getUnrekt

https://unrekt.net — Ethereum and BSC Smart Contract approval toolbox

No responses yet