Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain that no struct can be created as transaction input other than some exceptions #91

Merged
merged 10 commits into from
Aug 27, 2024
21 changes: 21 additions & 0 deletions book/src/concepts/what-is-a-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ Transactions consist of:
- a gas object - the `Coin` object used to pay for the transaction;
- gas price and budget - the cost of the transaction;

## Inputs

Transaction inputs are the arguments for the transaction and are split between 2 types:
- Pure arguments: These are mostly [primitive types](../move-basics/primitive-types.html) with some
extra additions. A pure argument can be:
- boolean
- integer (u8, u16, u32, u64, u128, u256)
- address
- std::ascii::String
nikos-terzo marked this conversation as resolved.
Show resolved Hide resolved
- std::string::String
- vector of pure types
- Option of pure types
damirka marked this conversation as resolved.
Show resolved Hide resolved
- ID, a special type that refers to a unique identifier of an object
Copy link
Collaborator

@damirka damirka Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, not a special type, defined in sui::object::ID. Link one of the object chapters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object/object-model seems more appropriate as it refers to the UID.

Copy link
Contributor Author

@nikos-terzo nikos-terzo Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After all, I linked storage/uid-and-id. I also referred to object/object-model as "See also".
a49b910

- Object arguments: These are objects or references of objects that the transaction will access. An
object argument needs to be either a shared object, a frozen object, or an object that the
transaction sender owns, in order for the transaction to be successfull.
For more see [Object Model](http://localhost:3000/object/index.html).

Note that a single command inside a transaction can also have a previous command's result as input.
damirka marked this conversation as resolved.
Show resolved Hide resolved
These results/inputs can be anything from a simple value, an object, or any kind of Move struct.

## Commands

Sui transactions may consist of multiple commands. Each command is a single built-in command (like
Expand Down
4 changes: 4 additions & 0 deletions book/src/programmability/bcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Structs encode similarly to simple types. Here is how to encode a struct using B
{{#include ../../../packages/samples/sources/programmability/bcs.move:encode_struct}}
```

Note that encoding a custom struct does not make much sense in interacting with the Move VM, as
damirka marked this conversation as resolved.
Show resolved Hide resolved
they cannot be created this way to use in Move VM. See also
[Transaction Inputs](../concepts/what-is-a-transaction.html#inputs).

## Decoding

Because BCS does not self-describe and Move is statically typed, decoding requires prior knowledge of the data type. The `sui::bcs` module provides various functions to assist with this process.
Expand Down
Loading