Transactions are encoded based on the Contract ABI Specification. It is hard to get through, but these docs have all the answers to your question.
The transaction in question is passing in two parameters: a dynamic string (name
) and a static bool (isFirst
). When encoding the parameters, the EVM looks to see if the parameters are static or dynamic.
Static parameters are encoded in a fairly straightforward manner--they are converted to their hex representation and then concatenated into the input data hex string.
Dynamic values are more interesting. Use this section of the docs to fully understand, but the idea is that the encoded data is the location of the data. The encoded data itself is then concatenated to the end of the input data hex string, after all of the dynamic types. For dynamic types, the length of the parameter is then included, followed by the data itself.
Breaking down the transaction you posted:
0x1a38772000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000974657374206e616d650000000000000000000000000000000000000000000000
0x1a38772
This is the method ID of the function called (in this case, testFunc(string, bool)
)
0000000000000000000000000000000000000000000000000000000000000040
This is the location of the first (dynamic) parameter. This is the location where name
lives, but is not the data itself.
0000000000000000000000000000000000000000000000000000000000000001
This is the isFirst
parameter that was sent with the transaction. 1
is equivalent to true
.
0000000000000000000000000000000000000000000000000000000000000009
This is the length of the dynamic name
. In this case, the string has 9 characters.
74657374206e616d650000000000000000000000000000000000000000000000
The hex representation of the ASCII for "test name".