Cover photo

Deploying SUI smart contract on devnet

I will do all the necessary steps on Ubuntu. We have two options: easy (my guide) and not so easy (server rental). We will go the simple way. For this one, you must have a Github account.

Create a new repository and name it "Hello SUI", for example.

post image

After creating the repository, go to this site

https://www.gitpod.io/

and log in with our Github profile.

Next, create a new workspace and select our created repository.

post image

The terminal opens (the Get started window at the top can be closed).

post image

We need to install all the necessary components to deploy a smart contract.

Now paste the commands one by one into the terminal and click Enter (to paste the copied text into the terminal right-click).

sudo apt-get update

sudo apt install curl -y

sudo apt-get install git-all -y

sudo apt install cmake -y

dpkg -L cmake

sudo apt-get install libssl-dev

sudo apt-get install libclang-dev -y

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Type 1 and press Enter

cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

This part takes a very long time to install. Just waiting.

Continue.

echo $PATH

cargo install --git https://github.com/move-language/move move-analyzer --features "address20"

sui client

Type next: 1) y and press Enter, 2) then just press Enter, 3) then type 0 and press Enter

post image

Continue.

sui client new-address ed25519

post image

A wallet was created. Save the seed phrase and address to a text file.

We need to request test tokens to this wallet. There are several ways

  • Request tokens in SUI discord to our address.

  • Transfer some test tokens from another wallet.

  • Import the seed phrase into one of the SUI wallets (SUI wallet, Suiet etc) and request tokens in it.

    Continue.

    sui client switch --address [ADDRESS]

    replace [ADDRESS] with the address obtained from the previous command

post image

Continue.

sui move new forge

Created a forge folder with an empty source folder and a Move.toml file

Go to the source folder and create the file forge.move

post image

Go here

https://github.com/Salvatorenodes/Hello-SUI/blob/main/example.move

copy the code and paste the code into the forge.move file

post image

Continue.

cd forge

sui client publish --gas-budget 1000

post image

Congratulations, you have deployed a smart contract! Save everything that goes into Created ojects.

Go to Sui explorer and search for your contract by typing the ID from Created objects.

https://explorer.sui.io/