🔴stx_callContract

You can use the stx_callContract method to request the signature of any contract call transaction from the user's wallet. The method lets you specify the contract to call, the function to execute on the contract and the arguments to pass to the function.

    import { Wallet } from "sats-connect";

      const response = await Wallet.request("stx_callContract", {
        contract: `${contractAddress}.${contractName}`,
        functionName,
        arguments: JSON.parse(functionArgs),
      });
      if (response.status === "success") {
        console.log(response.result);
      } else {
        console.error(response.error);
      }
    } catch (error) {
      console.error(error);
      alert(error);
    }

The user will see a Stacks contract call transaction signing request prompt in the wallet.

The transaction will be signed and broadcasted upon user approval.

The stx_callContract method returns a Promise that resolves to the CallContractResult object: