# Deploying Starknet smart contract

By [Vitamine](https://paragraph.com/@vitamine777) · 2023-02-06

---

Let's use the tool we used before - [Gitpod](https://www.gitpod.io/).

We need to upgrade Ubuntu to version 22. Here we go

> sudo apt list --upgradable
> 
> sudo apt update && sudo apt upgrade -y
> 
> sudo apt-get install ufw
> 
> sudo ufw enable
> 
> sudo ufw allow 1022/tcp
> 
> sudo ufw reload
> 
> sudo apt install update-manager-core -y
> 
> sudo do-release-upgrade -d

After this command, a long installation will begin.

![Press Enter when needed](https://storage.googleapis.com/papyrus_images/683440e1666efc3baad1888c796bfef9505c0e8b168fff3637f99c400f874cd9.jpg)

Press Enter when needed

![Type Y and press Enter](https://storage.googleapis.com/papyrus_images/3e1c3e768fb57325e00f0eb919a89c38167a8279fac748a5c2fd95b4bb5d6cb0.jpg)

Type Y and press Enter

![Type Y and press Enter](https://storage.googleapis.com/papyrus_images/7ad6d2ebecc391b6429e5d2f79c57d951d76865711ef9ad88b3ee70a13953488.jpg)

Type Y and press Enter

![Press Enter](https://storage.googleapis.com/papyrus_images/516a1f339aa64d701f16e5b7b2e334053a496de55dfb1829f46d798fefa0a622.jpg)

Press Enter

Now let's install the components needed to deploy a smart contract

> curl -L [https://raw.githubusercontent.com/software-mansion/protostar/master/install.sh](https://raw.githubusercontent.com/software-mansion/protostar/master/install.sh) | bash
> 
> source /home/gitpod/.bashrc
> 
> protostar -v

![If you have done everything correctly, this message will appear](https://storage.googleapis.com/papyrus_images/aa491c54165d411a39a005f01e21d91f3cbc07b9d7c6bd1fbc46299dfb889e5f.jpg)

If you have done everything correctly, this message will appear

Continue.

> protostar init

![Type N and press Etner. Then enter a folder name (any).](https://storage.googleapis.com/papyrus_images/2e30d0cc7820d0c3182615839a264b847b1446eb7d5c3e8a58f2014325fb0897.jpg)

Type N and press Etner. Then enter a folder name (any).

> cd \[YOUR FOLDER NAME\]

![](https://storage.googleapis.com/papyrus_images/65d9bea9519d1273504bfc64c6d0439b63c513a14b28d81b2c23d34c1483c391.jpg)

> protostar build

![](https://storage.googleapis.com/papyrus_images/b7ec53029039330f4c2bd17976e32cf2a4e7baf4d3e17ff49f2cb31c331ba566.jpg)

Now create a .env file in your folder.

![](https://storage.googleapis.com/papyrus_images/5e36ee800ce21fec5a969a9ab5c324b87a4d993afaf61467e3e6ff6b13637310.jpg)

We will use the **ArgentX.** Copy the private key and paste it into the .env file (the gear at the top right and click on the name of the account).

![](https://storage.googleapis.com/papyrus_images/46808adbaf05e686a2e07c79e21bd7f8b166459341cf1b81d1f8a53398c2a9b6.jpg)

**Important!** We need to have at least **1 transaction** in the network in which we will deploy the contract to continue (testnet or mainnet).

Continue. We will be deploying the contract in mainnet. If you want to do this on a test network, just replace the ends of the following 2 commands "mainnet >>> testnet".

> protostar declare ./build/main.json --account-address \[YOUR\_WALLET\_ADDRESS\] --max-fee auto --private-key-path ./.env --network mainnet

![Save the data (just in case)](https://storage.googleapis.com/papyrus_images/025e3dc4ff6f8dd0a70c613fc8731daa9c6c300bdb28cb971fe66517071d34ae.jpg)

Save the data (just in case)

Go to explorer (transaction hash) and wait for confirmation in L2.

![](https://storage.googleapis.com/papyrus_images/5979db3fa7effcb9c7438a2e39602f7e9cd5a8909ae61f46063b7c47c1df1ded.jpg)

Continue

> protostar deploy \[CLASS\_HASH\] --account-address \[YOUR\_WALLET\_ADDRESS\] --max-fee auto --private-key-path ./.env --network mainnet

Take CLASS\_HASH from the previous result.

![The transaction costs a few cents](https://storage.googleapis.com/papyrus_images/fd7703526c9eb49286ab24187f1608e7f156e16f118a5c60d0480118a671271d.jpg)

The transaction costs a few cents

Congratulations, you have deployed a smart contract!

The last command may give an error. This is normal. This is Starknet. Enter the command until it works, you can wait 5-10 minutes.

![](https://storage.googleapis.com/papyrus_images/de75094806165304ab466e8f7222bf173261209aedb46d8d8cda88e41600b8a4.jpg)

---

*Originally published on [Vitamine](https://paragraph.com/@vitamine777/deploying-starknet-smart-contract)*
