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:
- Upload WASM code using this host function
- Receive WASM ID (hash) from the transaction result
- 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
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
$contractCodeBytes
public
string|null
$contractCodeBytes
= null
The WASM bytecode as a binary string
Methods
__construct()
Constructs a new UploadContractWasmHostFunction
public
__construct(string|null $contractCodeBytes) : mixed
Parameters
- $contractCodeBytes : string|null
-
The WASM bytecode as a binary string
fromXdr()
Creates an UploadContractWasmHostFunction from XDR format
public
static fromXdr(XdrHostFunction $xdr) : UploadContractWasmHostFunction
Parameters
- $xdr : XdrHostFunction
-
The XDR host function
Tags
Return values
UploadContractWasmHostFunction —The decoded host function
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
toXdr()
Converts the upload WASM host function to XDR format
public
toXdr() : XdrHostFunction
Return values
XdrHostFunction —The XDR host function