รวมคำสั่ง Sui Client ที่ใช้บ่อยๆ

Sui Mar 30, 2023

เนื่องจากช่วงนี้ลองมาเล่น Sui ดูหลังจากเคยลอง Install เบื้องต้น ตอน v0.10.0 ตอนนี้ v0.29.0 ก็เลยนำมาเขียนเป็นบันทึกไว้ เผื่อลืม แต่เอาจริงๆ ก็ไม่ค่อยลืมเท่าไหร่ หรือลืมก็ดู guide ผ่าน Command Line ได้เลย เอาเป็นว่าจดบันทึกเอาไว้เผื่อกลับมาอ่าน โดยเลือกเอาเฉพาะคำสั่งที่ใช้ละกัน

How to install Sui and Connect to Devnet
Take notes about my learning Sui for the first time, How to install Sui, and how to connect to Sui Devnet

ติดตั้ง sui client และ sui-test-validator  (ใช้ branch devnet)

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

คำสั่ง sui client จริงๆ ถ้าลืม ก็แค่พิมพ์

sui client

# หรือ
sui client --help

Address

# ดู active address
sui client active-address

# list address ทั้งหมด
sui client addresses

# เปลี่ยน active address
sui client switch --address <ADDRESS>

# สร้าง address ใหม่
sui client new-address ed25519 # ed25519 | secp256k1 | secp256r1

# ดู gas object ของ address
sui client gas

Environment

# ดู active env
sui client active-env

# เพิ่ม env
sui client new-env --alias <ALIAS> --rpc <RPC-SERVER-URL>

# เพิ่ม testnet
sui client new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443

# เปลี่ยน env
sui client switch --env <ALIAS>
sui client switch --env local
Announcing Permanent Testnet
Sui’s highly anticipated Permanent Testnet has finally arrived!! This instance of the Sui network serves as Sui’s long-running, decentralized, and permissionless Testnet. Unlike past Testnet Waves 1 and 2, this new Testnet will continue running even after Mainnet launch. With this network we bring…
ล่าสุด ณ วันที่ 29 มีนา มี testnet แล้ว!

Faucet

ขอผ่าน Discord

!faucet <SUI ADDRESS>

ขอผ่าน cURL

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

ขอผ่าน axios

const url = 'https://faucet.devnet.sui.io/gas'

const payload = {
  FixedAmountRequest: {
    recipient: '<SUI ADDRESS>'
  }
}

const res = await axios.post(url, payload)

Start Localtest

sui-test-validator

Publish module

sui client publish <FILE> --gas-budget <GAS>

References

Sui Blockchain - Build without boundaries
Sui is the first permissionless Layer 1 blockchain designed from the ground up to enable creators and developers to build experiences that cater to the next billion users in web3 - Sui is a decentralized platform to build rich and dynamic on-chain assets from gaming to finance. A STEP-FUNCTION CHANG…
Sui Documentation
Documentation for Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by Move.

Tags

Chai Phonbopit

เป็น Web Dev ทำงานมา 10 ปีหน่อยๆ ด้วยภาษา JavaScript, Node.js, React, Vue และปัจจุบันกำลังสนใจ Web3, Crypto และ Blockchain เขียนบล็อกที่ https://devahoy.com