stx_deployContract

Deploy a Clarity smart contract on the Stacks blockchain.

Method name

stx_deployContract


Parameters

Parameter
Description
Required
Type

name

The name of the contract.

string

clarityCode

Clarity contract code

string

clarityVersion

Version of the Clarity language (defaut: 3)

number


Example request

try {
  // Deploy contract
  const response = await window.LeatherProvider.request("stx_deployContract", {
    name: "my-smart-contract",
    clarityCode: "(define-public (say-hi) (ok \"Hello, world!\"))",
    clarityVersion: 2,
  });

  console.log("Response:", response);
} catch (error) {
  console.log("Request error:", error.error.code, error.error.message);
}

Example response


Last updated