Post

Share your knowledge.

Post

Share your knowledge.

Xavier.eth.
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

2
dudley_smith.
Mar 18 2025, 04:59

So 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
.
Ramirez.
Mar 17 2025, 18:13

Not 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
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignJune
    We use cookies to ensure you get the best experience on our website.
    More info