Stellar PHP SDK API Documentation

CreateContractFromExternalRefWithConstructorHostFunction extends HostFunction
in package

Represents a Soroban host function for creating contracts from a CAP-85 external executable reference, passing constructor arguments

Combines CreateContractFromExternalRefHostFunction with constructor initialization: the executable names an owner contract and a tag whose persistent entry holds the wasm hash, and the constructor arguments are passed to the created instance during deployment.

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: $args = [XdrSCVal::forSymbol("admin"), XdrSCVal::forAddress($adminAddress)];

$hostFunction = new CreateContractFromExternalRefWithConstructorHostFunction( Address::fromAccountId("GABC..."), // Deployer address Address::fromContractId($ownerId), // Contract holding the executable tag entry "token-v1", // Tag of the entry on the owner $args, // Constructor arguments $salt // Optional salt );

Tags
see
HostFunction

Base class for all host functions

CreateContractFromExternalRefHostFunction

For contracts without constructor arguments

CreateContractWithConstructorHostFunction

For the wasm hash form

https://developers.stellar.org

Stellar developer docs

since
1.13.0

Table of Contents

Properties

$address  : Address
$constructorArgs  : array<string|int, XdrSCVal>
$executableOwner  : Address
$salt  : string
$tag  : string

Methods

__construct()  : mixed
Constructs a new CreateContractFromExternalRefWithConstructorHostFunction
fromXdr()  : HostFunction
Creates a HostFunction from XDR format
getAddress()  : Address
getConstructorArgs()  : array<string|int, XdrSCVal>
getExecutableOwner()  : Address
getSalt()  : string
getTag()  : string
setAddress()  : void
setConstructorArgs()  : void
setExecutableOwner()  : void
setSalt()  : void
setTag()  : void
toXdr()  : XdrHostFunction
Converts the host function to XDR format

Properties

Methods

__construct()

Constructs a new CreateContractFromExternalRefWithConstructorHostFunction

public __construct(Address $address, Address $executableOwner, string $tag, array<string|int, XdrSCVal$constructorArgs[, 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

$constructorArgs : array<string|int, XdrSCVal>

The constructor arguments

$salt : string|null = null

Optional salt (32 random bytes generated if not provided)

Tags
throws
InvalidArgumentException

If the executable owner is not a contract address

Exception

If random bytes generation fails

On this page

Search results