Stellar PHP SDK API Documentation

InvokeContractHostFunction extends HostFunction
in package

Represents a Soroban smart contract invocation host function

This host function type is used to invoke functions on deployed Soroban smart contracts. It specifies the contract to call, the function name, and any arguments to pass to the function.

The contract ID can be provided in various formats including hex contract ID, StrKey-encoded contract ID, or other address types that can be converted using Address::fromAnyId().

Usage: // Invoke a contract function without arguments $hostFunction = new InvokeContractHostFunction( "CCFIFQ...", // Contract ID "transfer" // Function name );

// Invoke a contract function with arguments $hostFunction = new InvokeContractHostFunction( "CCFIFQ...", "transfer", [XdrSCVal::forAddress($fromAddr), XdrSCVal::forAddress($toAddr), XdrSCVal::forU64(1000)] );

Tags
see
HostFunction

Base class for all host functions

see
Address

For address conversion utilities

see
https://developers.stellar.org

Stellar developer docs

since
1.0.0

Table of Contents

Properties

$arguments  : array<string|int, XdrSCVal>|null
$contractId  : string
$functionName  : string

Methods

__construct()  : mixed
Constructs a new InvokeContractHostFunction
fromXdr()  : InvokeContractHostFunction
Creates an InvokeContractHostFunction from XDR format
getArguments()  : array<string|int, XdrSCVal>|null
Gets the function arguments
getContractId()  : string
Gets the contract ID
getFunctionName()  : string
Gets the function name
setArguments()  : void
Sets the function arguments
setContractId()  : void
Sets the contract ID
setFunctionName()  : void
Sets the function name
toXdr()  : XdrHostFunction
Converts the invoke contract host function to XDR format

Properties

$contractId

public string $contractId

Can be any type that can be converted to an address. E.g. hex contract id, StrKey contract id, hex claimable balance id, StrKey claimable balance id, etc. Use Address::fromAnyId($contractId) to get the exact type.

Methods

__construct()

Constructs a new InvokeContractHostFunction

public __construct(string $contractId, string $functionName[, array<string|int, XdrSCVal>|null $arguments = null ]) : mixed
Parameters
$contractId : string

The contract ID (can be hex or StrKey-encoded)

$functionName : string

The name of the function to invoke

$arguments : array<string|int, XdrSCVal>|null = null

Optional array of function arguments

getArguments()

Gets the function arguments

public getArguments() : array<string|int, XdrSCVal>|null
Return values
array<string|int, XdrSCVal>|null

The array of Soroban values, or null if no arguments

getFunctionName()

Gets the function name

public getFunctionName() : string
Return values
string

The function name

setArguments()

Sets the function arguments

public setArguments(array<string|int, XdrSCVal>|null $arguments) : void
Parameters
$arguments : array<string|int, XdrSCVal>|null

The array of Soroban values, or null for no arguments

setContractId()

Sets the contract ID

public setContractId(string $contractId) : void
Parameters
$contractId : string

The contract ID

setFunctionName()

Sets the function name

public setFunctionName(string $functionName) : void
Parameters
$functionName : string

The function name


        
On this page

Search results