contractCall

suspend fun contractCall(target: String, targetFn: String, targetArgs: List<SCValXdr> = emptyList(), forceMethod: SubmissionMethod? = null, resolveContextRuleIds: ResolveContextRuleIds? = null): TransactionResult

Calls an arbitrary function on an external contract directly from the smart account.

Builds a host function that invokes target.targetFn(targetArgs) directly (not through the smart account's execute() entry point). The smart account authorizes the call via require_auth triggered by the target contract. Context rules of type CallContract(target) are matched for authorization.

Use this for any external contract interaction (e.g., token approve, token transfer, DeFi protocol calls) where the smart account is the authorized party.

For the multi-signer equivalent, see OZMultiSignerManager.multiSignerContractCall.

Return

TransactionResult indicating success or failure.

Parameters

target

The contract address (C-address) to call.

targetFn

The function name to invoke on the target contract.

targetArgs

Pre-encoded SCVal arguments for the function.

forceMethod

Optional override to force relayer or RPC submission.

resolveContextRuleIds

Optional callback to resolve context rule IDs per auth entry.

Throws

if validation fails, simulation fails, or submission fails.