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

# 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:

<table><thead><tr><th width="200">Request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>a string representing the name under which to deploy the contract<br>Example: <code>ST000000000000000000002AMW42H.pox-3</code></td></tr><tr><td><code>clarityCode</code></td><td>a string representing the code of the contract to deploy, in Clarity language</td></tr><tr><td><code>clarityVersion</code></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> Optional<br>The Clarity version used for the contract code. Will default to the latest Clarity version if <code>undefined</code></td></tr><tr><td><code>postConditions?</code></td><td><p>an array of strings representing the post conditions to be applied on the transaction. <br><br> post conditions are expected as hex-encoded strings <br></p><p>To convert post conditions values to their hex representation, you can use the <code>postConditionToHex</code> helper from the <code>@stacks/transactions</code> package.</p></td></tr><tr><td><code>postConditionMode?</code></td><td>'allow' | 'deny'</td></tr></tbody></table>

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

```typescript
    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.&#x20;

The transaction will be signed and broadcasted upon user approval.

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

<table><thead><tr><th width="162">Property</th><th>Description</th></tr></thead><tbody><tr><td><code>txid</code></td><td>a hex-encoded string representing the ID of the Stacks contract deployment transaction signed</td></tr><tr><td><code>transaction</code></td><td>a hex-encoded string representing the Stacks contract deployment transaction signed</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.xverse.app/sats-connect/stacks-methods/stx_deploycontract.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
