CreateContractHostFunction
extends HostFunction
in package
Represents a Soroban host function for creating smart contracts
This host function deploys a new smart contract instance from previously uploaded WASM code. The contract is identified by the WASM ID (hash of the uploaded code), a deployer address, and a salt value for uniqueness.
The contract address is deterministically generated from:
- The deployer address (typically the source account or contract)
- The WASM ID (hash of the contract code)
- A salt value (random or specified for reproducibility)
Usage:
// Deploy a contract from uploaded WASM
$hostFunction = new CreateContractHostFunction(
Address::fromAccountId("GABC..."), // Deployer address
$wasmId, // WASM hash from upload
$salt // Optional salt (generated if not provided)
);
// Use in an InvokeHostFunctionOperation $operation = (new InvokeHostFunctionOperationBuilder($hostFunction))->build();
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructs a new CreateContractHostFunction
- fromXdr() : CreateContractHostFunction
- Creates a CreateContractHostFunction from XDR format
- getAddress() : Address
- Gets the deployer address
- getSalt() : string
- Gets the salt value
- getWasmId() : string
- Gets the WASM ID
- setAddress() : void
- Sets the deployer address
- setSalt() : void
- Sets the salt value
- setWasmId() : void
- Sets the WASM ID
- toXdr() : XdrHostFunction
- Converts the create contract host function to XDR format
Properties
$address
public
Address
$address
The deployer address
$salt
public
string
$salt
The salt value for contract address generation
$wasmId
public
string
$wasmId
The WASM ID (hash of the uploaded contract code)
Methods
__construct()
Constructs a new CreateContractHostFunction
public
__construct(Address $address, string $wasmId[, string|null $salt = null ]) : mixed
Parameters
- $address : Address
-
The deployer address
- $wasmId : string
-
The WASM ID (hash of uploaded contract code)
- $salt : string|null = null
-
Optional salt (32 random bytes generated if not provided)
Tags
fromXdr()
Creates a CreateContractHostFunction from XDR format
public
static fromXdr(XdrHostFunction $xdr) : CreateContractHostFunction
Parameters
- $xdr : XdrHostFunction
-
The XDR host function
Tags
Return values
CreateContractHostFunction —The decoded host function
getAddress()
Gets the deployer address
public
getAddress() : Address
Return values
Address —The deployer address
getSalt()
Gets the salt value
public
getSalt() : string
Return values
string —The salt value for contract address generation
getWasmId()
Gets the WASM ID
public
getWasmId() : string
Return values
string —The WASM ID (hash of uploaded contract code)
setAddress()
Sets the deployer address
public
setAddress(Address $address) : void
Parameters
- $address : Address
-
The deployer address
setSalt()
Sets the salt value
public
setSalt(string $salt) : void
Parameters
- $salt : string
-
The salt value for contract address generation
setWasmId()
Sets the WASM ID
public
setWasmId(string $wasmId) : void
Parameters
- $wasmId : string
-
The WASM ID (hash of uploaded contract code)
toXdr()
Converts the create contract host function to XDR format
public
toXdr() : XdrHostFunction
Return values
XdrHostFunction —The XDR host function