Setting up a Sui 💧 Development Environment in Linux
April 15th, 2023

For an extended explanation, please check the great Sui docs here.

Prerequisites

In a nutshell:

curl, git-all, cmake, gcc, libssl-dev, pkg-config, libclang-dev,build-essential

Well, you know what to do: just apt them all, right?

Installing Sui Binaries

Use the following command to install Sui directly from the Sui GitHub repository (devnet branch):

# Install
cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui
# Update rust
rustup update stable
# Check sui
sui
Output of "sui" command
Output of "sui" command

Install vscode as IDE

Next, install the move-analyzer extension:

vscode extension move-analyzer
vscode extension move-analyzer

And the move language server:

cargo install --git https://github.com/move-language/move move-analyzer --branch sui-move --features "address32"

You should be able to see Move code with syntax highlighting, commenting & uncommenting, simple context-unaware completion suggestions while typing, and other basic language features in Move files.

Nice syntax highlight and other features provided by the Move Analyzer plugin
Nice syntax highlight and other features provided by the Move Analyzer plugin

Connect to Sui Devnet or Testnet

To connect to the Sui devnet for the first time, just run sui client:

sui client

Choose: y, devnet, 0.

Save the address and secret recovery phrase just in case. Example from Sui documentation:

# Result: keypar added to sui.keystore and seed phrase printed
Generated new keypair for address with scheme "ed25519" [0xb9c83a8b40d3263c9ba40d551514fbac1f8c12e98a4005a0dac072d3549c2442]
Secret Recovery Phrase : [cap wheat many line human lazy few solid bored proud speed grocery raise erode there idea inform culture cousin shed sniff author spare carpet]

Add testnet:

sui client new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443

List configured environments:

sui client envs

# Result: alias to the left, RPC endpoint to the right 
  devnet => https://fullnode.devnet.sui.io:443 (active)
  testnet => https://fullnode.testnet.sui.io:443

Switch active network:

sui client switch --env testnet

As testnet is usually comparatevily slow, it is better to use devnet for all developments. It is also possible to setup a local network, as described here in the Sui docs.

Go Further with the Sui CLI

Get the active Sui client address:

sui client active-address

Create a new address:

# The Sui Wallet currently only allow importing PKs 
# generate from ed25519. If you plan to import later 
# the local address into the Sui wallet, use it.
sui client new-address ed25519

List all created addresses:

sui client addresses

Change active address:

sui client switch --address YOUR_ADDRESS_HERE

List amount of gas for the active-address:

# For a specific address just add it after gas
sui client gas

Request gas from the Sui testnet faucet:

curl --location --request POST 'https://faucet.testnet.sui.io/gas' \
--header 'Content-Type: application/json' \
--data-raw '{
    "FixedAmountRequest": {
        "recipient": "YOUR_ADDRESS_HERE"
    }
}'

Request gas from the Sui devnet faucet:

curl --location --request POST 'https://faucet.devnet.sui.io/gas' \
--header 'Content-Type: application/json' \
--data-raw '{
    "FixedAmountRequest": {
        "recipient": "YOUR_ADDRESS_HERE"
    }
}'

List all objects owned by the active-address:

sui client objects

Get object detailed info:

sui client object YOUR_OBJECT_ID_HERE

That’s it for today. If you enjoyed the content, consider subscribing and collecting this entry. Thank you!

PS. If you are interested in how to import your locally generated address into your Sui Wallet, check this article here.

Subscribe to Crypto Trekker
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from Crypto Trekker

Skeleton

Skeleton

Skeleton