HostFunction
in package
Abstract base class for Soroban smart contract host functions
Host functions enable interaction with Soroban smart contracts on the Stellar network. This abstract class defines the interface for all host function types including contract invocation, deployment, and WASM upload operations.
Host Function Types:
- InvokeContractHostFunction: Call smart contract functions
- CreateContractHostFunction: Deploy contracts from WASM hash
- CreateContractWithConstructorHostFunction: Deploy contracts with constructor arguments
- UploadContractWasmHostFunction: Upload contract WASM code
- DeploySACWithAssetHostFunction: Deploy Stellar Asset Contracts for assets
- DeploySACWithSourceAccountHostFunction: Deploy Stellar Asset Contracts with source account
Usage:
// Invoke a contract function
$hostFunction = new InvokeContractHostFunction($contractId, $functionName, $args);
// Upload WASM code $hostFunction = new UploadContractWasmHostFunction($wasmBytes);
// Deploy a contract $hostFunction = new CreateContractHostFunction($wasmId, $address);
Tags
Table of Contents
Methods
- __construct() : mixed
- Constructs a new HostFunction instance
- fromXdr() : HostFunction
- Creates a HostFunction from XDR format
- toXdr() : XdrHostFunction
- Converts the host function to XDR format
Methods
__construct()
Constructs a new HostFunction instance
public
__construct() : mixed
fromXdr()
Creates a HostFunction from XDR format
public
abstract static fromXdr(XdrHostFunction $xdr) : HostFunction
Parameters
- $xdr : XdrHostFunction
-
The XDR host function
Return values
HostFunction —The decoded host function instance
toXdr()
Converts the host function to XDR format
public
abstract toXdr() : XdrHostFunction
Return values
XdrHostFunction —The XDR representation