APIs

Developer Docs

stx_callContract API method

May 21, 2025

Disclaimer: Leather does not interpret or verify contract function logic. Developers must ensure contract safety and parameter correctness before invoking user-signed transactions.

Trigger a Stacks smart contract function using the user's Leather wallet.

This method wraps stx_signTransaction, handling function call formatting and signature flow automatically.

Method name

stx_callContract

Parameters

  • contract (string, required): The fully qualified identifier for the target contract, including the Stacks address and contract name. Example: SP3FBR2AGK5X3Y5D0X6MYB6Z3R9Y3WNRJY9ZTV8PV.my-contract

  • functionName (string, required): The name of the function in the contract to call.

  • functionArgs (string[], required): The list of Clarity-compatible arguments to be passed to the contract function. Each argument must be properly encoded as a string.

Usage

This method simplifies the process of calling smart contracts by abstracting the construction and signing of transactions. When invoked, Leather presents the user with a prompt to approve the contract call, then signs and broadcasts the transaction to the network.

This is ideal for developers who want a streamlined interface for interacting with contract functions in a user-authorized and secure manner.

Use case

Use stx_callContract when:

  • Your app needs to interact with deployed Clarity contracts (e.g., minting, transferring, or voting)

  • You want Leather to handle signing and broadcasting the call transaction

  • Reducing boilerplate around stx_signTransaction for function calls

Example use cases:

  • NFT minting flows

  • DAO proposals or executions

  • Smart contract interaction in DeFi dApps

Security notes

  • The user will see the full transaction request and must approve it in Leather.

  • Ensure that argument encoding is correct and matches the Clarity function signature.

  • Leather handles the signing and broadcasting once approved.

Example

const response = await window.LeatherProvider.request("stx_callContract", {
  contract: "SP3FBR2AGK5X3Y5D0X6MYB6Z3R9Y3WNRJY9ZTV8PV.my-contract",
  functionName: "get-balance",
  functionArgs: [],
});
{
  "jsonrpc": "2.0",
  "id": "d5e8a7bf-2bc6-4e5e-9c4d-8a6e1d2f99eb",
  "result": {
    "txid": "0x9a12b3c4d5e6f7890ab1c2d3e4f567890abcdef1234567890abcdef123456789",
    "transaction": "0xe3a1b2c3..."
  }
}