question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Questions about JSON output

See original GitHub issue

When I print out the result from Mythril in JSON and I look at the tx_sequence, there are attributes named address, calldata , origin and input, and value, would you please explain the differences among these attributes or pointers to the documentation where I can find the definitions of these attributes?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:30

github_iconTop GitHub Comments

1reaction
norhhcommented, Jul 15, 2022

For types, the first type of calldata are static types such as the uint, bool .. etc types. These have fixed 32 bytes width, the other classes are dynamic types such as bytes, array[] ... these point to some corresponding location in the calldata in it’s corresponding initial location (in this case the location that it points to is 0x0000000.....20). So you’ll have to extend the calldata to the corresponding location in some cases. In some cases mythril might generate a calldata that the program can run, but it’s not possible to directly decode it since it’s considered invalid by abi programs, like in this case (although you can execute the program with such an input, the abi programs such as eth-abi consider them as invalid). It’s invalid here because 0x20 points to a location less than 96 bytes or 192nd location in hex.

1reaction
norhhcommented, Jul 13, 2022

Oops, let me make a correction and be a bit more precise.

If you see a calldata as 0x4a6781a901 here the first 4 bytes are function signature, which is 0x4a6781a9. The next set of 32 bytes are the arguments, if there are two arguments of uint256, uint256 for this function, then the following is true.

function signature:- 0x4a6781a9 as these are the first 4 bytes. first uint256:- the remaining calldata left is only a single byte valued as 01, so you’ll have to append it with 0s to make it 32 bytes, hence it will be 0100000000000000000000000000000000000000000000000000000000000000 the second uint256:- since the remaining calldata is empty now, the second uint is 0000000000000000000000000000000000000000000000000000000000000000 which is 0.

All these arguments are in hex, you’ll have to convert them to uint.

For the following error that you encountered you can see that it expected 32 bytes for the second argument, but it only got a single byte, you’ll need to append 31 bytes of 0s which is 62 zeros to correct the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 19 JSON Interview Questions and Answers (2022)
1) Mention what is JSON? 2) Explain what is JSON objects? 3) Explain how to transform JSON text to a JavaScript object? 4)...
Read more >
16 JSON Interview Questions You Must Be Prepared For
16 JSON Interview Questions You Must Be Prepared For · Q1: What is JSON and why would I use it? · Q2: How...
Read more >
Top JSON Interview Questions and Answers
This JSON Interview Questions tutorial includes a list of all the frequently asked questions related to JSON. We hope that this tutorial ...
Read more >
33 JSON Interview Questions (Plus Tips) - Indeed
JSON interview questions with sample answers · 1. What other programming languages integrate with JSON? · 2. What is Newtonsoft as it pertains...
Read more >
Json Interview Questions and Answers - myTectra
Json Interview Questions and Answers · Q1. What is the full form of JSON? · Q3. What is JSON used for? · Q4....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found