I'm reading up on upgradable proxies, came across this in openzeppelin.

    assembly {
      // Copy msg.data. We take full control of memory in this inline assembly
      // block because it will not return to Solidity code. We overwrite the
      // Solidity scratch pad at memory position 0.
      calldatacopy(0, 0, calldatasize())

      // Call the implementation.
      // out and outsize are 0 because we don't know the size yet.
      let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

      // Copy the returned data.
      returndatacopy(0, 0, returndatasize())

      switch result
        // delegatecall returns 0 on error.
        case 0 {
          revert(0, returndatasize())
        default {
          return(0, returndatasize())

Particularly I'm curious about this line " Solidity scratch pad at memory position 0.".

I understand the gist of this statement that we are writing the 0th position in our memory data type using assembly. But what is the "solidity scratch pad"? Why is it called that and what exactly does that mean. Does it have any significance?

  • ethereum.stackexchange.com/a/139188/66634 This answer I believe also explains this. Mentions scratch space for hashing methods, and also special data being stored in the first 128 bytes of memory using solidity.
    – Bruce
    Commented Nov 10, 2022 at 23:45

1 Answer 1


A solidity scratch pad is a memory location for short term memory allocation. It is called that because it is used by proxy to write an arbitrary amount of data starting at position 0 because proxy doesn't care about overwriting allocating memory or respecting solidity memory model.



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.