0

I didn't found any instructions about nested structs (in structs). Seen video about sending bytecode to contract and I wanted to understand.

For example, method is:

function fulfillOrder(
    Order calldata order,
    bytes32 fulfillerConduitKey
) external payable returns (bool fulfilled);

struct Order {
    OrderParameters parameters;
    bytes signature;
}

struct OrderParameters {
    address offerer; // 0x00
    address zone; // 0x20
    OfferItem[] offer; // 0x40
    ConsiderationItem[] consideration; // 0x60
    OrderType orderType; // 0x80
    uint256 startTime; // 0xa0
    uint256 endTime; // 0xc0
    bytes32 zoneHash; // 0xe0
    uint256 salt; // 0x100
    bytes32 conduitKey; // 0x120
    uint256 totalOriginalConsiderationItems; // 0x140
    // offer.length                          // 0x160
}

struct OfferItem {
    ItemType itemType;
    address token;
    uint256 identifierOrCriteria;
    uint256 startAmount;
    uint256 endAmount;
}

struct ConsiderationItem {
    ItemType itemType;
    address token;
    uint256 identifierOrCriteria;
    uint256 startAmount;
    uint256 endAmount;
    address payable recipient;
}

enum OrderType {
    FULL_OPEN,
    PARTIAL_OPEN,
    FULL_RESTRICTED,
    PARTIAL_RESTRICTED,
    CONTRACT
}
fulfillOrder(((address,address,(uint8,address,uint256,uint256,uint256)[],(uint8,address,uint256,uint256,uint256,address)[],uint8,uint256,uint256,bytes32,uint256,bytes32,uint256),bytes),bytes32)

keccak256 is b3a34c4c89989a0871b97285782de68e7db27f7d5fe738e7aa7c6f1f7118d3ac

What is code?:

0xb3a34c4c
0x00000...
0x00.. - how represent struct in arguments with nested struct in parent argument struct?
0x0000...

I've google a lot, it's didn't gave any results...

That is my analysis, I tried to understand but I don't.

0xb3a34c4c
32/0000000000000000000000000000000000000000000000000000000000000040 .*args[0] 32*2       >-- Order
64/0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000 'fulfillerConduitKey   |
96/0000000000000000000000000000000000000000000000000000000000000040 'args[0] *Order[0]    <-    >--
128/0000000000000000000000000000000000000000000000000000000000000280'-------->32*20 link SIG      | OrderParams
160/000000000000000000000000047a0ba6eab7825a854049eda6256301cf0a7056' offerer Order[0] Start cnt <-
192/0000000000000000000000000000000000000000000000000000000000000000' zone
224/0000000000000000000000000000000000000000000000000000000000000160'- *arr1 352 32*11 *OfferItem[]
256/0000000000000000000000000000000000000000000000000000000000000220'- 544 32*17
288/0000000000000000000000000000000000000000000000000000000000000000'  orderType
320/0000000000000000000000000000000000000000000000000000000000000000' FULL_OPEN OrderType - start static
352/000000000000000000000000000000000000000000000000000000006383abd0' start time //1669573584
384/0000000000000000000000000000000000000000000000000000000063ab38d0' end time //1672165584
416/0000000000000000000000000000000000000000000000000000000000000000' zoneHash
448/360c6ebe0000000000000000000000000000000000000000f69d6dec7287d948' salt
480/0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000' conduitKey
512/000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d6'* arr1 weth
544/0000000000000000000000000000000000000000000000000000000000000000'* identifierOrCriteria
576/0000000000000000000000000000000000000000000000000de0b6b3a7640000'* start amount of weth 1*10^19
608/0000000000000000000000000000000000000000000000000de0b6b3a7640000'* end amount
640/0000000000000000000000000000000000000000000000000000000000000000' 20th
672/0000000000000000000000000000000000000000000000000000000000000041 --- SIG length
704/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---
736/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   } SIG value
768/xx00000000000000000000000000000000000000000000000000000000000000 ---

Maybe code is outdated.

1 Answer 1

1

I figured it out. One rule for tuples - tuple has it own offset start, from first element (itself or offset for) of tuple. And offset in tuples counted from first tuple record including.

Well explained with examples here: https://blog.soliditylang.org/2022/08/08/calldata-tuple-reencoding-head-overflow-bug/ - it helped me.

And bytecode above was also wrong. Right code with my marks see below:

  0xb3a34c4c
  32/0000000000000000000000000000000000000000000000000000000000000040  *args[0] 32*2       >-- Order
  64/0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000  fulfillerConduitKey   |
  96/0000000000000000000000000000000000000000000000000000000000000040  args[0] *Order[0]    <-    >--
  128/0000000000000000000000000000000000000000000000000000000000000280 -------->32*20 link SIG      |  OrderParams
  160/000000000000000000000000047a0ba6eab7825a854049eda6256301cf0a7056  offerer Order[0] Start cnt <-
  192/0000000000000000000000000000000000000000000000000000000000000000  zone
  224/0000000000000000000000000000000000000000000000000000000000000160 - *arr1 352 32*11 *OfferItem[]
  256/0000000000000000000000000000000000000000000000000000000000000220 - *arr2 544 32*17 *ConsiderationItem[]
  288/0000000000000000000000000000000000000000000000000000000000000000  FULL_OPEN OrderType - start static
  320/000000000000000000000000000000000000000000000000000000006383abd0  startTime //1669573584
  352/0000000000000000000000000000000000000000000000000000000063ab38d0  endTime //1672165584
  384/0000000000000000000000000000000000000000000000000000000000000000  zoneHash
  416/360c6ebe0000000000000000000000000000000000000000f69d6dec7287d948  salt
  448/0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000  conduitKey
  480/0000000000000000000000000000000000000000000000000000000000000000  totalOriginalConsiderationItems
  512/0000000000000000000000000000000000000000000000000000000000000001 ->arr1.length
  544/0000000000000000000000000000000000000000000000000000000000000001 ->arr1.itemType
  576/000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d6 ->arr1.wethAddress (token)
  608/0000000000000000000000000000000000000000000000000000000000000000 ->arr1.identifierOrCriteria
  640/0000000000000000000000000000000000000000000000000de0b6b3a7640000 ->arr1.startAmount of weth 1*10^19
  672/0000000000000000000000000000000000000000000000000de0b6b3a7640000 ->arr1.endAmount
  704/0000000000000000000000000000000000000000000000000000000000000000 => arr2.length (0)
  736/0000000000000000000000000000000000000000000000000000000000000041 --- SIG length
  768/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---
  800/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   } SIG value
  832/xx00000000000000000000000000000000000000000000000000000000000000 ---

Maybe this will help somebody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.