Skip to content

VIP: add new built-in function raw_create #3710

@pcaversaccio

Description

@pcaversaccio

Simple Summary

Expose the opcodes CREATE and CREATE2 via a new built-in function raw_create.

Motivation

Example use case: use Vyper to build generic contract factories.

Specification

raw_create(init_code: Bytes, *args, value: uint256 = 0, raw_args: bool = False, revert_on_failure: bool = True, [, salt: bytes32]) -> address
  • init_code: Contains the contract creation code. Can already entail the ABI-encoded and appended constructor arguments.
  • *args: Constructor arguments to be appended to init_code. If raw_args = False (default), the arguments are ABI-encoded according to their types. If raw_args = True, *args must be a single Bytes argument which is directly appended to init_code. (Optional, default to "").
  • value: The wei value to send during contract creation. Note that if value is non-zero, init_code must have a payable constructor. (Optional, default to 0).
  • raw_args: If True, *args must be a single Bytes argument which is directly appended to init_code. Alternatively, you can also use concat in combination with the contract creation bytecode. (Optional, default False).
  • revert_on_failure: Reverts if the new contract address is equal to empty(address) or is a zero-byte contract. (Optional, default True).
  • salt: A bytes32 value utilised by the deterministic CREATE2 opcode (Optional, if not supplied, CREATE is used).

Backwards Compatibility

raw_create is a new built-in function that is not backward-compatible.

Dependencies

N/A.

References

N/A.

Copyright

Copyright and related rights waived via CC0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions