CreateContractFromExternalRefHostFunction
extends HostFunction
in package
Represents a Soroban host function for creating contracts from a CAP-85 external executable reference
From Protocol 28 on, a contract can be created without naming a wasm hash directly. The executable instead names an owner contract and a tag; the owner holds a persistent contract data entry under that tag whose value is the 32-byte hash of an already uploaded wasm, and the created instance runs that code.
The executable owner must be a contract address — only a contract can hold the executable tag entry. The constructor, setExecutableOwner(), and toXdr() reject any other address type.
Usage:
$hostFunction = new CreateContractFromExternalRefHostFunction(
Address::fromAccountId("GABC..."), // Deployer address
Address::fromContractId($ownerId), // Contract holding the executable tag entry
"token-v1", // Tag of the entry on the owner
$salt // Optional salt
);
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructs a new CreateContractFromExternalRefHostFunction
- fromXdr() : HostFunction
- Creates a HostFunction from XDR format
- getAddress() : Address
- getExecutableOwner() : Address
- getSalt() : string
- getTag() : string
- setAddress() : void
- setExecutableOwner() : void
- setSalt() : void
- setTag() : void
- toXdr() : XdrHostFunction
- Converts the host function to XDR format
Properties
$address
public
Address
$address
The deployer address
$executableOwner
public
Address
$executableOwner
The contract holding the executable tag entry the instance runs
$salt
public
string
$salt
The salt value for contract address generation
$tag
public
string
$tag
The tag the owner holds the executable entry under
Methods
__construct()
Constructs a new CreateContractFromExternalRefHostFunction
public
__construct(Address $address, Address $executableOwner, string $tag[, string|null $salt = null ]) : mixed
Parameters
- $address : Address
-
The deployer address
- $executableOwner : Address
-
The contract holding the executable tag entry
- $tag : string
-
The tag of the executable entry on the owner; matched byte for byte
- $salt : string|null = null
-
Optional salt (32 random bytes generated if not provided)
Tags
fromXdr()
Creates a HostFunction from XDR format
public
static fromXdr(XdrHostFunction $xdr) : HostFunction
Parameters
- $xdr : XdrHostFunction
-
The XDR host function
Tags
Return values
HostFunction —The decoded host function instance
getAddress()
public
getAddress() : Address
Return values
AddressgetExecutableOwner()
public
getExecutableOwner() : Address
Return values
AddressgetSalt()
public
getSalt() : string
Return values
stringgetTag()
public
getTag() : string
Return values
stringsetAddress()
public
setAddress(Address $address) : void
Parameters
- $address : Address
setExecutableOwner()
public
setExecutableOwner(Address $executableOwner) : void
Parameters
- $executableOwner : Address
Tags
setSalt()
public
setSalt(string $salt) : void
Parameters
- $salt : string
setTag()
public
setTag(string $tag) : void
Parameters
- $tag : string
toXdr()
Converts the host function to XDR format
public
toXdr() : XdrHostFunction
Tags
Return values
XdrHostFunction —The XDR representation