setcode

SystemService::SetCode

struct SystemService::SetCode {
    const psibase::AccountNumber service;      // "setcode"
    const uint64_t               serviceFlags; // Flags this service must run with

    init(...);          
    setCode(...);       // This action is called in order to upload compiled service code to the chain
    stageCode(...);     // This action is called in order to upload compiled service code to the chain
    unstageCode(...);   // Removes previously staged code.
    setCodeStaged(...); // Loads compiled service code that was previously uploaded by stageCode
    setFlags(...);      // Sets the flags that a particular service must be run with
    verifySeq(...);     // Returns a sequence number that is incremented whenever the verify services change.
};

All compiled code is uploaded to the chain through this service.

SystemService::SetCode::init

void SystemService::SetCode::init();

SystemService::SetCode::setCode

void SystemService::SetCode::setCode(
    psibase::AccountNumber service,
    uint8_t                vmType,
    uint8_t                vmVersion,
    std::vector<char>      code
);

This action is called in order to upload compiled service code to the chain.

Uploaded code is automatically uploaded to the account that calls the action.

  • service - Must match the sender account
  • vmType - Specifies the type of the WebAssembly VM. Currently must be equal to 0.
  • vmVersion - Specifies the version of the WebAssembly VM. Currently must be equal to 0.
  • code - A byte array containing the compiled code to upload

SystemService::SetCode::stageCode

void SystemService::SetCode::stageCode(
    psibase::AccountNumber service,
    std::uint64_t          id,
    std::uint8_t           vmType,
    std::uint8_t           vmVersion,
    std::vector<char>      code
);

This action is called in order to upload compiled service code to the chain.

The uploaded code will not take effect until the service calls setCodeStaged.

  • service - The service account that the code is intended for. This account is not required to exists when stageCode is called.
  • id - A unique id chosen by the sender.
  • vmType - Specifies the type of the WebAssembly VM. Currently must be equal to 0.
  • vmVersion - Specifies the version of the WebAssembly VM. Currently must be equal to 0.
  • code - A byte array containing the compiled code to upload

SystemService::SetCode::unstageCode

void SystemService::SetCode::unstageCode(
    psibase::AccountNumber service,
    std::uint64_t          id
);

Removes previously staged code..

SystemService::SetCode::setCodeStaged

void SystemService::SetCode::setCodeStaged(
    psibase::AccountNumber from,
    std::uint64_t          id,
    std::uint8_t           vmType,
    std::uint8_t           vmVersion,
    psibase::Checksum256   codeHash
);

Loads compiled service code that was previously uploaded by stageCode.

  • from - The account that staged the code
  • id - The id that was passed to stageCode
  • vmType - Specifies the type of the WebAssembly VM. Currently must be equal to 0.
  • vmVersion - Specifies the version of the WebAssembly VM. Currently must be equal to 0.
  • codeHash - SHA256 of the compiled code

SystemService::SetCode::setFlags

void SystemService::SetCode::setFlags(
    psibase::AccountNumber service,
    uint64_t               flags
);

Sets the flags that a particular service must be run with.

SystemService::SetCode::verifySeq

std::uint64_t SystemService::SetCode::verifySeq();

Returns a sequence number that is incremented whenever the verify services change..