Deploying contracts
SmartPy doesn't include a built-in way to deploy (originate) contracts to Tezos. You can deploy contracts in the SmartPy IDE or use other tools that can deploy Tezos contracts.
One popular tool is the Octez client, which is a command-line client that runs many different kinds of Tezos operations. For installation instructions, see Installing the Octez client on docs.tezos.com.
Here are general steps for deploying a SmartPy contract with the Octez client:
Install SmartPy locally as described in Installation.
Compile the contract with the
python
command. SmartPy writes the output to a folder with the same name as the test scenario.Install the Octez client and configure it for the target Tezos network. For example, to configure the client for the Ghostnet test network, get the URL of a Ghostnet node from https://teztnets.com and use it in the
octez-client config update
command, as in this example:bashoctez-client --endpoint https://rpc.ghostnet.teztnets.com config update
If you are using a testnet, Octez shows a warning that you are not using Mainnet. You can hide this message by setting the
TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER
environment variable to "YES".In the Octez client, create or import a wallet as described in Creating accounts on docs.tezos.com.
Fund the wallet with tez tokens. If you are using a testnet, you can use the network's faucet to get free tez. Testnet faucets are listed on https://teztnets.com.
In the output folder, find the compiled contract file, which ends in
contract.tz
. For example, if you downloaded and compiled the Welcome contract described in Installation, the compiled contract is in the fileWelcome/step_002_cont_0_contract.tz
.Optional: In the output folder, find the compiled initial storage value, which ends in
storage.tz
. For example, if you downloaded and compiled the Welcome contract described in Installation, the compiled contract storage value is in the fileWelcome/step_002_cont_0_storage.tz
.Use the
octez-client originate contract
command to deploy the contract. For example, this command deploys the Welcome contract and sets its initial storage:bashoctez-client originate contract welcome transferring 0 from my_account \ running Welcome/step_002_cont_0_contract.tz \ --init "`cat Welcome/step_002_cont_0_storage.tz`" --burn-cap 1
The response includes the address of the deployed contract, which starts with
KT1
. You can look up the contract in a block explorer using this address.
Now you can call the contract from a block explorer, a dApp, or the Octez client.