> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mpcvault.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Soroban Interactions

> Submit Soroban contract calls for MPCVault signing and automatic broadcast.

## 1. Build and simulate the contract call

Use an activated MPCVault wallet with XLM for fees and a deployed Mainnet counter contract exposing `increment()`. This example requires only source-account authorization.

Using [Stellar JavaScript SDK 17.x](https://github.com/stellar/js-stellar-sdk/releases/tag/v17.0.0), build an `invokeHostFunction` operation and prepare the unsigned transaction:

```javascript theme={null}
import {
  BASE_FEE, Contract, Networks, TransactionBuilder, rpc,
} from "@stellar/stellar-sdk";

const server = new rpc.Server("<STELLAR_MAINNET_RPC_URL>");
const source = await server.getAccount("<YOUR_STELLAR_ADDRESS>");
const transaction = new TransactionBuilder(source, {
  fee: BASE_FEE,
  networkPassphrase: Networks.PUBLIC,
})
  .addOperation(new Contract("<COUNTER_CONTRACT_ID>").call("increment"))
  .setTimeout(300)
  .build();

const prepared = await server.prepareTransaction(transaction);
const txBase64 = prepared.toXdr();
```

[`prepareTransaction`](https://stellar.github.io/js-stellar-sdk/reference/network-rpc/) simulates the call and applies the returned authorization, resource data and fees. [`toXdr()`](https://stellar.github.io/js-stellar-sdk/reference/core-transactions/) returns the unsigned base64 envelope. Use `txBase64` as `<PREPARED_UNSIGNED_TRANSACTION_BASE64>` below; MPCVault performs signing and broadcast.

The MPCVault [Resimulation](https://docs.mpcvault.com/api-reference/rest/resimulation.md) endpoint currently returns no simulation for Soroban requests submitted through `stellarSendCustom`.

Resolve simulation errors before submission. Archived contract data may require a `RestoreFootprint` transaction through the same custom signing flow; confirm it, then rebuild and simulate the original call.

## 2. Create a signing request

[CreateSigningRequest](https://docs.mpcvault.com/api-reference/rest/create-signing-request.md)

```bash theme={null}
curl -X POST https://api.mpcvault.com/v1/createSigningRequest \
  -H "Content-Type: application/json" \
  -H "x-mtoken: <API_TOKEN>" \
  -d '{
    "vaultUuid": "<VAULT_UUID>",
    "callbackClientSignerPublicKey": "<CLIENT_SIGNER_OPENSSH_PUBLIC_KEY>",
    "broadcastTx": true,
    "stellarSendCustom": {
      "from": "<YOUR_STELLAR_ADDRESS>",
      "txBase64": "<PREPARED_UNSIGNED_TRANSACTION_BASE64>"
    }
  }'
```

`txBase64` is the standard base64-encoded XDR envelope. `from` selects the MPCVault wallet that signs it. Save the response's `signingRequest.uuid` for execution.

## 3. Sign and track

Review the payload with [GetSigningRequestDetails](https://docs.mpcvault.com/api-reference/overview.md#review-the-request), then [sign the request](https://docs.mpcvault.com/api-reference/overview.md#sign-the-request). MPCVault signs and broadcasts the transaction.

Confirm the returned `txHash` with [Stellar RPC](https://docs.mpcvault.com/api-reference/stellar/quickstart#confirm-a-transaction). `SUCCESS` confirms on-chain execution.

If the sequence or validity window is stale, rebuild and simulate the transaction before creating a new signing request. If `ExecuteSigningRequests` times out, [check the existing request](https://docs.mpcvault.com/api-reference/overview.md#track-the-result) and its transaction hash before resubmitting.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.