Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msg.data, calldataload, calldatasize not available in constructor but no error in compiler #15585

Open
3esmit opened this issue Nov 22, 2024 · 0 comments
Labels

Comments

@3esmit
Copy link
Contributor

3esmit commented Nov 22, 2024

Description

constructor() is a different type of method, which dont have calldata.

When using msg.data on constructor, or equivalents in Yul, the result would be null. Although, no errors are presented by compiler.

contract A  {

    event Log(bytes data, uint size);
    bytes public b;
    uint public size;
    constructor (uint256 value) 
    {
        uint s;
        assembly {
            s := calldatasize()
        }
        emit Log(msg.data, s);
        b = msg.data;
        size = s;
    }
}

Logs:

[
	{
		"from": "0x8207D032322052AfB9Bf1463aF87fd0c0097EDDE",
		"topic": "0x2c3af94f3304a9c884c0e74503327fb15ee45c874e155fd13b4d1f9ba9fb8857",
		"event": "Log",
		"args": {
			"0": "0x",
			"1": "0",
			"data": "0x",
			"size": "0"
		}
	}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant