# Table of Contents - [byte_conversions.c (Byte Util Conversions) | MicroSui Docs](#byte-conversions-c-byte-util-conversions-microsui-docs) - [cryptography.c (Cryptography) | MicroSui Docs](#cryptography-c-cryptography-microsui-docs) - [rpc_json_builder.c (RPC JSON Builder) | MicroSui Docs](#rpc-json-builder-c-rpc-json-builder-microsui-docs) - [sign.c (Signatures) | MicroSui Docs](#sign-c-signatures-microsui-docs) - [Client | MicroSui Docs](#client-microsui-docs) - [API Reference | MicroSui Docs](#api-reference-microsui-docs) - [Keypair | MicroSui Docs](#keypair-microsui-docs) - [Getting Started | MicroSui Docs](#getting-started-microsui-docs) - [Transaction | MicroSui Docs](#transaction-microsui-docs) - [WiFi | MicroSui Docs](#wifi-microsui-docs) - [-Types- | MicroSui Docs](#-types-microsui-docs) - [Examples | MicroSui Docs](#examples-microsui-docs) - [Broadcast Transaction to Sui Network | MicroSui Docs](#broadcast-transaction-to-sui-network-microsui-docs) - [Bytes,Base64,Hexa - Encode/Decode | MicroSui Docs](#bytes-base64-hexa-encode-decode-microsui-docs) - [Validating a Sui Signature for a given message | MicroSui Docs](#validating-a-sui-signature-for-a-given-message-microsui-docs) - [Obtain Sui Address and Public Key from Private Key | MicroSui Docs](#obtain-sui-address-and-public-key-from-private-key-microsui-docs) - [key_management.c (Key Management) | MicroSui Docs](#key-management-c-key-management-microsui-docs) - [SDK Classes | MicroSui Docs](#sdk-classes-microsui-docs) - [Core C functions | MicroSui Docs](#core-c-functions-microsui-docs) - [Offline Sign (Get Signature) | MicroSui Docs](#offline-sign-get-signature-microsui-docs) - [Overview | MicroSui Docs](#overview-microsui-docs) --- # byte_conversions.c (Byte Util Conversions) | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#__docusaurus_skipToContent_fallback) On this page This file implements low-level byte and string conversion utilities for **_MicroSui_**. It provides deterministic helpers to convert between hexadecimal strings, raw byte buffers, and Base64-encoded strings. These utilities are used across the library to serialize and deserialize cryptographic data, signatures, and transaction payloads in formats required by the _Sui ecosystem_. All functions are designed to be lightweight, allocation-free (unless explicitly stated), and suitable for embedded and resource-constrained environments. File Location[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#file-location "Direct link to File Location") --------------------------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/microsui_core/byte_conversions.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/microsui_core/byte_conversions.c) * * * hex\_to\_bytes[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#hex_to_bytes "Direct link to hex_to_bytes") -------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description "Direct link to Description") Convert a hexadecimal string into its corresponding byte representation. The function parses the input hex string (two characters per byte) and writes the decoded bytes into the provided output buffer. The conversion stops after `bytes_len` bytes have been written. No dynamic memory allocation is performed. The caller is responsible for providing a sufficiently sized output buffer. void hex_to_bytes(const char* hex_str, uint8_t* bytes, uint32_t bytes_len) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `hex_str` | `const char *` | Input Hexadecimal character string | | `bytes` | `uint8_t *` | Output bytes array buffer for the converted data in bytes format | | `bytes_len` | `uint32_t` | Input size of the `bytes` buffer array | ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage "Direct link to Example usage") Given: * A defined `hex_str`: Data in hexadecimal string format, in this example `hex_str` is a Singature in Hexadecimal format. You can convert the Hexa string in bytes as follows: uint8_t output_signature_bytes_from_hex[97] // We initialize it emptyhex_to_bytes(hex_str, output_signature_bytes_from_hex, sizeof(output_signature_bytes_from_hex)); * * * bytes\_to\_hex[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#bytes_to_hex "Direct link to bytes_to_hex") -------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description-1 "Direct link to Description") Convert a byte buffer into a lowercase hexadecimal string. Each input byte is encoded as two hexadecimal characters. The resulting string is written to the provided output buffer and is null-terminated. The caller must ensure that the output buffer is large enough to hold `bytes_len * 2 + 1` characters. void bytes_to_hex(const uint8_t* bytes, uint32_t bytes_len, char* hex_str) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `bytes` | `uint8_t *` | Input buffer for data in bytes format | | `bytes_len` | `uint32_t` | Input size of the input `bytes` data array | | `hex_str` | `char *` | Output string buffer for the converted data in hexa string format | ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage-1 "Direct link to Example usage") Given: * A defined `sui_sig`: Data in bytes array format, in this example `sui_sig` is a Singature in bytes array format. You can convert the Hexa string in bytes as follows: char sui_sig_hex[195]; // 2 hex chars per byte + null terminatorbytes_to_hex(sui_sig, 97, sui_sig_hex); // 97 bytes is the length of a Sui Signature * * * bytes\_to\_base64[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#bytes_to_base64 "Direct link to bytes_to_base64") ----------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description-2 "Direct link to Description") Encode a byte buffer into a Base64-encoded string. The function converts the input byte array into a Base64 representation and writes the result into the provided output buffer, including a null terminator. The output is compatible with standard Base64 encoding as required by Sui RPC interfaces. Returns an error if the output buffer is too small or if encoding fails. int bytes_to_base64(const uint8_t* input, size_t input_len, char* output, size_t output_size) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters-2 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `input` | `uint8_t *` | Input buffer for data in bytes format | | `input_len` | `size_t` | Input size of the `input` bytes data array | | `output` | `char *` | Output string buffer for the converted data in base64 string format | | `output_len` | `size_t` | Input size of the buffer `output` | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#returns "Direct link to Returns") * `0` on success. * `1` on error. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage-2 "Direct link to Example usage") Given: * A defined `input`: Data in bytes array format, in this example `input` is a Singature in bytes array format. You can convert the bytes array in a base64 String as follows: char output_signature_base64[((97 + 2) / 3 * 4) + 1]; // Base64 output size calculation + 1 for null terminatorint status = bytes_to_base64(sui_sig, sizeof(sui_sig), output_sig_base64, sizeof(output_sig_base64));if (status == 0) // Converted signature is now stored in output_signature_base64 * * * base64\_to\_bytes[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#base64_to_bytes "Direct link to base64_to_bytes") ----------------------------------------------------------------------------------------------------------------------------------------------- int base64_to_bytes(const char* input, size_t input_len, uint8_t* output, size_t output_size) ### Description[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description-3 "Direct link to Description") Decode a Base64-encoded string into its raw byte representation. The function parses the input Base64 string and writes the decoded bytes into the provided output buffer. The caller must ensure the output buffer is large enough to hold the decoded data. Returns an error if decoding fails due to invalid input or insufficient buffer size. ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters-3 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `input` | `char *` | Input buffer for data in string base64 format | | `input_len` | `size_t` | Input size of the `input` string | | `output` | `uint8_t *` | Output bytes buffer for the converted data in bytes format | | `output_len` | `size_t` | Input size of the buffer `output` | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#returns-1 "Direct link to Returns") * `0` on success. * `1` on error. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage-3 "Direct link to Example usage") Given: * A defined input `sig_base64`: Data in bytes array format, in this example `input` is a Singature in base64 string. You can convert the base64 string in a bytes array as follows: uint8_t output_sig_bytes[SIG_BASE64_LEN]; // Provide a large enough buffer to prevent overflow. Typically, `(sig_base64_len / 4) * 3` is sufficient (but the exact value depends on other factors).status = base64_to_bytes(sig_base64, strlen(sig_base64), output_sig_bytes, strlen(output_sig_bytes));if status == 0: // Converted signature is now stored in output_sig_bytes * [File Location](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#file-location) * [hex\_to\_bytes](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#hex_to_bytes) * [Description](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage) * [bytes\_to\_hex](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#bytes_to_hex) * [Description](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description-1) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters-1) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage-1) * [bytes\_to\_base64](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#bytes_to_base64) * [Description](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description-2) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters-2) * [Returns](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#returns) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage-2) * [base64\_to\_bytes](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#base64_to_bytes) * [Description](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#description-3) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#parameters-3) * [Returns](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#returns-1) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/byte_conversions#example-usage-3) --- # cryptography.c (Cryptography) | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/functions/cryptography#__docusaurus_skipToContent_fallback) On this page This file implements core cryptographic utility functions for **_MicroSui_**. It provides encoding and decoding helpers for Sui-compatible key formats, including Bech32 private key representation with the `suiprivkey` prefix. These utilities are used to convert between raw cryptographic key material and the standardized formats expected by the Sui ecosystem. All functions are designed for deterministic behavior and compatibility with resource-constrained and embedded environments. File Location[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#file-location "Direct link to File Location") ----------------------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/microsui_core/cryptography.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/microsui_core/cryptography.c) * * * microsui\_encode\_sui\_privkey[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#microsui_encode_sui_privkey "Direct link to microsui_encode_sui_privkey") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#description "Direct link to Description") Encodes a 32-byte Ed25519 private key into a Bech32 string with the Sui prefix `suiprivkey1`. The output includes the `0x00` scheme flag byte and a valid 6-character Bech32 checksum, producing a fully compatible Sui private key string. int microsui_encode_sui_privkey(const uint8_t *privkey_bytes, char *privkey_bech_output) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `privkey_bytes` | `const uint8_t *` | Input bytes array of the Private/Secret Key in bytes format | | `privkey_bech_output` | `char *` | Output buffer for the encoded Private/Secret Key in Bech32 format | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#returns "Direct link to Returns") * `0` on success. * `-1` if encoding fails (e.g. due to bad input, insufficient buffer size or internal conversion failure). ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#example-usage "Direct link to Example usage") Given: * A defined `privkey_bytes`: Private/Secret Key in Bytes format. You can decode the key as follows: char privkey_bech_output[71]; // We initialize it emptyint status = microsui_encode_sui_privkey(privkey_bytes, privkey_bech_output);if (status == 0) // Decoded key is now stored in privkey_bech_output * * * microsui\_decode\_sui\_privkey[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#microsui_decode_sui_privkey "Direct link to microsui_decode_sui_privkey") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#description-1 "Direct link to Description") Decode a Sui _Bech32 private key (secret key)_ string into 32 raw bytes. Validates the _Bech32-encoded private key_ (HRP = "suiprivkey", no mixed case), converts the 5-bit words back to 8-bit bytes, and extracts the 32-byte secret (sk) after the 1-byte scheme flag. int microsui_decode_sui_privkey(const char *privkey_bech, uint8_t privkey_bytes_output[32]) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `privkey_bech` | `const char *` | Input string of the Private/Secret Key in Bech32 format | | `privkey_bytes_output` | `uint8_t[32]` | Output buffer for the decoded Private/Secret Key in bytes format | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#returns-1 "Direct link to Returns") * `0` on success. * `-1` on fail. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/cryptography#example-usage-1 "Direct link to Example usage") Given: * A defined `privkey_bech`: Private/Secret Key in Bech32 format. E.g.: `suiprivkey1...` You can decode the key as follows: uint8_t private_key[97]; // We initialize it emptyint status = microsui_decode_sui_privkey(privkey_bech, private_key);if (status == 0) // Decoded key is now stored in private_key * [File Location](https://docs.microsui.com/docs/api_reference/functions/cryptography#file-location) * [microsui\_encode\_sui\_privkey](https://docs.microsui.com/docs/api_reference/functions/cryptography#microsui_encode_sui_privkey) * [Description](https://docs.microsui.com/docs/api_reference/functions/cryptography#description) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/cryptography#parameters) * [Returns](https://docs.microsui.com/docs/api_reference/functions/cryptography#returns) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/cryptography#example-usage) * [microsui\_decode\_sui\_privkey](https://docs.microsui.com/docs/api_reference/functions/cryptography#microsui_decode_sui_privkey) * [Description](https://docs.microsui.com/docs/api_reference/functions/cryptography#description-1) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/cryptography#parameters-1) * [Returns](https://docs.microsui.com/docs/api_reference/functions/cryptography#returns-1) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/cryptography#example-usage-1) --- # rpc_json_builder.c (RPC JSON Builder) | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#__docusaurus_skipToContent_fallback) On this page 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[​](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#file-location "Direct link to File Location") --------------------------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/microsui_core/rpc_json_builder.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/microsui_core/rpc_json_builder.c) * * * microsui\_prepare\_executeTransactionBlock[​](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#microsui_prepare_executetransactionblock "Direct link to microsui_prepare_executeTransactionBlock") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#description "Direct link to 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[​](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#parameters "Direct link to 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[​](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#returns "Direct link to 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[​](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#example-usage "Direct link to Example usage") Given: * A defined `sui_sig`: A 97-byte Sui signature. * A defined `sui_msg`: Transaction message (BCS-encoded) in Bytes format, and `sui_msg_len` size. 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); * [File Location](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#file-location) * [microsui\_prepare\_executeTransactionBlock](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#microsui_prepare_executetransactionblock) * [Description](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#description) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#parameters) * [Returns](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#returns) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder#example-usage) --- # sign.c (Signatures) | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/functions/sign#__docusaurus_skipToContent_fallback) On this page This file implements the _core signing_ logic for **_MicroSui_**. It provides a generic signing interface (`microsui_sign`) and concrete implementations for _Sui-compatible signature schemes_. The signing process follows the Sui specification, including intent-prefixed message hashing and Sui-formatted signature encoding. Currently, **only the _Ed25519_ scheme is implemented**. Additional schemes (_Secp256k1, Secp256r1, MultiSig, zkLogin, Passkey_)are planned and will be added incrementally. File Location[​](https://docs.microsui.com/docs/api_reference/functions/sign#file-location "Direct link to File Location") --------------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/microsui_core/sign.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/microsui_core/sign.c) * * * microsui\_sign[​](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_sign "Direct link to microsui_sign") ---------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/sign#description "Direct link to Description") Generic signing entry point for multiple signature schemes. Dispatches to the appropriate signing routine depending on the provided scheme identifier. Currently only _**Ed25519**_ (`0x00`) is implemented. int microsui_sign(uint8_t scheme, uint8_t sui_sig[97], const uint8_t* message, const size_t message_len, const uint8_t private_key[32]) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/sign#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `scheme` | `uint8_t` | Identifier of the signing scheme.
Supported schemes:
\- 0x00: Ed25519 (implemented)
\- Others (Secp256k1, Secp256r1, Multisig, zkLogin, Passkey) are not yet implemented. | | `sui_sig` | `uint8_t[97]` | Output buffer for the generated Sui signature. Format:
• Byte 0: Scheme
• Bytes 1–64: Ed25519 signature
• Bytes 65–96: Ed25519 public key | | `message` | `const uint8_t*` | Message to sign in hexadecimal bytes format | | `message_len` | `size_t` | Length of the message. | | `private_key` | `const uint8_t[32]` | Raw 32-byte Ed25519 private key used for signature generation. | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/sign#returns "Direct link to Returns") * `0` on success. * `-1` on fail. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage "Direct link to Example usage") Given: * A defined `scheme`: `0x00` (Ed25519 scheme) * A bytes array `message`: `[0x00, 0x01, 0x02, 0x03, 0x04, 0x05]` (message\_len = 6) * A 32-byte _Ed25519_ private key You can generate a signature as follows: uint8_t sui_sig[97]; // Placeholder for the Sui signature. We initialize it emptyint status = microsui_sign(scheme, sui_sig, message, message_len, private_key);if (status == 0) // Signature is now stored in sui_sig * * * microsui\_sign\_ed25519[​](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_sign_ed25519 "Direct link to microsui_sign_ed25519") ----------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/sign#description-1 "Direct link to Description") Sign a Sui Transaction message using _Ed25519_ and produce a _Sui-formatted signature_. Builds the "message with intent" (prefix + tx bytes), digests it with _BLAKE2b_, signs the digest with _Ed25519_, and encodes the result in the Sui signature format (scheme byte + 64-byte _Ed25519_ signature + 32-byte public key). int microsui_sign_ed25519(uint8_t sui_sig[97], const uint8_t* message, const size_t message_len, const uint8_t private_key[32]) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `sui_sig` | `uint8_t[97]` | Output buffer for the generated Sui signature. Format:
• Byte 0: `0x00` (Ed25519 scheme)
• Bytes 1–64: Ed25519 signature
• Bytes 65–96: Ed25519 public key | | `message` | `const uint8_t*` | Message to sign in hexadecimal bytes format | | `message_len` | `size_t` | Length of the message. | | `private_key` | `const uint8_t[32]` | Raw 32-byte Ed25519 private key used for signature generation. | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/sign#returns-1 "Direct link to Returns") * `0` on success. * `-1` on fail. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-1 "Direct link to Example usage") Given: * A bytes array `message`: `[0x00, 0x01, 0x02, 0x03, 0x04, 0x05]` (message\_len = 6) * A 32-byte Ed25519 private key You can generate a signature as follows: uint8_t sui_sig[97]; // We initialize it emptyint status = microsui_sign_ed25519(sui_sig, message, message_len, private_key);if (status == 0) // Signature is now stored in sui_sig * * * microsui\_verify\_signature[​](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_verify_signature "Direct link to microsui_verify_signature") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/sign#description-2 "Direct link to Description") Verifies that the provided _Sui-formatted signature_ **is valid** for the given _serialized message_. Generic **signature verification** entry point for multiple signature schemes. Dispatches to the appropriate verification routine based on the **scheme byte** found in the provided _Sui Signature_ (`sui_sig[0]`). Currently only **_Ed25519_** (`0x00`) is implemented. int microsui_verify_signature(uint8_t sui_sig[97], const uint8_t* message, const size_t message_len) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-2 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `sui_sig` | `uint8_t[97]` | Output buffer for the generated Sui signature. Format:
• Byte 0: `0x00` (Ed25519 scheme)
• Bytes 1–64: Ed25519 signature
• Bytes 65–96: Ed25519 public key | | `message` | `const uint8_t*` | Message to sign in hexadecimal bytes format | | `message_len` | `size_t` | Length of the message. | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/sign#returns-2 "Direct link to Returns") * `0` if the signature is valid for the detected scheme. * `-1` if the scheme is unsupported or verification fails. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-2 "Direct link to Example usage") Given: * A Message or Transaction bytes data `message` (`uint8_t[]` type). * A valid Sui Signature `sui_sig` (`uint8_t[97]` type). You can check if as follows: int verification = microsui_verify_signature(sui_sig, message, message_len);if (verification == 0) // Sui-formatted signature IS VALID for the given serialized message * * * microsui\_verify\_signature[​](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_verify_signature-1 "Direct link to microsui_verify_signature") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/sign#description-3 "Direct link to Description") Verifies that the provided _Sui-formatted Ed25519 signature_ **is valid** for the given _serialized message_. Expects a Sui signature encoded as: `[0x00 scheme | 64-byte Ed25519 signature | 32-byte public key]` int microsui_verify_signature_ed25519(uint8_t sui_sig[97], const uint8_t* message, const size_t message_len) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-3 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `sui_sig` | `uint8_t[97]` | Output buffer for the generated Ed25519 Sui signature. | | `message` | `const uint8_t*` | Message to sign in hexadecimal bytes format | | `message_len` | `size_t` | Length of the message. | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/sign#returns-3 "Direct link to Returns") * `0` if the signature is valid. * `-1` if the signature is invalid or the scheme byte is not Ed25519 (0x00). ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-3 "Direct link to Example usage") Given: * A Message or Transaction bytes data `message` (`uint8_t[]` type). * A valid Sui Ed25519 Signature `sui_ed25519_sig` (`uint8_t[97]` type). You can check if as follows: int verification = microsui_verify_signature_ed25519(sui_ed25519_sig, message, message_len);if (verification == 0) // Sui-formatted signature IS VALID for the given serialized message * * * microsui\_sign\_message (Deprecated)[​](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_sign_message-deprecated "Direct link to microsui_sign_message (Deprecated)") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ### Description[​](https://docs.microsui.com/docs/api_reference/functions/sign#description-4 "Direct link to Description") **_\[DEPRECATED\]_** Use `microsui_sign()` or `microsui_sign_ed25519()` instead. This function is kept only for backward compatibility. Please use `microsui_sign()` or `microsui_sign_ed25519()`, which provide better compatibility and performance. int microsui_sign_message(uint8_t sui_sig[97], const char* message_hex, const uint8_t private_key[32]); ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-4 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `sui_sig` | `uint8_t[97]` | Output buffer for the generated Sui signature. Format:
• Byte 0: `0x00` (Ed25519 scheme)
• Bytes 1–64: Ed25519 signature
• Bytes 65–96: Ed25519 public key | | `message_hex` | `const char*` | Null-terminated string representing the message in hexadecimal (2 hex chars per byte). | | `private_key` | `const uint8_t[32]` | Raw 32-byte Ed25519 private key used for signature generation. | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/sign#returns-4 "Direct link to Returns") * `0` on success. * `-1` on fail. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-4 "Direct link to Example usage") Given: * A hexadecimal message: `"48656c6c6f2053756921"` (which is `"Hello Sui!"`) * A 32-byte Ed25519 private key You can generate a signature as follows: uint8_t sui_sig[97]; // We initialize it emptyint status = microsui_sign_message(sui_sig, message_hex, private_key);if (status == 0) // Signature is now stored in sui_sig * [File Location](https://docs.microsui.com/docs/api_reference/functions/sign#file-location) * [microsui\_sign](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_sign) * [Description](https://docs.microsui.com/docs/api_reference/functions/sign#description) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/sign#parameters) * [Returns](https://docs.microsui.com/docs/api_reference/functions/sign#returns) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage) * [microsui\_sign\_ed25519](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_sign_ed25519) * [Description](https://docs.microsui.com/docs/api_reference/functions/sign#description-1) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-1) * [Returns](https://docs.microsui.com/docs/api_reference/functions/sign#returns-1) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-1) * [microsui\_verify\_signature](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_verify_signature) * [Description](https://docs.microsui.com/docs/api_reference/functions/sign#description-2) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-2) * [Returns](https://docs.microsui.com/docs/api_reference/functions/sign#returns-2) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-2) * [microsui\_verify\_signature](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_verify_signature-1) * [Description](https://docs.microsui.com/docs/api_reference/functions/sign#description-3) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-3) * [Returns](https://docs.microsui.com/docs/api_reference/functions/sign#returns-3) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-3) * [microsui\_sign\_message (Deprecated)](https://docs.microsui.com/docs/api_reference/functions/sign#microsui_sign_message-deprecated) * [Description](https://docs.microsui.com/docs/api_reference/functions/sign#description-4) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/sign#parameters-4) * [Returns](https://docs.microsui.com/docs/api_reference/functions/sign#returns-4) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/sign#example-usage-4) --- # Client | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/sdk/client#__docusaurus_skipToContent_fallback) On this page _MicroSui Object-style_ RPC client for interacting with a Sui full node. Provides a small OO-like API (struct + function pointers) to talk to a Sui RPC endpoint over HTTP(S). **The current focus is submitting transactions, but this module is designed to expand into a general-purpose blockchain client for data queries as well.** **Client capabilities:** RPC binding, keypair TX sign-execute, and execution of pre-signed transactions. **IMPORTANT NOTE:** ✅ _Compatibility & Support:_ This class is fully supported and production-stable (as of this documentation release) on:       - **ESP32 series** — including all existing and future variants within the family       - **Desktop platforms** — Windows, macOS, Linux, and Unix-based operating systems ⚠️ Support for additional embedded architectures may be added in upcoming releases. Inspired by the **_Mysten Labs_ TypeScript SDK**, adapted for embedded C. * * * File Location[​](https://docs.microsui.com/docs/api_reference/sdk/client#file-location "Direct link to File Location") ----------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/Client.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/Client.c) * * * Indexs[​](https://docs.microsui.com/docs/api_reference/sdk/client#indexs "Direct link to Indexs") -------------------------------------------------------------------------------------------------- ### Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/client#constructors "Direct link to Constructors") * [`SuiClient_newClient`](https://docs.microsui.com/docs/api_reference/sdk/client#suiclient_newclient) ### Methods[​](https://docs.microsui.com/docs/api_reference/sdk/client#methods "Direct link to Methods") * [`signAndExecuteTransaction`](https://docs.microsui.com/docs/api_reference/sdk/client#signandexecutetransaction) * [`executeTransactionBlock`](https://docs.microsui.com/docs/api_reference/sdk/client#executetransactionblock) * * * Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/client#constructors-1 "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------- ### `SuiClient_newClient`[​](https://docs.microsui.com/docs/api_reference/sdk/client#suiclient_newclient "Direct link to suiclient_newclient") SuiClient_newClient(const char* rpc_url): MicroSuiClient Create a new [`MicroSuiClient`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) bound to an RPC URL. Initializes the client struct, safely copies the provided URL into an internal buffer, and assigns method pointers. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/client#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `rpc_url` | `const char*` | Null-terminated RPC endpoint URL (e.g. `"https://host:443/"`). | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/client#returns "Direct link to Returns") * [`MicroSuiClient`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/client#example-usage "Direct link to Example usage") const char* rpc_url = "https://fullnode.testnet.sui.io:443/"; // Sui Testnet fullnode RPC URLMicroSuiClient client = SuiClient_newClient(rpc_url);if (client.rpc_url != NULL) // client created successfully Methods[​](https://docs.microsui.com/docs/api_reference/sdk/client#methods-1 "Direct link to Methods") ------------------------------------------------------------------------------------------------------- ### `signAndExecuteTransaction`[​](https://docs.microsui.com/docs/api_reference/sdk/client#signandexecutetransaction "Direct link to signandexecutetransaction") signAndExecuteTransaction(MicroSuiClient *self, MicroSuiEd25519 kp, MicroSuiTransaction tx): SuiTransactionBlockResponse Sign a transaction and execute it via the Sui RPC. Converts transaction bytes to hex, asks the keypair to sign the message, builds the JSON RPC request, performs the HTTP POST, and decodes the JSON response into the provided response structure. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/client#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiClient *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) | Pointer to client instance (must contain a valid rpc\_url) | | `kp` | [`MicroSuiEd25519`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) | Keypair used to sign the transaction bytes | | `tx` | [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) | Transaction holding raw bytes to be signed/executed | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/client#returns-1 "Direct link to Returns") * [`SuiTransactionBlockResponse`](https://docs.microsui.com/docs/api_reference/sdk/types#suitransactionblockresponse) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/client#example-usage-1 "Direct link to Example usage") Given: * A valid client instance `client`: [`MicroSuiClient`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) type. * A valid keypair instance `keypair`: [`MicroSuiEd25519`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) type. * A valid transaction instance `transaction`: [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) type. We can execute the transaction with the following function: SuiTransactionBlockResponse res = client.signAndExecuteTransaction(&client, keypair, transaction);if (res.digest != NULL) // Transaction submited successfully to the Sui Netwrok ### `executeTransactionBlock`[​](https://docs.microsui.com/docs/api_reference/sdk/client#executetransactionblock "Direct link to executetransactionblock") executeTransactionBlock(MicroSuiClient *self, TransactionBytes txBytes, SuiSignature signature): SuiTransactionBlockResponse Sign a transaction and execute it via the Sui RPC. Receive the Transaction bytes and the Signature and generate the json to send to the Sui API Node. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/client#parameters-2 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiClient *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) | Pointer to client instance (must contain a valid rpc\_url) | | `txBytes` | [`TransactionBytes`](https://docs.microsui.com/docs/api_reference/sdk/types#transactionbytes) | Transaction bytes of the transaction to execute | | `signature` | [`SuiSignature`](https://docs.microsui.com/docs/api_reference/sdk/types#suisignature) | Signature of the transaction to execute | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/client#returns-2 "Direct link to Returns") * [`SuiTransactionBlockResponse`](https://docs.microsui.com/docs/api_reference/sdk/types#suitransactionblockresponse) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/client#example-usage-2 "Direct link to Example usage") Given: * A valid client instance `client`: [`MicroSuiClient`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) type. * A valid transaction bytes instance `transaction_bytes`: [`TransactionBytes`](https://docs.microsui.com/docs/api_reference/sdk/types#transactionbytes) type. * A valid signtaure instance `signature`: [`SuiSignature`](https://docs.microsui.com/docs/api_reference/sdk/types#suisignature) type. We can execute the transaction with the following function: SuiTransactionBlockResponse res = client.executeTransactionBlock(&client, transaction_bytes, signature);if (res.digest != NULL) // Transaction submited successfully to the Sui Netwrok * [File Location](https://docs.microsui.com/docs/api_reference/sdk/client#file-location) * [Indexs](https://docs.microsui.com/docs/api_reference/sdk/client#indexs) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/client#constructors) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/client#methods) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/client#constructors-1) * [`SuiClient_newClient`](https://docs.microsui.com/docs/api_reference/sdk/client#suiclient_newclient) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/client#methods-1) * [`signAndExecuteTransaction`](https://docs.microsui.com/docs/api_reference/sdk/client#signandexecutetransaction) * [`executeTransactionBlock`](https://docs.microsui.com/docs/api_reference/sdk/client#executetransactionblock) --- # API Reference | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/category/api-reference#__docusaurus_skipToContent_fallback) [🗃️ SDK Classes\ ---------------\ \ 5 items](https://docs.microsui.com/docs/category/sdk-classes) [🗃️ Core C functions\ --------------------\ \ 5 items](https://docs.microsui.com/docs/category/core-c-functions) --- # Keypair | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/sdk/keypair#__docusaurus_skipToContent_fallback) On this page _MicroSui Object-style_ for handling Ed25519 keypairs in MicroSui. Provides a small OO-like API (struct + function pointers) to work with Ed25519 keypairs in the context of the Sui blockchain. **This module provides core cryptographic utilities for creating and managing Sui-compatible keypairs and signatures.** **Keypair capabilities:** Generation of random Keypairs from fresh entropy, Initialize a keypair from a Bech32-encoded secret key string, Securely sign transaction messages using Ed25519, Retrieve the secret key (Bech32), public key (raw bytes), and derive the Sui-formatted address. **IMPORTANT NOTE:** ✅ _Compatibility & Support:_ This class is fully supported and production-stable (as of this documentation release) on any microcontroller and operating system. ⚠️ Functions returning strings or buffers use static internal storage. Results will be overwritten by subsequent calls and are not thread-safe. Inspired by the **_Mysten Labs_ TypeScript SDK**, adapted for embedded C. * * * File Location[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#file-location "Direct link to File Location") ------------------------------------------------------------------------------------------------------------------------ Defined in [`microsui-lib/src/Keypair.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/Keypair.c) * * * Indexs[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#indexs "Direct link to Indexs") --------------------------------------------------------------------------------------------------- ### Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#constructors "Direct link to Constructors") * [`SuiKeypair_generate`](https://docs.microsui.com/docs/api_reference/sdk/keypair#suikeypair_generate) * [`SuiKeypair_fromSecretKey`](https://docs.microsui.com/docs/api_reference/sdk/keypair#suikeypair_fromsecretkey) ### Methods[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#methods "Direct link to Methods") * [`signTransaction`](https://docs.microsui.com/docs/api_reference/sdk/keypair#signtransaction) * [`toSuiAddress`](https://docs.microsui.com/docs/api_reference/sdk/keypair#tosuiaddress) * [`getPublicKey`](https://docs.microsui.com/docs/api_reference/sdk/keypair#getpublickey) * [`getSecretKey`](https://docs.microsui.com/docs/api_reference/sdk/keypair#getsecretkey) * * * Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#constructors-1 "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------- ### `SuiKeypair_generate`[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#suikeypair_generate "Direct link to suikeypair_generate") SuiKeypair_generate(uint8_t seed_extra): MicroSuiEd25519 Generate a new Ed25519 keypair for Sui. Creates a MicroSuiEd25519 instance with a random secret key derived from the current system time and an extra seed value. Function pointers for signing, retrieving keys, and deriving the Sui address are also assigned. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `seed_extra` | `uint8_t` | Extra seed mixed with current time to initialize PRNG | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#returns "Direct link to Returns") * [`MicroSuiEd25519`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#example-usage "Direct link to Example usage") uint8_t seed_extra = 234584; // In embedded systems, it's recommended to read the // internal temperature sensor of the microcontroller, // which most microcontrollers have.MicroSuiEd25519 keypair = SuiKeypair_generate(seed_extra); ### `SuiKeypair_fromSecretKey`[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#suikeypair_fromsecretkey "Direct link to suikeypair_fromsecretkey") SuiKeypair_fromSecretKey(const char *sk): MicroSuiEd25519 Initialize a MicroSuiEd25519 keypair from a Bech32 secret key string. Decodes the provided Bech32 private key string and stores it in the new created struct. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `sk` | `const char *` | Bech32-encoded secret key string | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#returns-1 "Direct link to Returns") * [`MicroSuiEd25519`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#example-usage-1 "Direct link to Example usage") const char* sui_secret_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";MicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_secret_key_bech32); Methods[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#methods-1 "Direct link to Methods") -------------------------------------------------------------------------------------------------------- ### `signTransaction`[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#signtransaction "Direct link to signtransaction") signTransaction(MicroSuiEd25519 *self, const char *msg): SuiSignature Sign a transaction and execute it via the Sui RPC. Sign a transaction message with the Ed25519 private key. Converts a hex-encoded message string to bytes, signs it with Ed25519, and encodes the signature into Base64 format. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#parameters-2 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiEd25519 *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) | Pointer to MicroSuiEd25519 instance | | `msg` | `const char *` | Hex-encoded transaction message string | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#returns-2 "Direct link to Returns") * [`SuiSignature`](https://docs.microsui.com/docs/api_reference/sdk/types#suisignature) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#example-usage-2 "Direct link to Example usage") Given: * A valid secret key in bech32 format `sui_secret_key_bech32`: `const char *` type. * A valid Message to Sign string (in hexadecimal format) `messageToSign`: `const char *` type. We can generate the signature as following: const char* sui_secret_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";const char* messageToSign = "0000020008c0d8a700202e3d52393c9035afd1ef38abd7fce2dad71f0e276b522fb274f4e14d1d";MicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_secret_key_bech32);SuiSignature sig = keypair.signTransaction(&keypair, messageToSign);if (sig.signature != NULL) // Is a valid Signature ### `toSuiAddress`[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#tosuiaddress "Direct link to tosuiaddress") toSuiAddress(MicroSuiEd25519 *self): const char * Derive the Sui address from the Ed25519 public key. Computes the public key from the secret key, encodes it into a Sui address, and formats it as a hex string with the "0x" prefix. The returned string is stored in a static buffer and will be overwritten by subsequent calls. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#parameters-3 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiEd25519 *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) | Pointer to MicroSuiEd25519 instance | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#returns-3 "Direct link to Returns") * `const char *` string. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#example-usage-3 "Direct link to Example usage") Given: * A valid secret key in bech32 format `sui_secret_key_bech32`: `const char *` type. const char* sui_secret_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";MicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_secret_key_bech32);const char* suiAddress = keypair.toSuiAddress(&keypair);if (suiAddress != NULL) // Sui Address is valid ### `getPublicKey`[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#getpublickey "Direct link to getpublickey") getPublicKey(MicroSuiEd25519 *self): const uint8_t * Get the public key derived from the private key. Derives the 32-byte Ed25519 public key corresponding to the internal secret key. The returned buffer is static and will be overwritten by subsequent calls. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#parameters-4 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiEd25519 *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) | Pointer to MicroSuiEd25519 instance | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#returns-4 "Direct link to Returns") * `const uint8_t *` string. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#example-usage-4 "Direct link to Example usage") * A valid secret key in bech32 format `sui_secret_key_bech32`: `const char *` type. const char* sui_secret_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";MicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_secret_key_bech32);const uint8_t* publicKey = keypair.getPublicKey(&keypair);if (publicKey != NULL) // Public Key is valid ### `getSecretKey`[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#getsecretkey "Direct link to getsecretkey") getSecretKey(MicroSuiEd25519 *self): const char * Get the secret key in Bech32 string format. Encodes the internal 32-byte secret key into a Bech32-encoded string. The returned string is stored in a static buffer and will be overwritten by subsequent calls. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#parameters-5 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiEd25519 *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) | Pointer to MicroSuiEd25519 instance | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#returns-5 "Direct link to Returns") * `const char *` string. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/keypair#example-usage-5 "Direct link to Example usage") Given: * A valid secret key in bech32 format `sui_secret_key_bech32`: `const char *` type. const char* sui_secret_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";MicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_secret_key_bech32);const char* secretKey = keypair.getSecretKey(&keypair);if (secretKey != NULL) // Secret Key is valid * [File Location](https://docs.microsui.com/docs/api_reference/sdk/keypair#file-location) * [Indexs](https://docs.microsui.com/docs/api_reference/sdk/keypair#indexs) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/keypair#constructors) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/keypair#methods) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/keypair#constructors-1) * [`SuiKeypair_generate`](https://docs.microsui.com/docs/api_reference/sdk/keypair#suikeypair_generate) * [`SuiKeypair_fromSecretKey`](https://docs.microsui.com/docs/api_reference/sdk/keypair#suikeypair_fromsecretkey) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/keypair#methods-1) * [`signTransaction`](https://docs.microsui.com/docs/api_reference/sdk/keypair#signtransaction) * [`toSuiAddress`](https://docs.microsui.com/docs/api_reference/sdk/keypair#tosuiaddress) * [`getPublicKey`](https://docs.microsui.com/docs/api_reference/sdk/keypair#getpublickey) * [`getSecretKey`](https://docs.microsui.com/docs/api_reference/sdk/keypair#getsecretkey) --- # Getting Started | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/getting-started#__docusaurus_skipToContent_fallback) On this page Easy way - Arduino IDE[​](https://docs.microsui.com/docs/getting-started#easy-way---arduino-ide "Direct link to Easy way - Arduino IDE") ----------------------------------------------------------------------------------------------------------------------------------------- ![Arduino IDE](https://docs.microsui.com/img/arduinoLogo.jpg) The easiest way to use and test the **_MicroSui C-library_** is by using the **_Arduino IDE_** together with an **_ESP32 development board_** (any _ESP32_ model is supported). You only need to install the **_Arduino IDE_** on your computer (available for all major operating systems). Once installed, open it and go to _"Sketch → Include Library → Manage Libraries"_. This will open the Arduino Library Manager, where you can search for and install the library **_"MicroSui (by Gustavo Belbruno)"_**. ![](https://docs.microsui.com/img/arduino-library.png) After installation, you will find several ready-to-use examples in the **Examples** section. These examples can be uploaded to the microcontroller of your choice. The _ESP32_ is the recommended option for testing and development, as it offers the highest level of compatibility and is widely available. In addition, _ESP32_ development boards can be found almost anywhere in the world at a very affordable price (typically between 3 and 10 USD). tip You don’t need advanced hardware to get started. An **ESP32 development board** and a USB cable are enough to run the examples. ![](https://docs.microsui.com/img/esp32Boards.png) Production-oriented dev for professional devices - PlatformIO[​](https://docs.microsui.com/docs/getting-started#production-oriented-dev-for-professional-devices---platformio "Direct link to Production-oriented dev for professional devices - PlatformIO") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ![PlatformIO](https://docs.microsui.com/img/platformio-logo.png) For professional hardware and embedded systems development, the recommended environment is **_PlatformIO_**. It is similar to the _Arduino IDE_, but offers broader support for boards and microcontrollers, along with a more structured and customizable development workflow. Just like in the _Arduino IDE_, the **_MicroSui_** library is available through the **_PlatformIO Library Manager_**. This means you can add **_MicroSui_** to a new or existing project in just a few clicks. ![](https://docs.microsui.com/img/platformio-library.png) ### Mini comparison: Arduino IDE vs PlatformIO[​](https://docs.microsui.com/docs/getting-started#mini-comparison-arduino-ide-vs-platformio "Direct link to Mini comparison: Arduino IDE vs PlatformIO") | Feature | Arduino IDE | PlatformIO | | --- | --- | --- | | Ease of use | ⭐⭐⭐⭐⭐ Very easy | ⭐⭐⭐ Medium | | Setup time | Minutes | A bit longer | | Supported boards | Good | Excellent | | Project structure | Simple | More organized | | Best for | Beginners, quick tests, prototypes | Professional and production setups | Embedded engineer custom workflow: unsupported microcontrollers and language bindings[​](https://docs.microsui.com/docs/getting-started#embedded-engineer-custom-workflow-unsupported-microcontrollers-and-language-bindings "Direct link to Embedded engineer custom workflow: unsupported microcontrollers and language bindings") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Some developers may need to work directly with the C source code of **_MicroSui_**, either to adapt it to less common or unsupported microcontrollers, or to create bindings for other programming languages. In these cases, it is recommended to clone the repository and work directly with the project’s source code. Clone the repository: git clone https://github.com/MicroSui/microsui-lib.git The **core library code** is located in the `/src` directory, while the most common usage examples can be found in `/examples`. Which option should I choose?[​](https://docs.microsui.com/docs/getting-started#which-option-should-i-choose "Direct link to Which option should I choose?") ------------------------------------------------------------------------------------------------------------------------------------------------------------- tip If you are new to embedded development, or you just want to test MicroSui quickly, **Arduino IDE** is the best place to start. note If you are building a professional device, planning long-term development, or working with custom hardware, **PlatformIO** is the recommended option. note If you need full control over the code, want to support uncommon microcontrollers, or plan to create language bindings, cloning the repository and working directly with the source code is the best approach. Ready to begin![​](https://docs.microsui.com/docs/getting-started#ready-to-begin "Direct link to Ready to begin!") ------------------------------------------------------------------------------------------------------------------- That’s it! you’re ready to begin. **Start with the examples**, modify them at your own pace, and build confidence as you go. **_MicroSui_** is built to support both learning and real-world projects. * [Easy way - Arduino IDE](https://docs.microsui.com/docs/getting-started#easy-way---arduino-ide) * [Production-oriented dev for professional devices - PlatformIO](https://docs.microsui.com/docs/getting-started#production-oriented-dev-for-professional-devices---platformio) * [Mini comparison: Arduino IDE vs PlatformIO](https://docs.microsui.com/docs/getting-started#mini-comparison-arduino-ide-vs-platformio) * [Embedded engineer custom workflow: unsupported microcontrollers and language bindings](https://docs.microsui.com/docs/getting-started#embedded-engineer-custom-workflow-unsupported-microcontrollers-and-language-bindings) * [Which option should I choose?](https://docs.microsui.com/docs/getting-started#which-option-should-i-choose) * [Ready to begin!](https://docs.microsui.com/docs/getting-started#ready-to-begin) --- # Transaction | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/sdk/transaction#__docusaurus_skipToContent_fallback) On this page _MicroSui Object-style_ to represent Sui transactions. Provides a small OO-like API (struct + function pointers) to interact with Sui Transaction. **Each transaction holds its raw byte data and exposes methods to build or clear its contents to a Sui RPC endpoint over HTTP(S).** **Client capabilities:** Initialize empty transactions, Create transactions from predefined hex-encoded bytes, Build transactions into raw byte arrays (placeholder), Clear and free transaction memory safely. **IMPORTANT NOTE:** ✅ _Compatibility & Support:_ This class is fully supported and production-stable (as of this documentation release) on:       - **ESP32 series** — including all existing and future variants within the family       - **Desktop platforms** — Windows, macOS, Linux, and Unix-based operating systems ⚠️ Full transaction construction using Sui BCS serialization is **not yet implemented**. For now, transactions are provided manually as raw TxBytes, and the actual construction/serialization is delegated externally. ⚠️ Memory for transaction bytes is dynamically allocated when using `SuiTransaction_setPrebuiltTxBytes()`. Always call `clear()` to avoid leaks. Inspired by the **_Mysten Labs_ TypeScript SDK**, adapted for embedded C. * * * File Location[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#file-location "Direct link to File Location") ---------------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/Transaction.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/Transaction.c) * * * Indexs[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#indexs "Direct link to Indexs") ------------------------------------------------------------------------------------------------------- ### Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#constructors "Direct link to Constructors") * [`SuiTransaction_init`](https://docs.microsui.com/docs/api_reference/sdk/transaction#suitransaction_init) * [`SuiTransaction_setPrebuiltTxBytes`](https://docs.microsui.com/docs/api_reference/sdk/transaction#suitransaction_setprebuilttxbytes) ### Methods[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#methods "Direct link to Methods") * [`build`](https://docs.microsui.com/docs/api_reference/sdk/transaction#build) * [`clear`](https://docs.microsui.com/docs/api_reference/sdk/transaction#clear) * * * Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#constructors-1 "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------- ### `SuiTransaction_init`[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#suitransaction_init "Direct link to suitransaction_init") SuiTransaction_init(): MicroSuiTransaction Initialize an empty [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) . Sets up a transaction with no bytes (data = NULL, length = 0) and assigns method pointers for building and clearing. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#returns "Direct link to Returns") * [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#example-usage "Direct link to Example usage") MicroSuiTransaction tx = SuiTransaction_init();// Initiated an empty tx ### `SuiTransaction_setPrebuiltTxBytes`[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#suitransaction_setprebuilttxbytes "Direct link to suitransaction_setprebuilttxbytes") SuiTransaction_setPrebuiltTxBytes(const char *txBytesString): MicroSuiTransaction Initialize a [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) transaction from a prebuilt hex-encoded TxBytes string. This function is a temporary helper: it assumes the caller already provides the raw transaction bytes (TxBytes) serialized externally, encoded as a hex string. These bytes are then decoded and stored inside the [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) struct. The transaction takes ownership of the allocated memory, which will be released when [`clear`](https://docs.microsui.com/docs/api_reference/sdk/transaction#clear) is called. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `txBytesString` | `const char *` | Null-terminated string containing prebuilt TxBytes (hex-encoded) | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#returns-1 "Direct link to Returns") * [`MicroSuiTransaction`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#example-usage-1 "Direct link to Example usage") const char* message_string = "00000200080065cd1d0000000000202e3d52393c9035af";MicroSuiTransaction tx = SuiTransaction_setPrebuiltTxBytes(message_string);if (tx.tx_bytes.length > 0) // Tx created successfully Methods[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#methods-1 "Direct link to Methods") ------------------------------------------------------------------------------------------------------------ ### `build`[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#build "Direct link to build") build(MicroSuiTransaction *self): TransactionBytes Build, performs BCS serialization operation of the transaction and return the bytes in a new [`TransactionBytes`](https://docs.microsui.com/docs/api_reference/sdk/types#transactionbytes) struct. ⚠️ This method is a placeholder for now, not BCS serialized yet. Full transaction building with Sui BCS serialization is not yet supported. At this stage, TxBytes are provided manually and construction is delegated externally. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#parameters-2 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiTransaction *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) | Pointer to the MicroSuiTransaction instance | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#returns-2 "Direct link to Returns") * [`TransactionBytes`](https://docs.microsui.com/docs/api_reference/sdk/types#transactionbytes) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#example-usage-2 "Direct link to Example usage") We can obtain the tx bytes in the following way: const char* message_string = "00000200080065cd1d0000000000202e3d52393c9035af";MicroSuiTransaction tx = SuiTransaction_setPrebuiltTxBytes(message_string);TransactionBytes built_tx_bytes = tx.build(&tx);if (built_tx_bytes.length > 0) // Tx bytes obtained successfully ### `clear`[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#clear "Direct link to clear") clear (MicroSuiTransaction *self) : (void) Clear and free memory of the transaction. Frees any dynamically allocated memory for transaction bytes, sets the data pointer to NULL, and resets length to zero. tip ⚠️ VERY IMPORTANT PERFORM THIS AFTER USE THE TRANSACTION OPERATION FOR FREE THE MEMORY. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#parameters-3 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | [`MicroSuiTransaction *`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) | Pointer to the MicroSuiTransaction instance | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#returns-3 "Direct link to Returns") * `void` #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/transaction#example-usage-3 "Direct link to Example usage") const char* message_string = "00000200080065cd1d0000000000202e3d52393c9035af";MicroSuiTransaction tx = SuiTransaction_setPrebuiltTxBytes(message_string);// ...tx.clear(&tx);if (tx.tx_bytes.length == 0) // Tx data has been freed from memory * [File Location](https://docs.microsui.com/docs/api_reference/sdk/transaction#file-location) * [Indexs](https://docs.microsui.com/docs/api_reference/sdk/transaction#indexs) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/transaction#constructors) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/transaction#methods) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/transaction#constructors-1) * [`SuiTransaction_init`](https://docs.microsui.com/docs/api_reference/sdk/transaction#suitransaction_init) * [`SuiTransaction_setPrebuiltTxBytes`](https://docs.microsui.com/docs/api_reference/sdk/transaction#suitransaction_setprebuilttxbytes) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/transaction#methods-1) * [`build`](https://docs.microsui.com/docs/api_reference/sdk/transaction#build) * [`clear`](https://docs.microsui.com/docs/api_reference/sdk/transaction#clear) --- # WiFi | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/sdk/wifi#__docusaurus_skipToContent_fallback) On this page _MicroSui Object-style_ WiFi client for handling WiFi connectivity in MicroSui. Provides a small OO-like API (struct + function pointers) interface to **manage WiFi connections in embedded environments where MicroSui is deployed**. **Client capabilities:** Connect to a WiFi network by SSID and password, Disconnect from the current WiFi network and release resources. **IMPORTANT NOTE:** ✅ _Compatibility & Support:_ This class is fully supported and production-stable (as of this documentation release) on:       - **ESP32 series** — including all existing and future variants within the family ⚠️ Support for additional embedded architectures may be added in upcoming releases. Inspired by the **_Mysten Labs_ TypeScript SDK**, adapted for embedded C. * * * File Location[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#file-location "Direct link to File Location") --------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/WiFi.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/WiFi.c) * * * Indexs[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#indexs "Direct link to Indexs") ------------------------------------------------------------------------------------------------ ### Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#constructors "Direct link to Constructors") * [`WiFi_connect`](https://docs.microsui.com/docs/api_reference/sdk/wifi#wifi_connect) ### Methods[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#methods "Direct link to Methods") * [`disconnect`](https://docs.microsui.com/docs/api_reference/sdk/wifi#disconnect) * * * Constructors[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#constructors-1 "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------- ### `WiFi_connect`[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#wifi_connect "Direct link to wifi_connect") WiFi_connect(const char* ssid, const char* password): MicroSuiWiFi Creates a [`MicroSuiWiFi`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiwifi) instance and attempts to connect to the specified Wi-Fi network using the provided `ssid` and `password`. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `ssid` | `const char*` | Null-terminated _SSID_ of the _WiFi network_ | | `password` | `const char*` | Null-terminated _password_ of the _WiFi network_ | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#returns "Direct link to Returns") * [`MicroSuiWiFi`](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiwifi) struct type. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#example-usage "Direct link to Example usage") const char* ssid = "mySSID";const char* pass = "myPassword";MicroSuiClient wifi = WiFi_connect(ssid, pass);if (wifi.ssid != NULL) // WiFi client created successfully Methods[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#methods-1 "Direct link to Methods") ----------------------------------------------------------------------------------------------------- ### `disconnect`[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#disconnect "Direct link to disconnect") disconnect(MicroSuiWiFi *self): (void) Safely disconnects the Wi-Fi connection, cleans up the network stack, and releases any memory allocated during the connection. #### Parameters[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `self` | `MicroSuiWiFi *` | Pointer to wifi client instance | #### Returns[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#returns-1 "Direct link to Returns") * `void`. #### Example usage[​](https://docs.microsui.com/docs/api_reference/sdk/wifi#example-usage-1 "Direct link to Example usage") const char* ssid = "mySSID";const char* pass = "myPassword";MicroSuiClient wifi = WiFi_connect(ssid, pass);// ...wifi.disconnect(wifi);if (wifi.ssid == NULL) // WiFi was disconected an memory was cleaned * [File Location](https://docs.microsui.com/docs/api_reference/sdk/wifi#file-location) * [Indexs](https://docs.microsui.com/docs/api_reference/sdk/wifi#indexs) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/wifi#constructors) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/wifi#methods) * [Constructors](https://docs.microsui.com/docs/api_reference/sdk/wifi#constructors-1) * [`WiFi_connect`](https://docs.microsui.com/docs/api_reference/sdk/wifi#wifi_connect) * [Methods](https://docs.microsui.com/docs/api_reference/sdk/wifi#methods-1) * [`disconnect`](https://docs.microsui.com/docs/api_reference/sdk/wifi#disconnect) --- # -Types- | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/sdk/types#__docusaurus_skipToContent_fallback) On this page _MicroSui Object-style_ This section describes all the Type Structs of the SDK. Inspired by the **_Mysten Labs_ TypeScript SDK**, adapted for embedded C. * * * Types with Methods and Functions[​](https://docs.microsui.com/docs/api_reference/sdk/types#types-with-methods-and-functions "Direct link to Types with Methods and Functions") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### MicroSuiEd25519[​](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519 "Direct link to MicroSuiEd25519") struct MicroSuiEd25519 { uint8_t secret_key[32]; // Placeholder for the Secret Key // OO-style methods SuiSignature (*signTransaction)(MicroSuiEd25519 *self, const char *msg) const char* (*toSuiAddress)(MicroSuiEd25519 *self); const uint8_t* (*getPublicKey)(MicroSuiEd25519 *self); const char* (*getSecretKey)(MicroSuiEd25519 *self);}; ### MicroSuiClient[​](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient "Direct link to MicroSuiClient") struct MicroSuiClient { char rpc_url[128]; // Placeholder for the URL // OO-style methods SuiTransactionBlockResponse (*signAndExecuteTransaction)(MicroSuiClient *self, MicroSuiEd25519 kp, MicroSuiTransaction tx); SuiTransactionBlockResponse (*executeTransactionBlock)(MicroSuiClient *self, TransactionBytes txBytes, SuiSignature signature);}; ### MicroSuiTransaction[​](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction "Direct link to MicroSuiTransaction") struct MicroSuiTransaction { TransactionBytes tx_bytes; // Transaction bytes // OO-style methods TransactionBytes (*build)(MicroSuiTransaction *self); void (*clear)(MicroSuiTransaction *self);}; ### MicroSuiWiFi[​](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiwifi "Direct link to MicroSuiWiFi") struct MicroSuiWiFi { char ssid[64]; // Placeholder for the WiFi SSID char password[64]; // Placeholder for the WiFi Password // OO-style methods void (*disconnect)(MicroSuiWiFi *self);}; Types Struct native[​](https://docs.microsui.com/docs/api_reference/sdk/types#types-struct-native "Direct link to Types Struct native") ---------------------------------------------------------------------------------------------------------------------------------------- ### SuiSignature[​](https://docs.microsui.com/docs/api_reference/sdk/types#suisignature "Direct link to SuiSignature") struct SuiSignature { uint8_t bytes[97]; // Placeholder for the signature in bytes format char signature[133]; // Placeholder for the signature in base64 format (132 + null terminator)}; ### TransactionBytes[​](https://docs.microsui.com/docs/api_reference/sdk/types#transactionbytes "Direct link to TransactionBytes") struct TransactionBytes { uint8_t* data; // Placeholder for transaction bytes data size_t length; // Length of the transaction bytes}; ### SuiTransactionBlockResponse[​](https://docs.microsui.com/docs/api_reference/sdk/types#suitransactionblockresponse "Direct link to SuiTransactionBlockResponse") struct SuiTransactionBlockResponse { BalanceChange balanceChanges[MAX_BALANCE_CHANGES]; int balanceChanges_len; // actual count char* checkpoint; // may be NULL if not present char* confirmedLocalExecution; // "true"/"false" or NULL char* digest; // may be NULL if not present}; ### BalanceChange[​](https://docs.microsui.com/docs/api_reference/sdk/types#balancechange "Direct link to BalanceChange") struct BalanceChange { char* amount; // e.g., "100000000" char* coinType; // e.g., "0x2::sui::SUI" char* owner; // e.g., "0xabc..." (flattened AddressOwner if present)}; * [Types with Methods and Functions](https://docs.microsui.com/docs/api_reference/sdk/types#types-with-methods-and-functions) * [MicroSuiEd25519](https://docs.microsui.com/docs/api_reference/sdk/types#microsuied25519) * [MicroSuiClient](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiclient) * [MicroSuiTransaction](https://docs.microsui.com/docs/api_reference/sdk/types#microsuitransaction) * [MicroSuiWiFi](https://docs.microsui.com/docs/api_reference/sdk/types#microsuiwifi) * [Types Struct native](https://docs.microsui.com/docs/api_reference/sdk/types#types-struct-native) * [SuiSignature](https://docs.microsui.com/docs/api_reference/sdk/types#suisignature) * [TransactionBytes](https://docs.microsui.com/docs/api_reference/sdk/types#transactionbytes) * [SuiTransactionBlockResponse](https://docs.microsui.com/docs/api_reference/sdk/types#suitransactionblockresponse) * [BalanceChange](https://docs.microsui.com/docs/api_reference/sdk/types#balancechange) --- # Examples | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/category/examples#__docusaurus_skipToContent_fallback) [📄️ Offline Sign (Get Signature)\ --------------------------------\ \ The simplest and most powerful example we can find in microsui-lib is the ability to generate Sui-compatible Ed25519 signatures.](https://docs.microsui.com/docs/examples/offline-sign) [📄️ Broadcast Transaction to Sui Network\ ----------------------------------------\ \ Sends a fully constructed transaction (including the Sui message and its signature) to a Sui Network node via HTTP.](https://docs.microsui.com/docs/examples/broadcast-transaction) [📄️ Obtain Sui Address and Public Key from Private Key\ ------------------------------------------------------\ \ Functions for deriving the Sui address and public key from a private key (secret key) using Sui-compatible cryptography.](https://docs.microsui.com/docs/examples/private_key) [📄️ Validating a Sui Signature for a given message\ --------------------------------------------------\ \ Verifies that the provided Sui-formatted signature is valid for the given serialized message.](https://docs.microsui.com/docs/examples/validating_signature) [📄️ Bytes,Base64,Hexa - Encode/Decode\ -------------------------------------\ \ Utility conversions between common data formats used in Sui development.](https://docs.microsui.com/docs/examples/encode-decode) --- # Broadcast Transaction to Sui Network | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/examples/broadcast-transaction#__docusaurus_skipToContent_fallback) On this page Sends a fully constructed transaction (including the Sui message and its signature) to a _Sui Network_ node via _HTTP_. note ⚠️ This operation **REQUIRES** the microcontroller to support _HTTP_ (_HTTP POST_) and to be connected to the internet in order to communicate with a _Sui API node_. Therefore, the microcontroller must either natively include these capabilities or be connected to a module or device that provides them. note ✅ **All _ESP32_ variants provide full compatibility for this operation when using _Arduino IDE_**. tip ⚠️ If your microcontroller includes an HTTP stack and internet connectivity, _you are responsible for implementing the device-specific code required to perform the HTTP POST request_ using the payload generated by `microsui-lib`. In the final example, you will see exactly where this code should be placed. ESP32 Fully supported example - (adaptation for ArduinoIDE)[​](https://docs.microsui.com/docs/examples/broadcast-transaction#esp32-fully-supported-example---adaptation-for-arduinoide "Direct link to ESP32 Fully supported example - (adaptation for ArduinoIDE)") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- note ⚠️ ATTENTION: This code only works for ESP32 by the moment! This chunk of code is fully functional in _Arduino IDE_ for _ESP32_ boards and nothing needs to be edited or added (except for the initial constants). // 0) Constants// --- WiFi credentials (example) ---const char* wifi_ssid = "myWiFiSSID";const char* wifi_pass = "myWiFiPass";// --- Sui essentials for this example ---const char* rpc_url = "https://fullnode.testnet.sui.io:443/"; // Sui RPC URL (testnet in this example)const char* sui_private_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";const char* message_string = "48656c6c6f2053756921"; // which is "Hello Sui!", but in this case must be bytes from a real transaction// 1) Connect WiFiMicroSuiWiFi wifi = WiFi_connect(wifi_ssid, wifi_pass);// 2) Generate RPC clientMicroSuiClient client = SuiClient_newClient(rpc_url);Serial.print(F(" DONE! - Created Client with RPC URL: ")); Serial.println(rpc_url);// 3) Load keypair from Bech32 secret keyMicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_private_key_bech32);Serial.print(F(" DONE! - Created KeyPair - userAddress: ")); Serial.println(keypair.toSuiAddress(&keypair));// 4) Load prebuilt TxBytes (generated externally)MicroSuiTransaction tx = SuiTransaction_setPrebuiltTxBytes(message_string);Serial.println(F(" DONE! - Created a Sui Transaction object with prebuilt TxBytes"));// 5) Sign + Execute (simplest way: client handles the signature internally)SuiTransactionBlockResponse res1 = client.signAndExecuteTransaction(&client, keypair, tx);Serial.print(F(" DONE! - Signed Transaction sended to Sui Network!!"));Serial.println(F("\n\n --- RPC Response - Transaction Result ---"));if (res1.digest) { Serial.print(F(" Digest (Tx ID): ")); Serial.println(res1.digest); }if (res1.checkpoint) { Serial.print(F(" Checkpoint: ")); Serial.println(res1.checkpoint); }if (res1.confirmedLocalExecution) { Serial.print(F(" ConfirmedLocalExecution: ")); Serial.println(res1.confirmedLocalExecution); }Serial.print(F(" BalanceChanges count: "));Serial.println(res1.balanceChanges_len);// Cleaning memory after transactiontx.clear(&tx); // Clean transaction (important to avoid memory leaks)wifi.disconnect(&wifi); // Disconnect WiFi Any microcontroller with HTTP stack and internet connection - (pure C code)[​](https://docs.microsui.com/docs/examples/broadcast-transaction#any-microcontroller-with-http-stack-and-internet-connection---pure-c-code "Direct link to Any microcontroller with HTTP stack and internet connection - (pure C code)") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This chunk of code requires add your own HTTP POST implementation after the generation of the payload string. // Message and Signature previously generatedconst char* sui_message = "0000020008c0320a030000000000202e3d52393c9035afd1ef38abd7fce2dad71f0e276b522fb274f4e14d1df974720202000101000001010300000000010100d79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379d0115bc7e3113dfaebc7bdb30676e56e6ff651365235b74a202cbb1e73f57eaeb78600fd0140000000020c00463b22a32bebcb028b264d61bfa963c3f6a82bd7487c52bec8b2bf0c0e373d79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379de80300000000000040ab3c000000000000";const char* sui_signature = "004131446a8541b3c408e18054f2e175f1b04a93f6ab1bbf38d1234a3b6ed65adf508e9a03555269222536e0ecdbf4d496de7212c5e2f9c4dec2251226b7fcf8036309ede0a480229c12b578364ca13bc36cbf61786c47aa75f323127462b32405";// RPC NODEconst char* host = "fullnode.testnet.sui.io";const char* path = "/";int port = 443;// Convert the Sui Signature from hex to bytesuint8_t signature_bytes[132];hex_to_bytes(sui_signature, signature_bytes, sizeof(signature_bytes));// Convert the Sui Message from hex to bytessize_t message_bytes_len = strlen(sui_message) / 2; // 2 hex chars = 1 byteuint8_t message_bytes[message_bytes_len];hex_to_bytes(sui_message, message_bytes, message_bytes_len);// Prepare the JSON string for executing the transaction blockchar* json = microsui_prepare_executeTransactionBlock(signature_bytes, message_bytes, message_bytes_len);if (!json) { printf("Failed to generate JSON.\n"); return -1;}printf("\t JSON prepared to send via RPC by method `sui_executetransactionblock`:\n %s\n\n", json);// Send the JSON via HTTP POST requestprintf("\t Sending HTTP POST request to %s:%d%s\n", host, port, path);//// YOU HAVE TO IMPLEMENT HERE YOUR OWN HTTP POST implementation (According to your microcontroller)//// char* response = your_microcontroller_http_post(host, path, port, json);//////if (response != NULL) { printf("HTTP POST success!\n"); printf("\n\t Sui Network RPC Response:\n%s\n", response);} else { printf("\n HTTP POST failed\n");}free(json); // Free the JSON string after use (very important to avoid memory leaks)free(response); // Free the response string after use (very important to avoid memory leaks) tip MicroSui is open-source, and new platform implementations are welcome via PRs in the `microsui-lib` repository. * [ESP32 Fully supported example - (adaptation for ArduinoIDE)](https://docs.microsui.com/docs/examples/broadcast-transaction#esp32-fully-supported-example---adaptation-for-arduinoide) * [Any microcontroller with HTTP stack and internet connection - (pure C code)](https://docs.microsui.com/docs/examples/broadcast-transaction#any-microcontroller-with-http-stack-and-internet-connection---pure-c-code) --- # Bytes,Base64,Hexa - Encode/Decode | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/examples/encode-decode#__docusaurus_skipToContent_fallback) On this page Utility conversions between common data formats used in Sui development. note ✅ **Compatible across all microcontroller implementations and IDEs.** C pure General Example[​](https://docs.microsui.com/docs/examples/encode-decode#c-pure-general-example "Direct link to C pure General Example") ------------------------------------------------------------------------------------------------------------------------------------------------ // Constantsconst char* private_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";// Bech32 private key to 32 bytes private key convertionuint8_t private_key_bytes[32];microsui_decode_sui_privkey(private_key_bech32, private_key_bytes);// Obtain Public Key from Private Keyuint8_t public_key[32];get_public_key_from_private_key(private_key_bytes, public_key);// CONVERSION 1 - Input Bytes output Base64 and Hexaprintf("\n\n\t 1 - Byte to BASE64 and HEXA :\n");const uint8_t signature_bytes[97] = { 0x00, 0x41, 0x31, 0x44, 0x6a, 0x85, 0x41, 0xb3, 0xc4, 0x08, 0xe1, 0x80, 0x54, 0xf2, 0xe1, 0x75, 0xf1, 0xb0, 0x4a, 0x93, 0xf6, 0xab, 0x1b, 0xbf, 0x38, 0xd1, 0x23, 0x4a, 0x3b, 0x6e, 0xd6, 0x5a, 0xdf, 0x50, 0x8e, 0x9a, 0x03, 0x55, 0x52, 0x69, 0x22, 0x25, 0x36, 0xe0, 0xec, 0xdb, 0xf4, 0xd4, 0x96, 0xde, 0x72, 0x12, 0xc5, 0xe2, 0xf9, 0xc4, 0xde, 0xc2, 0x25, 0x12, 0x26, 0xb7, 0xfc, 0xf8, 0x03, 0x63, 0x09, 0xed, 0xe0, 0xa4, 0x80, 0x22, 0x9c, 0x12, 0xb5, 0x78, 0x36, 0x4c, 0xa1, 0x3b, 0xc3, 0x6c, 0xbf, 0x61, 0x78, 0x6c, 0x47, 0xaa, 0x75, 0xf3, 0x23, 0x12, 0x74, 0x62, 0xb3, 0x24, 0x05};char output_signature_base64[(97 + 2) / 3 * 4 + 1]; // Base64 output size calculation + 1 for null terminatorbytes_to_base64(signature_bytes, sizeof(signature_bytes), output_signature_base64, sizeof(output_signature_base64));printf("-> Signature in Base64: %s\n", output_signature_base64);char output_signature_hex[(97 * 2) + 1]; // Hex output size calculation + 1 for null terminatorbytes_to_hex(signature_bytes, sizeof(signature_bytes), output_signature_hex);printf("-> Signature in Hexa: %s\n", output_signature_hex);// CONVERSION 2 - Input Hexa output Bytesprintf("\n\n\t 2 - HEXA to Bytes:\n");const char signature_hex[(97 * 2) + 1] = "004131446a8541b3c408e18054f2e175f1b04a93f6ab1bbf38d1234a3b6ed65adf508e9a03555269222536e0ecdbf4d496de7212c5e2f9c4dec2251226b7fcf8036309ede0a480229c12b578364ca13bc36cbf61786c47aa75f323127462b32405";uint8_t output_signature_bytes_from_hex[97];hex_to_bytes(signature_hex, output_signature_bytes_from_hex, sizeof(output_signature_bytes_from_hex));printf("-> Signature in Bytes: [");for (size_t i = 0; i < sizeof(output_signature_bytes_from_hex); i++) { if (i+1 < sizeof(output_signature_bytes_from_hex)) { printf("0x%02x,", output_signature_bytes_from_hex[i]); } else { printf("0x%02x", output_signature_bytes_from_hex[i]); }}printf("]\n");// CONVERSION 3 - Input Base64 output Bytesprintf("\n\n\t 3 - BASE64 to Bytes:\n");const char signature_base64[(97 + 2) / 3 * 4 + 1] = "AEExRGqFQbPECOGAVPLhdfGwSpP2qxu/ONEjSjtu1lrfUI6aA1VSaSIlNuDs2/TUlt5yEsXi+cTewiUSJrf8+ANjCe3gpIAinBK1eDZMoTvDbL9heGxHqnXzIxJ0YrMkBQ==";size_t signature_base64_len = strlen(signature_base64);size_t output_signature_bytes_from_base64_len = (signature_base64_len / 4) * 3;if (signature_base64[signature_base64_len - 1] == '=') output_signature_bytes_from_base64_len--;if (signature_base64[signature_base64_len - 2] == '=') output_signature_bytes_from_base64_len--;uint8_t output_signature_bytes_from_base64[output_signature_bytes_from_base64_len];base64_to_bytes(signature_base64, signature_base64_len, output_signature_bytes_from_base64, output_signature_bytes_from_base64_len);printf("-> Signature in Bytes: [");for (size_t i = 0; i < sizeof(output_signature_bytes_from_base64); i++) { if (i+1 < sizeof(output_signature_bytes_from_base64)) { printf("0x%02x,", output_signature_bytes_from_base64[i]); } else { printf("0x%02x", output_signature_bytes_from_base64[i]); }}printf("]\n"); * [C pure General Example](https://docs.microsui.com/docs/examples/encode-decode#c-pure-general-example) --- # Validating a Sui Signature for a given message | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/examples/validating_signature#__docusaurus_skipToContent_fallback) On this page Verifies that the provided _Sui-formatted signature_ **is valid** for the given _serialized message_. Currently only **_Ed25519_** (`0x00`) is implemented in signature validations. note ✅ **Compatible across all microcontroller implementations and IDEs.** SDK way (adaptation for ArduinoIDE)[​](https://docs.microsui.com/docs/examples/validating_signature#sdk-way-adaptation-for-arduinoide "Direct link to SDK way (adaptation for ArduinoIDE)") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ✅ Fully compatible with _ArduinoIDE_ on supported platforms. Serial.print(F("\n\t This demo shows how to validate a Sui Signature. (Signature is generated here too)\n"));const char* private_key = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";const char* message1_string = "0001020304050607080910";const char* message2_string = "00020406081012141a1c1e";// Create a keypair from a given secret key in Bech32 formatMicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(private_key);// Create two transactions with the prebuilted TxBytesMicroSuiTransaction tx1 = SuiTransaction_setPrebuiltTxBytes(message1_string);MicroSuiTransaction tx2 = SuiTransaction_setPrebuiltTxBytes(message2_string);Serial.print(F("\n\t Signing the Transaction Message1 with the keypair...\n\n"));SuiSignature sig = keypair.signTransaction(&keypair, message1_string);Serial.print(F(" Signature in base64: %s\n", sig.signature));Serial.print(F" Signature in bytes: "));for (int i = 0; i < 97; i++) { Serial.print(F("%02x", sig.bytes[i]));}Serial.print(F("\n\n"));// Signature validation must be correct for Message 1 and failed for Message 2Serial.print(F("\t Signature validation must be correct for Message 1 and failed for Message 2\n"));// Validation with message 1 (correct)int verification_result_1 = microsui_verify_signature(sig.bytes, tx1.tx_bytes.data, tx1.tx_bytes.length);if(verification_result_1 == 0) Serial.print(F("\t - Signature Verification is CORRECT for Message 1 -- OK\n"));// Validation with message 2 (must fail)int verification_result_2 = microsui_verify_signature(sig.bytes, tx2.tx_bytes.data, tx2.tx_bytes.length);if(verification_result_2 == -1) Serial.print(F("\t - Signature Verification is FAILED for Message 2 -- OK\n")); Core functions way[​](https://docs.microsui.com/docs/examples/validating_signature#core-functions-way "Direct link to Core functions way") ------------------------------------------------------------------------------------------------------------------------------------------- ✅ Fully compatible with any IDE and any microcontroller, offering full control and customization for developers. This method is recommended for **8-bit microcontrollers** or other **memory-constrained environments**. printf("\n\t This demo shows how to validate a Sui Signature. (Signature is generated here too)\n");const char *private_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";const char* message_hex = "00000200080065cd1d0000000000202e3d52393c9035afd1ef38abd7fce2dad71f0e276b522fb274f4e14d1df974720202000101000001010300000000010100d79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379d0180dc491e55e7caabfcdd1b0f538928d8d54107b9c1def3ed0baa3aa5106ba8674f0dd01400000000204b7e9da00f30cd1edf4d40710213c15a862e1fc175f2edb2b2c870c8559d65cdd79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379de80300000000000040ab3c000000000000";// Decoding the Bech32 private key to bytesuint8_t private_key[32];if (microsui_decode_sui_privkey(private_key_bech32, private_key) != 0) { printf("Invalid Bech32 private key.\n"); return -1;}// Converting the message from hex to bytessize_t message_len = strlen(message_hex) / 2; // 2 hex chars = 1 byteuint8_t message[message_len];hex_to_bytes(message_hex, message, message_len);// Generating the Sui Signature from the message and private key (private_key is in constant.h)uint8_t sui_sig[97];printf("\n\n\n Generating Signature...\n");microsui_sign_ed25519(sui_sig, message, message_len, private_key);printf("\t Signature created successfully\n");// Verifying the Sui Signatureint verification_result = microsui_verify_signature(sui_sig, message, message_len);if(verification_result == 0) { printf("\t Signature verified successfully\n\n");} else { printf("\t Signature verification failed\n"); printf("\t Error code: %d\n\n", verification_result);} * [SDK way (adaptation for ArduinoIDE)](https://docs.microsui.com/docs/examples/validating_signature#sdk-way-adaptation-for-arduinoide) * [Core functions way](https://docs.microsui.com/docs/examples/validating_signature#core-functions-way) --- # Obtain Sui Address and Public Key from Private Key | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/examples/private_key#__docusaurus_skipToContent_fallback) On this page Functions for deriving the Sui address and public key from a private key (secret key) using Sui-compatible cryptography. note ✅ **Compatible across all microcontroller implementations and IDEs.** SDK way (adaptation for ArduinoIDE)[​](https://docs.microsui.com/docs/examples/private_key#sdk-way-adaptation-for-arduinoide "Direct link to SDK way (adaptation for ArduinoIDE)") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ✅ Fully compatible with _ArduinoIDE_ on supported platforms. This is the most developer-friendly approach, similar to what you may find in the _Mysten Labs SDKs_. const char* privateKey = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";// Create the keypair objectMicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_private_key_bech32);Serial.print(F(" Created KeyPair - userAddress: ")); Serial.println(address);const char* address = keypair.toSuiAddress(&keypair);Serial.print(F(" Sui Address: ")); Serial.println(keypair.toSuiAddress(&keypair));const char* public_key = keypair.getPublicKey(&keypair);Serial.print(F(" Public Key: ")); Serial.println(keypair.toSuiAddress(&public_key)); Core functions way[​](https://docs.microsui.com/docs/examples/private_key#core-functions-way "Direct link to Core functions way") ---------------------------------------------------------------------------------------------------------------------------------- ✅ Fully compatible with any IDE and any microcontroller, offering full control and customization for developers. This method is recommended for **8-bit microcontrollers** or other **memory-constrained environments**. const char* private_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";// Bech32 private key to 32 bytes private key convertionuint8_t private_key_bytes[32];microsui_decode_sui_privkey(private_key_bech32, private_key_bytes);// Obtain Public Key from Private Key (and converting it to base64)uint8_t public_key_bytes[32];char public_key_base64[(32 + 2) / 3 * 4 + 1];get_public_key_from_private_key(private_key_bytes, public_key);bytes_to_base64(public_key_bytes, sizeof(public_key_bytes), public_key_base64, sizeof(public_key_base64));Serial.print(F(" Public Key (in base64): ")); Serial.println(public_key_base64);Serial.print(F(" Public Key (in bytes): "));for (int i = 0; i < 32; i++) { Serial.print(F("%02x", public_key[i]));}Serial.print(F("\n"));// Obtain Public Key from Private Key (and converting it to base64)uint8_t public_key_bytes[32];char public_key_base64[(32 + 2) / 3 * 4 + 1];get_public_key_from_private_key(private_key_bytes, public_key);bytes_to_base64(public_key_bytes, sizeof(public_key_bytes), public_key_base64, sizeof(public_key_base64));Serial.print(F(" Public Key (in base64): ")); Serial.println(public_key_base64);Serial.print(F(" Public Key (in bytes): "));for (int i = 0; i < 32; i++) { Serial.print(F("%02x", public_key[i]));}Serial.print(F("\n"));// Obtain Sui Address from Public Keychar sui_address[67]; // Placeholder for Sui addressuint8_t encoded_address[32];microsui_pubkey_to_sui_address(public_key, encoded_address); // Encode public key to Sui addresschar encoded_address_string[65];bytes_to_hex(encoded_address, 32, encoded_address_string); // Convert the encoded address to a hex stringsui_address[0] = '0';sui_address[1] = 'x';memcpy(sui_address + 2, encoded_address_string, 65);Serial.print(F(" Sui Address: ")); Serial.println(sui_address); * [SDK way (adaptation for ArduinoIDE)](https://docs.microsui.com/docs/examples/private_key#sdk-way-adaptation-for-arduinoide) * [Core functions way](https://docs.microsui.com/docs/examples/private_key#core-functions-way) --- # key_management.c (Key Management) | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/api_reference/functions/key_management#__docusaurus_skipToContent_fallback) On this page This file implements core key management utilities for **_MicroSui_**. It provides deterministic helpers for deriving public keys and Sui addresses from raw _Ed25519_ key material, following the _Sui specification_. These routines handle scheme flag prefixing, public key derivation, and address hashing using _BLAKE2b-256_. The functionality in this file is intentionally minimal and focused on key derivation and address generation, making it suitable for embedded and resource-constrained environments. File Location[​](https://docs.microsui.com/docs/api_reference/functions/key_management#file-location "Direct link to File Location") ------------------------------------------------------------------------------------------------------------------------------------- Defined in [`microsui-lib/src/microsui_core/key_management.c`](https://github.com/MicroSui/microsui-lib/blob/main/src/microsui_core/key_management.c) * * * microsui\_pubkey\_to\_sui\_address[​](https://docs.microsui.com/docs/api_reference/functions/key_management#microsui_pubkey_to_sui_address "Direct link to microsui_pubkey_to_sui_address") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Description[​](https://docs.microsui.com/docs/api_reference/functions/key_management#description "Direct link to Description") Derive a Sui address from a 32-byte Ed25519 public key. Prepends the scheme flag (0x00 for Ed25519) to the public key, then computes the BLAKE2b-256 hash of the 33-byte input. The resulting 32-byte digest is the canonical Sui address. int microsui_pubkey_to_sui_address(const uint8_t pubkey[32], uint8_t sui_address_out[32]) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/key_management#parameters "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `pubkey` | `const uint8_t [32]` | 32-byte Ed25519 public key | | `sui_address_out` | `uint8_t [32]` | Output buffer for the 32-byte Sui address | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/key_management#returns "Direct link to Returns") * `0` on success. * `-1` if input pointers are NULL. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/key_management#example-usage "Direct link to Example usage") Given: * A defined `pubkey`: Public Key in Bytes format. You can derive the key as follows: uint8_t sui_address_out[32]; // We initialize it emptyint status = microsui_pubkey_to_sui_address(pubkey, sui_address_out);if (status == 0) // Derived Sui address is now stored in sui_address_out * * * get\_public\_key\_from\_private\_key[​](https://docs.microsui.com/docs/api_reference/functions/key_management#get_public_key_from_private_key "Direct link to get_public_key_from_private_key") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ### Description[​](https://docs.microsui.com/docs/api_reference/functions/key_management#description-1 "Direct link to Description") Derive a 32-byte Ed25519 public key from a 32-byte private key seed. Generates the full 64-byte Ed25519 secret key internally, then extracts the corresponding public key. int get_public_key_from_private_key(const uint8_t private_key[32], uint8_t public_key[32]) ### Parameters[​](https://docs.microsui.com/docs/api_reference/functions/key_management#parameters-1 "Direct link to Parameters") | Name | Type | Description | | --- | --- | --- | | `private_key` | `const uint8_t [32]` | 32-byte Ed25519 private key seed | | `public_key` | `uint8_t [32]` | Output buffer for the 32-byte public key | ### Returns[​](https://docs.microsui.com/docs/api_reference/functions/key_management#returns-1 "Direct link to Returns") * `0` on success. * `-1` if input pointers are NULL. ### Example usage[​](https://docs.microsui.com/docs/api_reference/functions/key_management#example-usage-1 "Direct link to Example usage") Given: * A defined `private_key`: Private/Secret Key in Bytes format. You can derive the key as follows: uint8_t public_key[32]; // We initialize it emptyint status = get_public_key_from_private_key(private_key, public_key);if (status == 0) // Decoded key is now stored in private_key * [File Location](https://docs.microsui.com/docs/api_reference/functions/key_management#file-location) * [microsui\_pubkey\_to\_sui\_address](https://docs.microsui.com/docs/api_reference/functions/key_management#microsui_pubkey_to_sui_address) * [Description](https://docs.microsui.com/docs/api_reference/functions/key_management#description) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/key_management#parameters) * [Returns](https://docs.microsui.com/docs/api_reference/functions/key_management#returns) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/key_management#example-usage) * [get\_public\_key\_from\_private\_key](https://docs.microsui.com/docs/api_reference/functions/key_management#get_public_key_from_private_key) * [Description](https://docs.microsui.com/docs/api_reference/functions/key_management#description-1) * [Parameters](https://docs.microsui.com/docs/api_reference/functions/key_management#parameters-1) * [Returns](https://docs.microsui.com/docs/api_reference/functions/key_management#returns-1) * [Example usage](https://docs.microsui.com/docs/api_reference/functions/key_management#example-usage-1) --- # SDK Classes | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/category/sdk-classes#__docusaurus_skipToContent_fallback) [📄️ Keypair\ -----------\ \ MicroSui Object-style for handling Ed25519 keypairs in MicroSui.](https://docs.microsui.com/docs/api_reference/sdk/keypair) [📄️ Client\ ----------\ \ MicroSui Object-style RPC client for interacting with a Sui full node.](https://docs.microsui.com/docs/api_reference/sdk/client) [📄️ Transaction\ ---------------\ \ MicroSui Object-style to represent Sui transactions.](https://docs.microsui.com/docs/api_reference/sdk/transaction) [📄️ WiFi\ --------\ \ MicroSui Object-style WiFi client for handling WiFi connectivity in MicroSui.](https://docs.microsui.com/docs/api_reference/sdk/wifi) [📄️ \-Types-\ ------------\ \ MicroSui Object-style This section describes all the Type Structs of the SDK.](https://docs.microsui.com/docs/api_reference/sdk/types) --- # Core C functions | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/category/core-c-functions#__docusaurus_skipToContent_fallback) [📄️ sign.c (Signatures)\ -----------------------\ \ This file implements the core signing logic for \_MicroSui\_.](https://docs.microsui.com/docs/api_reference/functions/sign) [📄️ cryptography.c (Cryptography)\ ---------------------------------\ \ This file implements core cryptographic utility functions for \_MicroSui\_.](https://docs.microsui.com/docs/api_reference/functions/cryptography) [📄️ key\_management.c (Key Management)\ --------------------------------------\ \ This file implements core key management utilities for \_MicroSui\_.](https://docs.microsui.com/docs/api_reference/functions/key_management) [📄️ rpc\_json\_builder.c (RPC JSON Builder)\ -------------------------------------------\ \ This file implements JSON-RPC request builders for \_MicroSui\_.](https://docs.microsui.com/docs/api_reference/functions/rpc_json_builder) [📄️ byte\_conversions.c (Byte Util Conversions)\ -----------------------------------------------\ \ This file implements low-level byte and string conversion utilities for \_MicroSui\_.](https://docs.microsui.com/docs/api_reference/functions/byte_conversions) --- # Offline Sign (Get Signature) | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/examples/offline-sign#__docusaurus_skipToContent_fallback) On this page **The simplest and most powerful example** we can find in `microsui-lib` is the ability to generate Sui-compatible _Ed25519_ signatures. Using _MicroSui_, **we can sign messages** both for validation purposes and for completing transactions. note ⚠️ **This operation DOES NOT REQUIRE an internet connection**. However, if generating the message to be signed requires network access, you must ensure that your microcontroller or development board includes an HTTP stack to reach the Sui API endpoints. Alternatively, the message to be signed can be generated externally and then passed to the device for signing. SDK way (adaptation for ArduinoIDE)[​](https://docs.microsui.com/docs/examples/offline-sign#sdk-way-adaptation-for-arduinoide "Direct link to SDK way (adaptation for ArduinoIDE)") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ✅ Fully compatible with Arduino IDE on supported platforms. This is the most developer-friendly approach, similar to what you may find in the _Mysten Labs SDKs_. const char* privateKey = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";const char* messageToSign = "48656c6c6f2053756921"; // which is "Hello Sui!"// Create the keypair objectMicroSuiEd25519 keypair = SuiKeypair_fromSecretKey(sui_private_key_bech32);Serial.print(F(" DONE! - Created KeyPair - userAddress: ")); Serial.println(keypair.toSuiAddress(&keypair));// Generate the Signature with the message and the keypairSuiSignature sig = keypair.signTransaction(&keypair, message_string);Serial.println(F(" DONE! - Created Signature!"));Serial.println(F("\n --- Signature Result ---"));if (sig.signature) Serial.print(F(" Signature in BASE64 format: ")); Serial.println(sig.signature);if (sig.bytes) { Serial.print(F(" Signature in Bytes format: ")); for (int i = 0; i < 97; i++) { Serial.print(F("%02x", sig.bytes[i])); }}Serial.print(F("\n")); Core functions way[​](https://docs.microsui.com/docs/examples/offline-sign#core-functions-way "Direct link to Core functions way") ----------------------------------------------------------------------------------------------------------------------------------- ✅ Fully compatible with any IDE and any microcontroller, offering full control and customization for developers. This method is recommended for **8-bit microcontrollers** or other **memory-constrained environments**. const char* private_key_bech32 = "suiprivkey1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq509duq";const char* message_hex = "48656c6c6f2053756921"; // which is "Hello Sui!"// Decoding the Bech32 private key to bytesuint8_t private_key[32];if (microsui_decode_sui_privkey(private_key_bech32, private_key) != 0) { printf("Invalid Bech32 private key.\n"); return -1;}// Converting the message from hex to bytessize_t message_len = strlen(message_hex) / 2; // 2 hex chars = 1 byteuint8_t message[message_len];hex_to_bytes(message_hex, message, message_len);// Generating the Sui Signature from the message and private keyuint8_t sui_sig[97];microsui_sign_ed25519(sui_sig, message, message_len, private_key);// Printing the Sui Signature in hex formatchar sui_sig_hex[195]; // 2 hex chars per byte + null terminatorbytes_to_hex(sui_sig, 97, sui_sig_hex); // 97 bytes is the length of a Sui Signatureprintf(" Sui Signature (97 bytes): %s\n", sui_sig_hex); * [SDK way (adaptation for ArduinoIDE)](https://docs.microsui.com/docs/examples/offline-sign#sdk-way-adaptation-for-arduinoide) * [Core functions way](https://docs.microsui.com/docs/examples/offline-sign#core-functions-way) --- # Overview | MicroSui Docs [Skip to main content](https://docs.microsui.com/docs/intro#__docusaurus_skipToContent_fallback) On this page ![microsuilib-logo](https://docs.microsui.com/img/microsuilib-logo.png) The code lines presented in the **_MicroSui_** documentation are primarily intended for projects targeting _microcontrollers_ and _embedded hardware systems_, where **_C_ is the officially supported language**. **_MicroSui_** provides, through _open-source_ code, the ability for devices that were previously disconnected from the _blockchain_ to become operational, allowing them to connect, interact with the _blockchain_, and perform cryptographic operations oriented toward the development of the **_Sui Network Blockchain_**. Although **_MicroSui_** is designed for _microcontrollers_ and _embedded systems_, it is compatible with **any platform**. Thanks to the simplicity of _C_, many **_Sui Network_** cryptographic operations **can be executed more efficiently** using MicroSui’s core functions, with the added benefit of a _C API_ designed for easy and safe _language bindings_. Main Components[​](https://docs.microsui.com/docs/intro#main-components "Direct link to Main Components") ---------------------------------------------------------------------------------------------------------- The MicroSui Framework includes **[microsui-lib](https://github.com/MicroSui/microsui-lib) ** repository, a lightweight implementation in _C language_. It’s designed to be compatible with virtually **any device or computer**. That said, let’s be brutally honest: there’s little reason to use it on powerful systems where robust solutions like _Mysten’s TypeScript SDK_ are available. In those cases, it is strongly recommended to use the tools offered by _Mysten Labs_, for obvious reasons. `microsui-lib` is truly valuable in constrained environments devices where firmware **MUST** be written in C. That’s where the library truly shines, offering a unique solution where no alternatives exist. ### MicroSui Core C API library[​](https://docs.microsui.com/docs/intro#microsui-core-c-api-library "Direct link to MicroSui Core C API library") The **_MicroSui Core C API library_** provides the _low-level_, portable building blocks of the _framework_, **exposing minimal and deterministic C functions for key management, signing, encoding, and core Sui cryptographic operations**. This layer is designed to be lightweight, predictable, and suitable for **highly constrained environments**, serving as the foundation for higher-level abstractions such as the _MicroSui SDK_. These functions **are designed to run on virtually any device, regardless of how constrained it may be**, and remain fully functional even on 8-bit microcontrollers. ### MicroSui SDK[​](https://docs.microsui.com/docs/intro#microsui-sdk "Direct link to MicroSui SDK") The **_MicroSui SDK_** is a higher-level abstraction layer built on top of the _MicroSui Core C APIs_. While the Core layer exposes low-level, portable C functions designed to run on virtually any microcontroller, the SDK **introduces an object-style programming model implemented in pure C** (using structs + function pointers), inspired by modern _Object Oriented SDKs_ such as **_Mysten Labs’_ TypeScript SDK**. This approach provides a more expressive and ergonomic developer experience, closer to _Object Oriented_ languages like _TypeScript_, while remaining compatible with _embedded constraints_. #### Platform Support & Compatibility[​](https://docs.microsui.com/docs/intro#platform-support--compatibility "Direct link to Platform Support & Compatibility") > **IMPORTANT NOTE** A full _MicroSui SDK_ support relies on features that may require: * **Internet connectivity** * **Networking stacks (HTTP stack)** As a result, _SDK_ support is currently fully supported and production-stable on: * **ESP32 family** (all variants) * **Desktop platforms** (Windows, macOS, Linux, Unix) Support for additional embedded architectures may be introduced in future releases. * [Main Components](https://docs.microsui.com/docs/intro#main-components) * [MicroSui Core C API library](https://docs.microsui.com/docs/intro#microsui-core-c-api-library) * [MicroSui SDK](https://docs.microsui.com/docs/intro#microsui-sdk) ---