To call create
in actual transactions, you need to start Sui and the Sui Client CLI.
Before you start, check the active address on the client as that address eventually owns the object):
Copy sui client active-address
To publish the code on-chain, use the following command:
Copy sui client publish $ROOT /sui_programmability/examples/objects_tutorial --gas-budget 10000
or from the root of the package folder:
Copy sui client publish --gas-budget 10000
These examples assume that the path to the root of the repository containing Sui source code is $ROOT.
You can find the published package object ID in the Transaction Effects output:
Copy Transaction Kind : Publish
----- Transaction Effects ----
Status : Success
Created Objects:
- ID: 0x225019dc52210704642b76c0bcf0d05bd374b6a348080f82a30ce7f8303c1b3f , Owner: Immutable
Mutated Objects:
- ID: 0x1b879f00b03357c95a908b7fb568712f5be862c5cb0a5894f62d06e9098de6dc , Owner: Account Address ( 0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446 )
Note that the exact data you see differs from the examples in this topic.
The first hex string with the Immutable
owner is the package's objectID
(0x79b81364676f2f700e8a5acc71ca66eef753f1e536e4480a24278f02499e8cc5
). For convenience, save it to an environment variable:
Copy export PACKAGE=0x79b81364676f2f700e8a5acc71ca66eef753f1e536e4480a24278f02499e8cc5
The mutated object is the gas object used to pay for the transaction.
You can call the function to create a color object:
Copy sui client call --gas-budget 1000 --package $PACKAGE --module "color_object" --function "create" --args 0 255 0
In the Transaction Effects portion of the output, you see an object included in the list of Created Objects :
Copy ----- Transaction Effects ----
Status : Success
Created Objects:
- ID: 0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446 , Owner: Account Address ( 0x79b81364676f2f700e8a5acc71ca66eef753f1e536e4480a24278f02499e8cc5 )
Mutated Objects:
- ID: 0x7cd011b6dbe90a0520a8501d993e3666b9373456b588f97600fcae6e02f60aa3 , Owner: Account Address ( 0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446 )
To save the object ID as a variable, use:
Copy export OBJECT=0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446
To inspect this object and see what kind of object it is, use:
Copy sui client object $OBJECT
This returns the metadata of the object, including its type:
Copy ----- Move Object (0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446[8]) -----
Owner: Account Address ( 0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446 )
Version: 8
Storage Rebate: 14
Previous Transaction: HRrB6qFxQZt7VEzagEjE4nhF9rbffK2wZRxqn9pPLhMk
----- Data -----
type: 0x79b81364676f2f700e8a5acc71ca66eef753f1e536e4480a24278f02499e8cc5::color_object::ColorObject
blue: 0
green: 255
id: 0x44840a79dd5cf1f5efeff1379f5eece04c72db13512a2e31e8750f5176285446
red: 0
You can also request the content of the object in json format by adding the --json
parameter:
Copy $ sui client object $OBJECT --json