Skip to content

Create chapter about how to instantiate contracts #70

@athei

Description

@athei

The instantiation works different on out platform than on Eth. That is probably the biggest difference people will experience early on. We documented this behaviour but it is not enough. We need concrete examples of instantiation patterns that don't work and what to do instead. The good news is that contract instantiation is easier and more efficient on our platform without the need to drop down to assembly.

Topics we need to cover:

  • Tell people not to use create or create2 directly. Instead use the new keyword. Use it with the salt parameter if create2 is needed.
  • IF THEY REALLY NEED TO USE ASSEMBLY (i dont know why they would though): How to properly use create2: Wrong output for creationCode contract-issues#45. Including the differences in .creationCode which get relevant then.
  • Always mention that the code has to be uploaded before and explain how this is better since we are not bundling huge amounts of code into a contract which limits the size the deployee could have.
  • Cover use cases where creation code is generated on the fly (stitching it together from runtime code). Mention how this is not necessary due to on-chain constructors.
  • Explain how to compute the address of the new contract on chain (difference in .creationCode). I am not sure why this is necessary though. To be it seems that predicting the address is something you want to do off-chain.

cc @xermicus @Jan-Jan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions