Publish a new Clarity smart contract to the Stacks blockchain via the user's Leather wallet.
Method name
stx_deployContract
Parameters
name
(string, required): The name to assign to the deployed contract.clarityCode
(string, required): The full source code of the Clarity contract.clarityVersion
(number, optional): The version of the Clarity language to use. Defaults to 3 if not specified.
Usage
This method creates and broadcasts a contract deployment transaction using the user’s connected Leather wallet. Once confirmed, the smart contract becomes available on the specified network with the specified name.
Use this method to streamline contract deployment from within your dApp or developer tooling.
Use case
Use stx_deployContract
when:
Deploying a new smart contract directly from a web-based IDE or builder interface
Enabling power users to launch DAO, NFT, or token contracts via an app UI
Facilitating Clarity experimentation from testnet tools
Security notes
The user must approve the deployment in Leather before it is signed and broadcast.
Malformed Clarity code or duplicate contract names at the same address will result in failed transactions.
Validate the syntax and simulate the contract first if possible to catch issues early.