owned this note
owned this note
Published
Linked with GitHub
# Install Sui on Ubuntu 22.04
## Sui GET STARTED
#### According to the [Sui GET STARTED](https://docs.sui.io/build/install) Sui only supports Ubuntu 20.04, and my os is Ubuntu 22.04 that has been published for more than one year so I would like to give it a try.
![](https://hackmd.io/_uploads/B1N3ehiH3.png)
## Rust and Cargo
Install Rust and Cargo
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
Update Rust
```
rustup update stable
```
![](https://hackmd.io/_uploads/HkofghjBh.png)
## Sui Binaries
Ubuntu Dependencies
```
sudo apt update
sudo apt install -y curl git-all libssl-dev libclang-dev cmake pkg-config libprotobuf-dev protobuf-compiler clang
```
Install Sui Binaries
```
cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui
```
![](https://hackmd.io/_uploads/H1ife2jSn.png)
It may take about half an hour, depends on your PC or NB performance.
![](https://hackmd.io/_uploads/H1xiGxnjS3.png)
Check the Sui Binaries installation
```
sui
```
![](https://hackmd.io/_uploads/Sylofe2sS3.png)
```
which sui
```
![](https://hackmd.io/_uploads/BkejfehiB3.png)
I want to check more so run sui client. You have to select a key scheme(any is ok) when you run the command first time, then it will generate a new address `0x73a2fb009cbac98639e054e5c3c3a56e28c1b2ad012ffe2ba022fc23765928b1` for you.
```
sui client
```
![](https://hackmd.io/_uploads/Byljzxnsr2.png)
![](https://hackmd.io/_uploads/HkjzehjHn.png)
The following command will show the networks that you have and active network
```
sui client envs
```
![](https://hackmd.io/_uploads/HJejGenoB2.png)
## Sui Faucet
We can request test token in Sui discord. Send the message to the relevant channel with the address : !faucet <YOUR-CLIENT-ADDRESS>
![](https://hackmd.io/_uploads/rJ6QK3sr3.png)
or
```
curl --location --request POST 'https://faucet.devnet.sui.io/gas' \
--header 'Content-Type: application/json' \
--data-raw '{
"FixedAmountRequest": {
"recipient": "<YOUR SUI ADDRESS>"
}
}'
```
![](https://hackmd.io/_uploads/BJzy35ar2.png)
Check the test token(active network and address, object id is not your address)
```
sui client gas
```
![](https://hackmd.io/_uploads/Syszx2jHh.png)
## Sui source code
Clone the Sui source code from Github
```
git clone https://github.com/MystenLabs/sui.git --branch devnet
```
![](https://hackmd.io/_uploads/SJZozx3orn.png)
## Connect to Sui Network
Add testnet to env
```
sui client new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443
```
![](https://hackmd.io/_uploads/rJoGg3jH2.png)
Switch to the testnet
```
sui client switch --env testnet
```
![](https://hackmd.io/_uploads/H1izx2iSn.png)
Start interactive shell( exit: ctrl+c )
```
sui console
```
![](https://hackmd.io/_uploads/S1kYLSnr2.png)
## First Publish
Publish an example code move_tutorial and the error means that the gas budget is too low.
```
sui client publish <your-sui-repo>/sui_programmability/examples/move_tutorial --gas-budget 30000
```
![](https://hackmd.io/_uploads/SJozxnirh.png)
Scale up the gas budget then success
![](https://hackmd.io/_uploads/ryesMlhjH2.png)
```
[warn] Client/Server api version mismatch, client api version : 1.2.0, server api version : 1.2.1
2023-05-31T03:32:11.532052Z WARN sui_sdk::wallet_context: Client/Server api version mismatch, client api version : 1.2.0, server api version : 1.2.1
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING MyFirstPackage
Skipping dependency verification
----- Transaction Digest ----
3xeXcrQ9oT7Xd2yKiC1DaMBbFyammqGFtpZHmvPeTeCN
----- Transaction Data ----
Transaction Signature: [Signature(Ed25519SuiSignature(Ed25519SuiSignature([0, 9, 220, 36, 214, 53, 59, 167, 98, 229, 180, 84, 181, 201, 189, 141, 43, 88, 175, 125, 191, 135, 129, 205, 84, 144, 113, 47, 78, 95, 64, 108, 79, 98, 137, 214, 236, 36, 26, 61, 184, 164, 131, 71, 199, 240, 43, 51, 170, 65, 214, 165, 1, 88, 173, 127, 36, 146, 98, 190, 84, 252, 40, 151, 3, 241, 134, 10, 229, 121, 255, 21, 253, 229, 185, 162, 215, 250, 148, 200, 147, 126, 77, 16, 150, 183, 60, 218, 225, 74, 163, 198, 207, 143, 63, 30, 85])))]
Transaction Kind : Programmable
Inputs: [Pure(SuiPureValue { value_type: Some(Address), value: "0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a" })]
----- Transaction Digest ----
3xeXcrQ9oT7Xd2yKiC1DaMBbFyammqGFtpZHmvPeTeCN
Commands: [
Publish(<modules>,0x0000000000000000000000000000000000000000000000000000000000000001,0x0000000000000000000000000000000000000000000000000000000000000002),
TransferObjects([Result(0)],Input(0)),
]
----- Transaction Data ----
2023-05-31T03:32:14.330634Z INFO sui::client_commands: Transaction Signature: [Signature(Ed25519SuiSignature(Ed25519SuiSignature([0, 9, 220, 36, 214, 53, 59, 167, 98, 229, 180, 84, 181, 201, 189, 141, 43, 88, 175, 125, 191, 135, 129, 205, 84, 144, 113, 47, 78, 95, 64, 108, 79, 98, 137, 214, 236, 36, 26, 61, 184, 164, 131, 71, 199, 240, 43, 51, 170, 65, 214, 165, 1, 88, 173, 127, 36, 146, 98, 190, 84, 252, 40, 151, 3, 241, 134, 10, 229, 121, 255, 21, 253, 229, 185, 162, 215, 250, 148, 200, 147, 126, 77, 16, 150, 183, 60, 218, 225, 74, 163, 198, 207, 143, 63, 30, 85])))]
2023-05-31T03:32:14.330644Z INFO sui::client_commands: Transaction Kind : Programmable
Inputs: [Pure(SuiPureValue { value_type: Some(Address), value: "0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a" })]
Commands: [
Publish(<modules>,0x0000000000000000000000000000000000000000000000000000000000000001,0x0000000000000000000000000000000000000000000000000000000000000002),
TransferObjects([Result(0)],Input(0)),
]
Sender: 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a
Gas Payment: Object ID: 0x84572a3bf15459f777bc4716fc4ff42bee3b990f38f8d71f62b83e90d0ecafbe, version: 0x6a, digest: 8FF6wvBThcZj9SA4y3EetV5qsvv5NPBHX2TJ6mtmwrYv
Gas Owner: 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a
Gas Price: 1000
Gas Budget: 15000000
----- Transaction Effects ----
Status : Success
Created Objects:
- ID: 0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7 , Owner: Immutable
- ID: 0x6bdb5005dd5e70170cabac273a426d8bd980a483e0956e653f4534fb9fb01917 , Owner: Account Address ( 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a )
- ID: 0xe64cc4a1278a87a372f3e67e800b99b45f845416f2b1a46558a326efddb06dd6 , Owner: Account Address ( 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a )
Mutated Objects:
Sender: 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a
Gas Payment: Object ID: 0x84572a3bf15459f777bc4716fc4ff42bee3b990f38f8d71f62b83e90d0ecafbe, version: 0x6a, digest: 8FF6wvBThcZj9SA4y3EetV5qsvv5NPBHX2TJ6mtmwrYv
- ID: 0x84572a3bf15459f777bc4716fc4ff42bee3b990f38f8d71f62b83e90d0ecafbe , Owner: Account Address ( 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a )
Gas Owner: 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a
----- Events ----
Gas Price: 1000
Gas Budget: 15000000
----- Transaction Effects ----
Array []
Status : Success
Created Objects:
----- Object changes ----
- ID: 0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7 , Owner: Immutable
Array [
- ID: 0x6bdb5005dd5e70170cabac273a426d8bd980a483e0956e653f4534fb9fb01917 , Owner: Account Address ( 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a )
Object {
- ID: 0xe64cc4a1278a87a372f3e67e800b99b45f845416f2b1a46558a326efddb06dd6 , Owner: Account Address ( 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a )
Mutated Objects:
"type": String("mutated"),
- ID: 0x84572a3bf15459f777bc4716fc4ff42bee3b990f38f8d71f62b83e90d0ecafbe , Owner: Account Address ( 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a )
"sender": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"owner": Object {
----- Events ----
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
Array []
},
----- Object changes ----
"objectType": String("0x2::coin::Coin<0x2::sui::SUI>"),
Array [
"objectId": String("0x84572a3bf15459f777bc4716fc4ff42bee3b990f38f8d71f62b83e90d0ecafbe"),
Object {
"version": String("107"),
"type": String("mutated"),
"previousVersion": String("106"),
"sender": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"digest": String("DfWEfbD2pmAwqSm9G8LA6wFKQd3eHXZ83Uk3cVKBsdqk"),
"owner": Object {
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
},
},
Object {
"objectType": String("0x2::coin::Coin<0x2::sui::SUI>"),
"type": String("published"),
"objectId": String("0x84572a3bf15459f777bc4716fc4ff42bee3b990f38f8d71f62b83e90d0ecafbe"),
"packageId": String("0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7"),
"version": String("107"),
"version": String("1"),
"previousVersion": String("106"),
"digest": String("C7XxvLH9vtX9hQzYc2FtWbYgVFAy2MvXVwof73LKoGLk"),
"digest": String("DfWEfbD2pmAwqSm9G8LA6wFKQd3eHXZ83Uk3cVKBsdqk"),
"modules": Array [
},
String("my_module"),
Object {
"type": String("published"),
],
"packageId": String("0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7"),
},
"version": String("1"),
Object {
"digest": String("C7XxvLH9vtX9hQzYc2FtWbYgVFAy2MvXVwof73LKoGLk"),
"type": String("created"),
"modules": Array [
"sender": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
String("my_module"),
"owner": Object {
],
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
},
},
Object {
"objectType": String("0x2::package::UpgradeCap"),
"type": String("created"),
"sender": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"objectId": String("0x6bdb5005dd5e70170cabac273a426d8bd980a483e0956e653f4534fb9fb01917"),
"owner": Object {
"version": String("107"),
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"digest": String("C7e82y6xpSh5JSexAmi3dwPUEYxVwaKL4NBTkJQobFQr"),
},
"objectType": String("0x2::package::UpgradeCap"),
"objectId": String("0x6bdb5005dd5e70170cabac273a426d8bd980a483e0956e653f4534fb9fb01917"),
},
"version": String("107"),
"digest": String("C7e82y6xpSh5JSexAmi3dwPUEYxVwaKL4NBTkJQobFQr"),
Object {
},
"type": String("created"),
Object {
"type": String("created"),
"sender": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"owner": Object {
"sender": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"owner": Object {
},
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"objectType": String("0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7::my_module::Forge"),
},
"objectId": String("0xe64cc4a1278a87a372f3e67e800b99b45f845416f2b1a46558a326efddb06dd6"),
"objectType": String("0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7::my_module::Forge"),
"version": String("107"),
"objectId": String("0xe64cc4a1278a87a372f3e67e800b99b45f845416f2b1a46558a326efddb06dd6"),
"digest": String("8Dsq6uSB1PUPZSXXDfkekZbTDDGrQppjbUoz4F6hq91N"),
"version": String("107"),
},
"digest": String("8Dsq6uSB1PUPZSXXDfkekZbTDDGrQppjbUoz4F6hq91N"),
]
},
----- Balance changes ----
]
Array [
Object {
----- Balance changes ----
"owner": Object {
Array [
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
Object {
"owner": Object {
},
"AddressOwner": String("0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a"),
"coinType": String("0x2::sui::SUI"),
},
"amount": String("-10327480"),
"coinType": String("0x2::sui::SUI"),
},
"amount": String("-10327480"),
]
},
]
```
##### The package publish operation creates several objects:
A package object (with ID 0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7 in the example output).
A Forge object (with ID 0xe64cc4a1278a87a372f3e67e800b99b45f845416f2b1a46558a326efddb06dd6 in the example output) as a result of running a module initializer for the one (and only) module of this package.
An UpgradeCap object (with ID 0x6bdb5005dd5e70170cabac273a426d8bd980a483e0956e653f4534fb9fb01917 in the example output) for use in future package upgrades.
We can see the created object on [Sui Explorer Testnet](https://suiexplorer.com/?network=testnet)
![](https://hackmd.io/_uploads/ByIVqrN8h.png)
The object details
![](https://hackmd.io/_uploads/HJlu5SNI2.png)
## Make a Move Call
#### Create new address
```
sui client new-address ed25519
```
#### Switch address
```
sui client switch --address <address>
```
#### List objects
```
sui client objects
```
![](https://hackmd.io/_uploads/rkr8sHEU2.png)
#### Object details
```
sui client objects <object id>
```
![](https://hackmd.io/_uploads/rJIIjHNIn.png)
#### Object json
```
sui client objects <object id> --json
```
![](https://hackmd.io/_uploads/B18LjrN8n.png)
#### Call function to create and transfer sword
```
sui client call --function sword_create --module my_module --package 0x5812c5ac9f61193f8b2fcfe54b580faddc15916f4e41ffab936a9c648632d9c7 --args \"0xe64cc4a1278a87a372f3e67e800b99b45f845416f2b1a46558a326efddb06dd6\" 42 7 \"0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a\" --gas-budget 15000000
```
![](https://hackmd.io/_uploads/SyBYGLELn.png)
![](https://hackmd.io/_uploads/SJ_of8VU2.png)
![](https://hackmd.io/_uploads/H160fLEIh.png)
## Transfer, Split and Merge
#### Transfer test token
```
sui client transfer --to 0x895c778bca7a8221c0878d27fe36b805d36d68d3ecf90547ab0980ffcd79016a --object-id 0xd80cc482701eff5e85174194c5eab4a528e95f3c98ac4b1a95f0b09b2ee6d9bf --gas-budget 1000
```
![](https://hackmd.io/_uploads/rkwLsrNIn.png)
![](https://hackmd.io/_uploads/rkx88jHNL3.png)
![](https://hackmd.io/_uploads/HkU8jBNU3.png)
![](https://hackmd.io/_uploads/HkgILoHN82.png)
#### Split coin
```
sui client split-coin --coin-id 0xd80cc482701eff5e85174194c5eab4a528e95f3c98ac4b1a95f0b09b2ee6d9bf --count 3 --gas-budget 10000000
```
![](https://hackmd.io/_uploads/S1wUiBNU2.png)
![](https://hackmd.io/_uploads/rJILjHEL2.png)
![](https://hackmd.io/_uploads/SyQUirNLn.png)
![](https://hackmd.io/_uploads/HJ8IiHVUn.png)
#### Merge coin
```
sui client merge-coin --primary-coin 0xd80cc482701eff5e85174194c5eab4a528e95f3c98ac4b1a95f0b09b2ee6d9bf --coin-to-merge 0xd3c885c4638480d187cb7b365e2984fe261474580151d9047be3cd3d1f81ab1c --gas-budget 10000000
```
![](https://hackmd.io/_uploads/BJvIjBNLh.png)
![](https://hackmd.io/_uploads/H1SUiSVU2.png)
![](https://hackmd.io/_uploads/ryx88orVIn.png)
#### Transfer again
![](https://hackmd.io/_uploads/rk8IorNU2.png)
![](https://hackmd.io/_uploads/B1lwIsrEU2.png)
![](https://hackmd.io/_uploads/SkUIjr4Un.png)
![](https://hackmd.io/_uploads/HkSUjrNL3.png)