Post
Share your knowledge.
Xavier.eth260
Mar 17, 2025
Expert Q&A
How to assign multiple variables from a tuple in CLI for PTB?
I'm working with the CLI and calling a function 0x2::transfer_policy::confirm_request
that returns a tuple (item, paid, from)
. I want to use these values in a PTB command. How can I assign each element of this tuple to separate variables using CLI?
- Move CLI
- Move
2
2
Share
Comments
Answers
2dudley_smith124
Mar 18 2025, 04:59So just to confirm after Ashok's addition, in the PTB command you would do something similar to:
sui client ptb \
--move-call [...] \
--assign result \
--assign item result.0 \
--assign paid result.1 \
--assign from result.2
[...the rest of the PTB]
2
Comments
Ramirez177
Mar 17 2025, 18:13Not at the moment. You can assign them individually by using the tuple index. For instance, you will get the tuple as a result, so you can just get each element and assign it separately. You can do this as follows:
--assign item result.0
--assign paid result.1
--assign from result.2
1
Comments
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.
148Posts231Answers
Bounty Posts