Sats Connect - Wallet API for Bitcoin & Stacks
  • Introduction
  • Wallet Providers
    • getInfo
    • getProviders & getProviderById
  • Connecting to the wallet
    • Connect to Xverse Wallet
    • Disconnect from Xverse Wallet
    • Connect to other wallets
      • Manage a user's default wallet
    • [Legacy âš ī¸] getAccounts
  • Wallet Methods
    • request methods
    • wallet_getAccount
    • wallet_getNetwork
    • wallet_changeNetwork
    • Xverse Custom Methods
  • Xverse Wallet Permissions
  • Xverse Wallet events
  • BITCOIN METHODS
    • 🟠getAddresses
    • 🟠signMessage
    • 🟠signPsbt
    • 🟠sendTransfer
    • 🟠signMultipleTransactions
    • 🟠getBalance
    • 🎨createInscription
    • 🎨createRepeatInscriptions
    • 🎨ord_getInscriptions
    • 🎨ord_sendInscriptions
    • 🔲runes_getBalance
    • 🔲runes_transfer
    • 🔲Mint Runes
      • runes_estimateMint
      • runes_mint
    • 🔲Etch Runes
      • runes_estimateEtch
      • runes_etch
    • 🔲runes_getOrder
    • 🔲Speed up a Rune Mint or Etch order
      • 🔲runes_estimateRbfOrder
      • 🔲runes_rbfOrder
  • STACKS METHODS
    • 🔴stx_getAccounts
    • 🔴stx_signMessage
    • 🔴stx_signStructuredMessage
    • 🔴stx_transferStx
    • 🔴stx_signTransaction
    • 🔴stx_callContract
    • 🔴stx_deployContract
  • GUIDES
    • Verify Bitcoin message signatures
    • Creating Bitcoin PSBTs
    • 📱Mobile Integration
    • Next.js support
  • RESOURCES
    • App Template
    • Demo App
    • Changelog
    • Github Issues
    • Developer forum
    • BIP322
Powered by GitBook
On this page
  1. STACKS METHODS

stx_deployContract

You can use the stx_deployContract method to request the signature of any contract deployment transaction from the user's wallet. The method lets you specify the contract code and the contract name:

Request parameters
Description

name

a string representing the name under which to deploy the contract Example: ST000000000000000000002AMW42H.pox-3

clarityCode

a string representing the code of the contract to deploy, in Clarity language

clarityVersion

postConditions?

an array of strings representing the post conditions to be applied on the transaction. post conditions are expected as hex-encoded strings

To convert post conditions values to their hex representation, you can use the postConditionToHex helper from the @stacks/transactions package.

postConditionMode?

'allow' | 'deny'

You can use any Stacks library to construct these transaction. See examples using helpers from the @stacks/transactions package

    import { request } from "sats-connect";
    
    try {
      const response = await request("stx_deployContract", {
        clarityCode,
        name: contractName,
      });
      if (response.status === "success") {
        alert("Success. Check console for response");
        console.log(response.result);
      } else {
        alert(errorMessage);
        console.error(response.error);
      }
    } catch (error) {
      alert(errorMessage);
      console.error(error);
    }

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

The transaction will be signed and broadcasted upon user approval.

The stx_deployContract method returns a Promise that resolves to the DeployContractResult object:

Property
Description

txid

a hex-encoded string representing the ID of the Stacks contract deployment transaction signed

transaction

a hex-encoded string representing the Stacks contract deployment transaction signed

Previousstx_callContractNextVerify Bitcoin message signatures

Last updated 2 months ago

Optional The Clarity version used for the contract code. Will default to the latest Clarity version if undefined

🔴
â„šī¸