> For the complete documentation index, see [llms.txt](https://docs.leather.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.leather.io/developers/stacks-methods/stx_callcontract.md).

# stx\_callContract

Wrapper method for \`stx\_signTransaction\` that calls a Stacks contract

## Method name

`stx_callContract`

The app must be connected first, through [`getAddresses`](/developers/methods/getaddresses.md). Leather builds the contract call, signs it with the account the app connected with and broadcasts it.

## Parameters

| Parameter           | Description                                                                  | Required | Type               |
| ------------------- | ---------------------------------------------------------------------------- | -------- | ------------------ |
| `contract`          | Fully qualified contract identifier, as `<contract address>.<contract name>` | ✅        | `string`           |
| `functionName`      | Name of the public function to call                                          | ✅        | `string`           |
| `functionArgs`      | Function arguments, each a hex-encoded serialized Clarity value              | ❌        | `string[]`         |
| `postConditions`    | Post-conditions, each a hex-encoded serialized post-condition                | ❌        | `string[]`         |
| `postConditionMode` | `allow`, `deny` or `originator`                                              | ❌        | `string`           |
| `network`           | Network identifier                                                           | ❌        | `string`           |
| `fee`               | Transaction fee in micro-STX. The user can change it before approving        | ❌        | `number \| string` |
| `nonce`             | Transaction nonce. The user can change it before approving                   | ❌        | `number \| string` |
| `sponsored`         | Build a sponsored transaction. Leather returns it signed, without a `txid`   | ❌        | `boolean`          |

Leather decodes `functionArgs` and shows each argument to the user before approval. Without post-conditions, the approval screen warns that the transaction can transfer any of the user's assets.

## Example request

```typescript
import { serializeCV, uintCV } from "@stacks/transactions";

try {
  // Replace with your contract and a public function it defines
  const response = await window.LeatherProvider.request("stx_callContract", {
    contract: "SP3FBR2AGK5X3Y5D0X6MYB6Z3R9Y3WNRJY9ZTV8PV.my-contract",
    functionName: "set-value",
    functionArgs: [serializeCV(uintCV(42))],
    postConditionMode: "deny",
  });

  console.log("Transaction ID:", response.result.txid);
} catch (error) {
  console.log("Request error:", error.error.code, error.error.message);
}
```

## Example response

```json
{
    "jsonrpc": "2.0",
    "id": "d5e8a7bf-2bc6-4e5e-9c4d-8a6e1d2f99eb",
    "result": {
        "txid": "9a12b3c4d5e6f7890ab1c2d3e4f567890abcdef1234567890abcdef123456789",
        "transaction": "<signed transaction hex>"
    }
}
```

## Multisig accounts

When the user connected a Stacks multisig vault (see [Multisig accounts](/developers/methods/getaddresses.md#multisig-accounts)), Leather proposes the transaction to the vault's co-signers instead of broadcasting it. The result is then `{ transaction, proposalId, status: "proposed" }`, with no `txid`. `stx_callContract` is the only Stacks method that proposes to a vault.

## Errors

| Code     | Message                                                                 | When                         |
| -------- | ----------------------------------------------------------------------- | ---------------------------- |
| `16`     | `Wallet no longer available. Reconnect the app to an available wallet.` | The origin is not connected  |
| `-32602` | Parameter validation details                                            | A parameter fails validation |
| `4001`   | `User rejected request`                                                 | The user closes the window   |
