Stellar PHP SDK API Documentation

UploadContractWasmHostFunction extends HostFunction
in package

Represents a Soroban host function for uploading contract WASM code

This host function uploads WebAssembly (WASM) bytecode to the Stellar network, making it available for contract deployment. The uploaded WASM is stored on the ledger and can be referenced by its hash (WASM ID) when deploying contract instances.

The upload process:

  1. Upload WASM code using this host function
  2. Receive WASM ID (hash) from the transaction result
  3. Use WASM ID to deploy contract instances via CreateContractHostFunction

Usage: // Read WASM file $wasmBytes = file_get_contents('contract.wasm');

// Create upload host function $hostFunction = new UploadContractWasmHostFunction($wasmBytes);

// Use in an InvokeHostFunctionOperation $operation = (new InvokeHostFunctionOperationBuilder($hostFunction))->build();

Tags
see
HostFunction

Base class for all host functions

see
CreateContractHostFunction

For deploying contracts from uploaded WASM

see
https://developers.stellar.org

Stellar developer docs

since
1.0.0

Table of Contents

Properties

$contractCodeBytes  : string|null

Methods

__construct()  : mixed
Constructs a new UploadContractWasmHostFunction
fromXdr()  : UploadContractWasmHostFunction
Creates an UploadContractWasmHostFunction from XDR format
getContractCodeBytes()  : string|null
Gets the contract WASM bytecode
setContractCodeBytes()  : void
Sets the contract WASM bytecode
toXdr()  : XdrHostFunction
Converts the upload WASM host function to XDR format

Properties

Methods

__construct()

Constructs a new UploadContractWasmHostFunction

public __construct(string|null $contractCodeBytes) : mixed
Parameters
$contractCodeBytes : string|null

The WASM bytecode as a binary string

getContractCodeBytes()

Gets the contract WASM bytecode

public getContractCodeBytes() : string|null
Return values
string|null

The WASM bytecode as a binary string

setContractCodeBytes()

Sets the contract WASM bytecode

public setContractCodeBytes(string|null $contractCodeBytes) : void
Parameters
$contractCodeBytes : string|null

The WASM bytecode as a binary string


        
On this page

Search results