Skip to content

Instantly share code, notes, and snippets.

@Jeongseup
Created May 24, 2024 10:00
Show Gist options
  • Save Jeongseup/80075c5eaf821e7fb1d99c8186ef7953 to your computer and use it in GitHub Desktop.
Save Jeongseup/80075c5eaf821e7fb1d99c8186ef7953 to your computer and use it in GitHub Desktop.
Sui CLI Helper
# simple test
sui move test
# The previous command runs all tests whose name contains sword.
sui move test sword
sui move test -h
# list envs
sui client envs
# Add new env
sui client new-env --alias testnet --rpc https://sui-rpc.publicnode.com:443
# switching
sui client switch --env testnet
# check active env
sui client envs
# import mn with sui client
cat .mnemonic | xargs -I {} sui keytool import {} ed25519 --alias tester
# or
cat .mnemonic | xargs -I {} sui keytool import {} ed25519 "m/44'/784'/0'/0'/0'" --alias tester
# sui keys list
sui keytool list
╭────────────────────────────────────────────────────────────────────────────────────────────╮
│ ╭─────────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ alias │ tester │ │
│ │ suiAddress │ 0x2ade594485fb795616b74156c91097ec517a05ac488364dd3ad1ec5f536db3f4 │ │
│ ╰─────────────────┴──────────────────────────────────────────────────────────────────────╯ │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
# get facuet
curl --location --request POST 'https://faucet.testnet.sui.io/gas' \
--header 'Content-Type: application/json' \
--data-raw '{
"FixedAmountRequest": {
"recipient": "0x2ade594485fb795616b74156c91097ec517a05ac488364dd3ad1ec5f536db3f4"
}
}'
# switch active address
sui client switch --env testnet --address tester
sui client active-address
# deploy move contract on sui testnet
sui client publish --gas-budget 100000000
[warn] Client/Server api version mismatch, client api version : 1.25.0, server api version : 1.25.1
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ 0x08d6db1aee221382c513b7d6db63ad65a5491405498eaffc1a9f01d1c15aa8d4 │ │
│ │ version │ 696511 │ │
│ │ digest │ tkaAU2zDazW1LuUZQZ/Kj/5HL0DOdOfkeTiZMHscFas= │ │
│ │ objectType │ 0x0000..0002::package::UpgradeCap │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ 0x3d66a3d496be2c894e13d40808269ea27bca2eb49a86442bc095ab1cea1ea0be │ │
│ │ version │ 696511 │ │
│ │ digest │ yf7YHvUqPhWfLwZ0u9LkcLxofnl6LzUk74NbbP995ag= │ │
│ │ objectType │ 0x0000..0002::coin::Coin │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ 0x93b7af101de8aa4569e59ee85c355961282c9614e498a4010b2d5419f67967cf │ │
│ │ version │ 696511 │ │
│ │ digest │ oVuneU3DNaZyXlJ4QPBoNuAjIQu6R1r4aKitM+EQySA= │ │
│ │ objectType │ 0xd9f1..c066::my_module::Forge │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ 0xf1feb8e6233f0c873ba9f7b5eefac327fd937ccdab385606bb32598b194876ce │ │
│ │ version │ 984322 │ │
│ │ digest │ 2c0MM0nDNK8ggywFsAzQ7VhuOzWgRB+b1HKk6cG/MFE= │ │
│ │ objectType │ 0x0000..0002::coin::Coin │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
╰───────────────────────────────────────────────────────────────────────────────────────╯
# sui ptb call
sui client ptb \
--assign forge @0x93b7af101de8aa4569e59ee85c355961282c9614e498a4010b2d5419f67967cf \
--assign to_address @0x2ade594485fb795616b74156c91097ec517a05ac488364dd3ad1ec5f536db3f4 \
--move-call 0xd9f136f74c1ee65c038ae1fec26981151dc143aaa88b7d6c472df0c67a77c066::my_module::new_sword forge 3 3 \
--assign sword \
--transfer-objects "[sword]" to_address \
--gas-budget 20000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment