🔴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 parametersDescription

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

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

    import { Wallet } from "sats-connect";
    
    try {
      const response = await Wallet.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:

PropertyDescription

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