Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

Support msg.data in host calls #321

Description

@clearloop

in the implementation of #297, we found that reading the complete call data could be complex: CALLDATA -> memory -> stack, for templates of implementing this (with return but not writing it on stack):

// load the complete call data to memory
PUSH0                   // from 0
PUSH0                   // from 0
CALLDATASIZE     // to size
CALDATALOAD     // calldataload(dest_mem_offset: 0, offest: 0, size: size)

// return the selected memory
PUSH0
CALLDATASIZE
RETURN

considering about the memory pointer:

MSIZE // first we get the memory size as the start pointer for the memory allocation
PUSH0 // to get the complete calldata, we start form offset 0
CALLDATASIZE // complete calldata
CALLDATALOAD // load the calldata to memory

// now we return the calldata
MSIZE
CALLDATASIZE
SUB
CALLDATASIZE
RETURN

for the real implementation, we might need to write the calldata on stack, need to do sort of research on it, mb learn from solidity or huff!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions