# Deploying a smart contract

Deploying a contract is done as follows:

## Verifying the compiled binary in your workspace <a href="#verifying-the-compiled-directory-in-your-workspace" id="verifying-the-compiled-directory-in-your-workspace"></a>

This simply means verifying that the binary file you have compiled with static linking in the step which is [specific for your language](/developers/qvm-multi-language-smart-contracts/docs-for-supported-languages.md) exists in your current workspace folder. After you have successfully executed the compilation, the resulting binary should be in your workspace already under the name `contract`. To verify just execute this command:

```
ls -al contract
```

If everything went well you should see similar output:

`-rwxr-xr-x 1 user group 1204224 Jul 25 02:14 contract`

## Run the deploy command of `qvmctl` using docker <a href="#run-the-deploy-command-of-qvmctl-using-docker" id="run-the-deploy-command-of-qvmctl-using-docker"></a>

```
docker run --rm -v $(pwd):/ws qanplatform/qvmctl deploy --privkey privkey.txt contract
```

## What happens under the hood? <a href="#what-happens-under-the-hood" id="what-happens-under-the-hood"></a>

### Upload <a href="#upload" id="upload"></a>

* Deployment fees are estimated based on your contract size
* Balance check is performed whether your wallet address has enough funds to cover the fee
* Your contract binary is pinned to IPFS
* A checksum of the binary's integrity is generated
* The above checksum is signed with your private key
* A call is made to the QVM Repository contract with your IPFS CID + the signature
* Fees are either paid during this call or the whole call fails

### Download <a href="#download" id="download"></a>

* The QVM Repository contract emits a Deployment event upon successful deployment
* QVM Executor nodes will download the binary based on the IPFS CID
* They will cryptographically prove to the QVM Repository that the contract has been downloaded indeed
* The QVM Repository contract verifies the submitted cryptographic proof to ensure Executors have the binary
* If above verification verification was successful then the contract is Registered and is now callable


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.qanplatform.com/developers/qvm-multi-language-smart-contracts/generic-workflow/deploying-a-smart-contract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
