I'd want to have:
- original types
- --> encode them in bytes
- --> string those bytes all together or as an array
[[address, address], [uint, uint], [other_type, other_type],...]
- --> convert to hex
- --> call smart contract
In the contract's called function - I'd then:
- --> decode from hex to bytes
- --> split the bytes accordingly to user's intent, then convert them to original types
Is that possible at all? The calldata's length's not fixed, but dynamic. I can see two approaches:
a) Can calldata be decoded from hex to bytes then split:
calldata
as hex ->calldata
as bytescalldata[0]
would then be eg.address[]
type as bytes,calldata[1]
could be other types and so on
b) if not, can I just mash all the bytes of different types together, convert it to hex, and then decode them simply by index in smart contract?
Not sure how to test that myself, I'm getting some strange results at the first small steps: [Remix IDE]
contract test {
function foo(bytes calldata _data) external view returns (uint256) {
uint256 x = uint256(bytes32(_data));
return x;
}
}
When called with 0x05
result is:
0:
uint256: 2261564242916331941866620800950935700259179388000792266395655937654553313280
I've checked out various calculators and converters on the web and they seem to differ from this or one another (don't know enough, but I'm pretty sure 0x05 is not that thing above?).