invokeContractFunction

fun invokeContractFunction(contractAddress: String, functionName: String, parameters: List<SCValXdr>): InvokeHostFunctionOperation

Creates an InvokeHostFunctionOperation for invoking a specific function on a contract.

This is a convenience factory method that builds the necessary XDR structures for contract invocation.

Return

An InvokeHostFunctionOperation ready to be added to a transaction

Example

val operation = InvokeHostFunctionOperation.invokeContractFunction(
contractAddress = "CABC123...",
functionName = "transfer",
parameters = listOf(
Scv.toAddress(fromAccount),
Scv.toAddress(toAccount),
Scv.toInt128(amount)
)
)

Parameters

contractAddress

The contract address (C... format)

functionName

The name of the contract function to invoke

parameters

The function parameters as SCVal XDR values