InvokeHostFunctionOperation
public class InvokeHostFunctionOperation : Operation, @unchecked Sendable
Invokes Soroban host functions for smart contract deployment, creation, and invocation operations.
-
The host function to invoke.
Declaration
Swift
public let hostFunction: HostFunctionXDR -
The authorizations required to execute the host function.
Declaration
Swift
public var auth: [SorobanAuthorizationEntryXDR] { get set } -
Creates a new invoke host function operation with specified parameters.
Declaration
Swift
public init(hostFunction: HostFunctionXDR, auth: [SorobanAuthorizationEntryXDR] = [], sourceAccountId: String? = nil) -
Creates an operation to invoke a function on a deployed smart contract.
Declaration
Swift
public static func forInvokingContract(contractId: String, functionName: String, functionArguments: [SCValXDR] = [], sourceAccountId: String? = nil, auth: [SorobanAuthorizationEntryXDR]? = nil) throws -> InvokeHostFunctionOperation -
Creates an operation to upload Wasm bytecode for contract deployment.
Declaration
Swift
public static func forUploadingContractWasm(contractCode: Data, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperation -
Creates an operation to instantiate a contract from uploaded Wasm using contract ID preimage.
Throws
StellarSDKError.invalidArgument if the wasm id is not exactly 64 hexadecimal charactersDeclaration
Swift
public static func forCreatingContract(wasmId: String, address: SCAddressXDR, salt: WrappedData32? = nil, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperationParameters
wasmIdthe 64 character hex of the 32 byte wasm hash
-
Creates an operation to instantiate a contract with constructor arguments (protocol >= 22).
Throws
StellarSDKError.invalidArgument if the wasm id is not exactly 64 hexadecimal charactersDeclaration
Swift
public static func forCreatingContractWithConstructor(wasmId: String, address: SCAddressXDR, constructorArguments: [SCValXDR] = [], salt: WrappedData32? = nil, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperationParameters
wasmIdthe 64 character hex of the 32 byte wasm hash
-
Creates an operation to instantiate a contract from a CAP-85 external reference (protocol >= 28).
The executable 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. An executable tag is an XDR string and may carry arbitrary bytes; the operation carries the given bytes unchanged.
Throws
StellarSDKError.invalidArgumentif the executable owner is not a contract addressDeclaration
Swift
public static func forCreatingContractFromExternalRef(executableOwner: SCAddressXDR, tag: Data, address: SCAddressXDR, salt: WrappedData32? = nil, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperationParameters
executableOwnerthe contract holding the executable tag entry; must be a contract address
tagthe tag of the executable entry on the owner; matched byte for byte
addressthe deployer address (account or contract)
saltoptional 32 byte salt for contract id generation; random if not provided
-
Creates an operation to instantiate a contract from a CAP-85 external reference (protocol >= 28) with a text tag. The operation carries the tag as the UTF-8 bytes of the given text; the entry is matched byte for byte against those bytes.
Throws
StellarSDKError.invalidArgumentif the executable owner is not a contract addressDeclaration
Swift
public static func forCreatingContractFromExternalRef(executableOwner: SCAddressXDR, tag: String, address: SCAddressXDR, salt: WrappedData32? = nil, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperationParameters
executableOwnerthe contract holding the executable tag entry; must be a contract address
tagthe tag of the executable entry on the owner, carried as its UTF-8 bytes
addressthe deployer address (account or contract)
saltoptional 32 byte salt for contract id generation; random if not provided
-
forCreatingContractFromExternalRefWithConstructor(executableOwner:tag: address: constructorArguments: salt: sourceAccountId: ) Creates an operation to instantiate a contract from a CAP-85 external reference with constructor arguments (protocol >= 28). An executable tag is an XDR string and may carry arbitrary bytes; the operation carries the given bytes unchanged.
Throws
StellarSDKError.invalidArgumentif the executable owner is not a contract addressDeclaration
Swift
public static func forCreatingContractFromExternalRefWithConstructor(executableOwner: SCAddressXDR, tag: Data, address: SCAddressXDR, constructorArguments: [SCValXDR] = [], salt: WrappedData32? = nil, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperationParameters
executableOwnerthe contract holding the executable tag entry; must be a contract address
tagthe tag of the executable entry on the owner; matched byte for byte
addressthe deployer address (account or contract)
constructorArgumentsarguments passed to the contract constructor
saltoptional 32 byte salt for contract id generation; random if not provided
-
forCreatingContractFromExternalRefWithConstructor(executableOwner:tag: address: constructorArguments: salt: sourceAccountId: ) Creates an operation to instantiate a contract from a CAP-85 external reference with constructor arguments (protocol >= 28) and a text tag. The operation carries the tag as the UTF-8 bytes of the given text; the entry is matched byte for byte against those bytes.
Throws
StellarSDKError.invalidArgumentif the executable owner is not a contract addressDeclaration
Swift
public static func forCreatingContractFromExternalRefWithConstructor(executableOwner: SCAddressXDR, tag: String, address: SCAddressXDR, constructorArguments: [SCValXDR] = [], salt: WrappedData32? = nil, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperationParameters
executableOwnerthe contract holding the executable tag entry; must be a contract address
tagthe tag of the executable entry on the owner, carried as its UTF-8 bytes
addressthe deployer address (account or contract)
constructorArgumentsarguments passed to the contract constructor
saltoptional 32 byte salt for contract id generation; random if not provided
-
Creates an operation to deploy a Stellar Asset Contract for a specific asset.
Declaration
Swift
public static func forDeploySACWithAsset(asset: Asset, sourceAccountId: String? = nil) throws -> InvokeHostFunctionOperation -
Creates a new InvokeHostFunctionOperation object from the given InvokeHostFunctionOpXDR object.
Declaration
Swift
public init(fromXDR: InvokeHostFunctionOpXDR, sourceAccountId: String?) throwsParameters
fromXDRthe InvokeHostFunctionOpXDR object to be used to create a new InvokeHostFunctionOperation object.
sourceAccountId(optional) source account Id, must be valid, otherwise it will be ignored.
View on GitHub
Install in Dash