1

For example I have a contract that has the following bytecode 0x433d52593df3 (contract that returns the current block number if called). How could I call such a contract?

1
  • Elaborate your question a little bit. How did the bytes 0x433d52593df3 come about, or from where?
    – dwardu
    Commented May 31, 2022 at 13:15

1 Answer 1

2

Yes, you can; send a standard transaction to it.

Solidity compiles functions/methods into a custom switch/case pattern applied to the calldata sent to the smart contract with the tx. Following that rule is not mandatory, just a best practice.

If you want to experiment your functionless smart contract using Solidity/Yul, you can start with something like this:

// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;

contract ReturnBlockNumber {
    fallback() external {
        assembly {
            mstore(0x0, number())
            return(0x0, 32)
        }
    }
}

You can also use Remix to call that contract, check the Low Level Interaction panel.

Side note about 0x433d52593df3: really clever use of 3d instead of 6000 ;)

0

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.