pub fn upload_program<T: Config>(
    code: Vec<u8>,
    salt: Vec<u8>,
    init_payload: Vec<u8>,
    gas_limit: u64,
    value: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance,
    keep_alive: bool
)
Expand description

Creates program initialization request (message), that is scheduled to be run in the same block.

There are no guarantees that initialization message will be run in the same block due to block gas limit restrictions. For example, when it will be the message’s turn, required gas limit for it could be more than remaining block gas limit. Therefore, the message processing will be postponed until the next block.

ProgramId is computed as Blake256 hash of concatenated bytes of code + salt. (todo #512 code_hash + salt) Such ProgramId must not exist in the Program Storage at the time of this call.

There is the same guarantee here as in upload_code. That is, future program’s code and metadata are stored before message was added to the queue and processed.

The origin must be Signed and the sender must have sufficient funds to pay for gas and value (in case the latter is being transferred).

Parameters:

  • code: wasm code of a program as a byte vector.
  • salt: randomness term (a seed) to allow programs with identical code to be created independently.
  • init_payload: encoded parameters of the wasm module init function.
  • gas_limit: maximum amount of gas the program can spend before it is halted.
  • value: balance to be transferred to the program once it’s been created.

Emits the following events:

  • InitMessageEnqueued(MessageInfo) when init message is placed in the queue.

§Note

Faulty (uninitialized) programs still have a valid addresses (program ids) that can deterministically be derived on the caller’s side upfront. It means that if messages are sent to such an address, they might still linger in the queue.

In order to mitigate the risk of users’ funds being sent to an address, where a valid program should have resided, while it’s not, such “failed-to-initialize” programs are not silently deleted from the program storage but rather marked as “ghost” programs. Ghost program can be removed by their original author via an explicit call. The funds stored by a ghost program will be release to the author once the program has been removed.

§Warning: Doc-Only

This function is an automatically generated, and is doc-only, uncallable stub. See the real version in Pallet::upload_program.