Move.

Post

Share your knowledge.

Jeremy.
Nov 16, 2023
Expert Q&A

Creating tx_bytes Based on sui_getNormalizedMoveFunction Output: Move modue examples

I am looking for examples or guidance on how to create tx_bytes after receiving data from sui_getNormalizedMoveFunction in Golang, PHP, and JavaScript. Essentially, I want to populate Move function parameters using the output from sui_getNormalizedMoveFunction, prepare/sign the transaction, and then send it using sui_executeTransactionBlock. Is this the correct flow for executing Move functions, and if so, how can I generate the necessary parameters? For example, I am trying to call the mint method from the Move package 0xf5b55a91957b68f23107522abf96634a0d58ccad6ff9ecd6daf3eba8808b3dd9, and the function requires parameters such as MintApp, Clock, Coin, Kiosk, KioskOwnerCap, and TransferPolicy<SuiFren>. I can retrieve MintApp and Clock from other Sui transaction examples, but I am unsure about the rest of the parameters. I thought I could obtain these parameters from sui_getNormalizedMoveFunction, but I am uncertain about the approach.

  • Move
1
2
Share
Comments
.

Answers

2
Jackson.
Nov 16 2023, 13:11

It seems you're looking to execute a Move Sui transaction, and the sui_getNormalizedMoveFunction provides some data about the Move package. To make a transaction, you can use the unsafe_*** JSON RPC calls documented in the Sui JSON RPC documentation. This call will return the transaction bytes (tx_bytes) that you can then sign and execute the transaction with.

Here are a few suggestions to help you proceed:

  1. Use the TypeScript SDK: If possible, start with the TypeScript SDK provided by the project. Using the SDK can help you by providing types and function arguments, making it easier to work with the Move functions without having to call unsafe_moveCall. You can find more information and resources in the SUI TypeScript documentation.
  2. Object IDs and Addresses: For some parameters, you'll need to know the object IDs. For example, if you're dealing with a Kiosk, you should know the Kiosk's ObjectID. Similarly, if you're the KioskOwnerCap, you'll need its ObjectID. The Clock object has a fixed ObjectID of 0x6.
  3. Argument Types for unsafe_payMove: When calling unsafe_payMove, provide the required arguments in the arguments type, which takes a list of JSON values. These values should be strings representing the IDs or addresses. For instance, "0x2::sui::SUI" represents an address. By following these steps and understanding the parameters and object IDs, you can create the necessary tx_bytes and execute your Move Sui transactions.
0
Comments
.
Steven.
Nov 16 2023, 13:38

The process you're describing is generally correct for executing Move functions on the Sui blockchain. Here's a step-by-step guide on how you might approach this:

  1. Call sui_getNormalizedMoveFunction: This function returns the normalized form of a Move function, which includes the function's name, parameters, and return type. You can use this information to understand what parameters the function requires.
  2. Generate the necessary parameters: The parameters required for the function call will depend on the function itself. In your case, you're trying to call the mint function in the 0xf5b55a91957b68f23107522abf96634a0d58ccad6ff9ecd6daf3eba8808b3dd9 Sui package. You've mentioned that you can retrieve MintApp and Clock from other transaction examples. For the other parameters (Coin, Kiosk, KioskOwnerCap, and TransferPolicy<SuiFren>), you may need to retrieve these from the Sui blockchain or generate them yourself.
  3. Prepare and sign the Sui transaction: Once you have all the necessary parameters, you can prepare the transaction. This will involve creating a transaction block that includes the function call and its parameters. You'll then need to sign this transaction block using your private key.
  4. Send the transaction using sui_executeTransactionBlock: Finally, you can send the signed transaction block to the Sui blockchain using the sui_executeTransactionBlock function.
0
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