Skip to content

Commit

Permalink
[cleanup] Fix docs after TransferObject change (MystenLabs#2813)
Browse files Browse the repository at this point in the history
* [cleanup] Fix docs after TransferObject change

- Fix json_rpc doc
- Fix transaction doc

* fixup! [cleanup] Fix docs after TransferObject change

* fixup! [cleanup] Fix docs after TransferObject change

* Fix Transfer object header

Co-authored-by: Clay-Mysten <100217682+Clay-Mysten@users.noreply.github.com>
  • Loading branch information
tnowacki and Clay-Mysten authored Jun 28, 2022
1 parent b83e558 commit a4b27aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
18 changes: 8 additions & 10 deletions doc/src/build/json-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ curl --location --request POST $SUI_RPC_HOST \
--data-raw '{ "jsonrpc":"2.0",
"method":"sui_transferObject",
"params":["{{owner_address}}",
"{{coin_object_id}}",
"{{object_id}}",
"{{gas_object_id}}",
{{gas_budget}},
"{{to_address}}"],
Expand Down Expand Up @@ -171,16 +171,15 @@ curl --location --request POST $SUI_RPC_HOST \
"id":1}' | json_pp
```

Native transfer by `sui_transferObject` is supported for coin
objects only (including gas objects). Refer to
Native transfer by `sui_transferObject` is supported for any object that allows for public transfers. Refer to
[transactions](transactions.md#native-transaction) documentation for
more information about a native transfer. Non-coin objects cannot be
more information about a native transfer. Some objects cannot be
transferred natively and require a [Move call](#sui_movecall).

You should replace `{{owner_address}}` and `{{to_address}}` in the
command above with an actual address values, for example one obtained
from `wallet.conf`. You should also replace
`{{coin_object_id}}` and `{{gas_object_id}}` in the command above with
`{{object_id}}` and `{{gas_object_id}}` in the command above with
an actual object ID, for example one obtained from `objectId` in the output
of [`sui_getOwnedObjects`](#sui_getownedobjects). You can see that all gas objects generated
during genesis are of `Coin/SUI` type). For this call to work, objects
Expand All @@ -205,7 +204,7 @@ curl --location --request POST $SUI_RPC_HOST \
"coin",
"transfer",
["0x2::sui::sui"],
["{{coin_object_id}}", "{{recipient_address}}"],
["{{object_id}}", "{{recipient_address}}"],
"{{gas_object_id}}",
2000
],
Expand All @@ -224,11 +223,10 @@ function is described in more detail in
the [Sui Wallet](wallet.md#calling-move-code) documentation.

Calling the `transfer` function in the `Coin` module serves the same
purpose as the native coin transfer ([`sui_transferObject`](#sui_TransferObject)), and is mostly used for illustration
purpose as the native transfer ([`sui_transferObject`](#sui_TransferObject)), and is mostly used for illustration
purposes as native transfer is more efficient when it's applicable
(i.e., we are transferring coins rather than non-coin
objects). Consequently, you should fill out argument placeholders
(`{{owner_address}}`, `{{coin_object_id}`, etc.) the same way you
(i.e., we are simply transferring objects with no additional Move logic). Consequently, you should fill out argument placeholders
(`{{owner_address}}`, `{{object_id}`, etc.) the same way you
would for [`sui_transferObject`](#sui_TransferObject) - please note additional
`0x` prepended to function arguments.

Expand Down
23 changes: 17 additions & 6 deletions doc/src/build/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,25 @@ In addition to the common metadata above, a publish transaction includes Package

Native transactions are optimized versions of common Sui operations. Each native transaction is semantically equivalent to a specific Move call but has a lower gas cost.

### Transfer
### Transfer object

This transaction type transfers coins from the sender to the specified recipients.
This transaction type transfers objects from the sender to the specified recipients.

In addition to the common metadata above, a transfer transaction includes the following fields:
* Input: An object reference pointing to a mutable object owned by the sender. The object must be of type `sui::coin::Coin<T>` with arbitrary `T`--that is, any fungible token. The gas input object from above cannot also appear as an object input.
* Recipients: The addresses that will receive payments from this transfer. This list must be non-empty.
* Amounts: A list of unsigned integers encoding the amount that each recipient will receive. This list must be the same length as the recipients list. Each amount will be debited from the input object, wrapped in a freshly created coin object, and sent to the corresponding recipient address. The value of the input object must be greater than or equal to the sum of the amounts.
In addition to the common metadata above, a transfer object transaction includes the following fields:

* Input: An object reference pointing to a mutable object owned by the sender. The object must be of type that allows for public transfers--that is, any type with the `store` ability. The gas input object from above cannot also appear as the object input.
* Recipient: The address that will receive the object from this transfer.

### Transfer SUI

This transaction type is similar to the Transfer Object transaction type, but the input object type must be a SUI coin--that is, an object of type `sui::coin::Coin<sui::sui::SUI>`. The benefit of this transaction type is that a separate coin object is not needed for gas. The gas payment is taken from the SUI coin being transferred.
Optionally, an amount can be specified for partial transfers.

In addition to the common metadata above, a transfer SUI transaction includes the following fields:

* Input: An object reference pointing to a `sui::coin::Coin<sui::sui::SUI>` object owned by the sender.
* (Optional) Amount: An unsigned integer encoding the amount that the recipient will receive. The amount will be debited from the input object, wrapped in a freshly created coin object, and sent to the corresponding recipient address. The value of the input object must be greater than or equal to the amount specified.
* Recipient: The address that will receive the coin from this transfer.

### Join

Expand Down

0 comments on commit a4b27aa

Please sign in to comment.