rpc_json_builder.c (RPC JSON Builder)
This file implements JSON-RPC request builders for MicroSui.
It provides helpers to construct Sui-compatible JSON-RPC payloads from serialized transaction data and signatures, handling Base64 encoding and request parameter formatting as required by the Sui RPC specification.
The functions in this file are focused on request construction only and do not perform network communication, making them suitable for use in embedded and constrained environments.
File Location
Defined in microsui-lib/src/microsui_core/rpc_json_builder.c
microsui_prepare_executeTransactionBlock
Description
Prepare a JSON-RPC request to execute a Sui transaction block.
Takes a Sui signature and a serialized transaction message, encodes both into Base64, and constructs a JSON string compatible with the sui_executeTransactionBlock RPC method.
The resulting JSON includes flags to request transaction effects, events, object changes, and balance changes in the RPC response.
char* microsui_prepare_executeTransactionBlock(const uint8_t sui_sig[97], const uint8_t* sui_msg, size_t sui_msg_len)
Parameters
| Name | Type | Description |
|---|---|---|
sui_sig | const uint8_t [97] | Pointer to a 97-byte Sui signature (scheme + sig + pubkey) |
sui_msg | const uint8_t* | Pointer to the serialized Sui transaction bytes |
sui_msg_len | size_t | Length of the serialized transaction in bytes |
Returns
char* : Pointer to a heap-allocated null-terminated JSON string, or NULL on error. The caller is responsible for freeing this buffer with free().
Example usage
Given:
- A defined
sui_sig: A 97-byte Sui signature. - A defined
sui_msg: Transaction message (BCS-encoded) in Bytes format, andsui_msg_lensize.
You obtain the Json with the next function:
char* json = microsui_prepare_executeTransactionBlock(sui_sig, sui_msg, sui_msg_len);
// After use the string, we need free the memory allocation to avoid memory leaks.
free(json);