<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alejandro Huitemagico</title>
    <description>The latest articles on DEV Community by Alejandro Huitemagico (@huitemagico).</description>
    <link>https://dev.to/huitemagico</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1147785%2F07534ee1-138b-4000-9115-324acd2fef11.JPG</url>
      <title>DEV Community: Alejandro Huitemagico</title>
      <link>https://dev.to/huitemagico</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/huitemagico"/>
    <language>en</language>
    <item>
      <title>KMAC : Template for Finite State Machine in Soroban</title>
      <dc:creator>Alejandro Huitemagico</dc:creator>
      <pubDate>Thu, 21 Dec 2023 02:12:37 +0000</pubDate>
      <link>https://dev.to/huitemagico/kmac-template-for-finite-state-machine-in-soroban-2kg4</link>
      <guid>https://dev.to/huitemagico/kmac-template-for-finite-state-machine-in-soroban-2kg4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W9__bWqz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/og287svyf8d9tlnxd8cx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W9__bWqz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/og287svyf8d9tlnxd8cx.png" alt="Image description" width="800" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;KMAC implements, with the &lt;a href="https://soroban.stellar.org/"&gt;Soroban Smart Contracts Platform&lt;/a&gt; , a Finite State Machine  template.&lt;br&gt;&lt;br&gt;
 The KMAC is an &lt;strong&gt;freely accessible program&lt;/strong&gt;, that  allows the creation of programs for Finite State Machine model. In the figure, an example of an application model built with the KMAC template is shown.&lt;/p&gt;

&lt;p&gt;The boxes painted in blue and green are "states," and the texts on the arrows are "transactions." &lt;br&gt;
The model of the green states, has been defined by a hypothetical "business user" who wants to model a "Coffee Vending Machine." &lt;br&gt;&lt;br&gt;
The business flow includes from select the coffee blend, buyer payment and coffee delivery.&lt;/p&gt;

&lt;p&gt;The core of KMAC is responsible for the flow defined by the blue states in the diagram. The other states (green boxes) and their respective transactions are defined by the developer using the KMAC template.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;The KMAC core controls all the flow&lt;/strong&gt; based on his internal FSM logic. The developer of the Vending Machine (or another system) only focuses on the &lt;strong&gt;business functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Learn about HOW the developer easily code the user part of the flow at &lt;a href="https://github.com/huitemagico/kmac/wiki"&gt;KMAC wiki doc&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
The image below shows from an "Sequence diagram model" the flow of transactions. The diagram shows how KMAC ensures that transactions are carried out by the appropriate users, in this case, either the 'buyer' or the 'admin'.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8avyZfg_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9nd6k3ttmbfx2zt6xir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8avyZfg_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9nd6k3ttmbfx2zt6xir.png" alt="Image description" width="800" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The “Extensible” KMAC Template.&lt;br&gt;
With KMAC  you can implement &lt;strong&gt;other examples of systems&lt;/strong&gt; based on Finite State Machine model, &lt;strong&gt;without the need to code the logic of the Finite State Machine flow&lt;/strong&gt;. You only need to focus on programming the specific 'user' functions for your new model.&lt;br&gt;&lt;br&gt;
I invite you to explore the comprehensive documentation of the KMAC system and download the programs from the &lt;a href="https://github.com/huitemagico/kmac"&gt;KMAC GitHub&lt;/a&gt;. Go to &lt;a href="https://soroban.stellar.org/"&gt;Soroban smart contract development platform&lt;/a&gt;  for learning about Soroban.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>rust</category>
      <category>cryptocurrency</category>
      <category>soroban</category>
    </item>
    <item>
      <title>Echo2: A Tiny Piece of Code for Learning and Practicing Soroban Rust SDK</title>
      <dc:creator>Alejandro Huitemagico</dc:creator>
      <pubDate>Mon, 28 Aug 2023 02:32:43 +0000</pubDate>
      <link>https://dev.to/huitemagico/echo2-a-tiny-piece-of-code-for-learning-and-practicing-soroban-rust-sdk-4h2m</link>
      <guid>https://dev.to/huitemagico/echo2-a-tiny-piece-of-code-for-learning-and-practicing-soroban-rust-sdk-4h2m</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DGkSVLxy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/63xrb21ax4j62h44wp3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DGkSVLxy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/63xrb21ax4j62h44wp3b.png" alt="echo2 state machine diagram" width="530" height="385"&gt;&lt;/a&gt;&lt;br&gt;
Hello everyone,&lt;/p&gt;

&lt;p&gt;To facilitate the learning process of the Soroban SDK &lt;a href="https://soroban.stellar.org/docs/reference/sdks/rust"&gt;https://soroban.stellar.org/docs/reference/sdks/rust&lt;/a&gt;  and provide to the beginners, like myself, with an example, I have created a program called "echo2".&lt;/p&gt;

&lt;p&gt;Note: If you want to access a comprehensive documentation for installing all the necessary tools to run 'echo2,' &lt;br&gt;
  please refer to &lt;a href="https://github.com/huitemagico/echo2/blob/rama1/echo2tutorial.pdf"&gt;echo2tutorial.pdf&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  (1) name
&lt;/h2&gt;

&lt;p&gt;echo2 "tiny piece of code for learning and practice soroban rust sdk"&lt;br&gt;
  version 1.1 &lt;/p&gt;

&lt;h2&gt;
  
  
  (2) What is the function of the echo2 program
&lt;/h2&gt;

&lt;p&gt;This program takes a text parameter as input from the caller, retrieves the previous message from &lt;br&gt;
&lt;a href="https://soroban.stellar.org/docs/fundamentals-and-concepts/persisting-data"&gt;persistent storage&lt;/a&gt; associated with the contract, and then saves the new message. &lt;br&gt;
So, with each subsequent call, 'echo2' returns 'the echo of your message' along with the previous message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oYs4d8T---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61zlrnc2zel55yzwwm15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oYs4d8T---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61zlrnc2zel55yzwwm15.png" alt="echo2 sequence" width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--afchjUx9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jr0lk3tqzja8oykqh1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--afchjUx9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jr0lk3tqzja8oykqh1r.png" alt="echo global diagram" width="774" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the community of Soroban programmers, I believe there is a significant opportunity for creating more basic examples, with documentation, and with that, making the code writing process with the &lt;a href="https://soroban.stellar.org/docs/getting-started/setup#install-the-soroban-cli"&gt;Soroban SDK&lt;/a&gt; much easier.&lt;/p&gt;

&lt;p&gt;You can find the code and documentation of echo2 program at: (&lt;a href="https://github.com/huitemagico/echo2"&gt;https://github.com/huitemagico/echo2&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  (3) Echo2 as an finite state machine
&lt;/h2&gt;

&lt;p&gt;Echo2 is a program that implements a basic state machine with two states: reset_state and echo_state. &lt;br&gt;
In the reset_state, the program does not process the previous message but instead resets it with a special meaning. &lt;br&gt;
If Echo2 receives another reset message while in the reset_state, it remains in that state. &lt;br&gt;
However, if it receives a message different from "reset," it transitions to the echo_state while saving the previous state and counter.&lt;br&gt;
While in the echo_state, if Echo2 receives a general message that is different from "reset," it remains in that state. &lt;br&gt;
The machine continues to stay in the echo_state until it receives a "reset" message, at which point it transitions back to the reset_state.&lt;br&gt;
The first diagram describes this.&lt;br&gt;
Note: The explanation of a state machine is easiest using a "finite state machine diagram" for better understanding.&lt;br&gt;
See "&lt;a href="https://en.wikipedia.org/wiki/Finite-state_machine"&gt;finite state machine diagram&lt;/a&gt;" &lt;/p&gt;

&lt;h2&gt;
  
  
  (4)  Steps for run the program:
&lt;/h2&gt;

&lt;p&gt;Note: If you want to access a comprehensive documentation for installing all the necessary tools to run 'echo2,' &lt;br&gt;
  please refer to &lt;a href="https://github.com/huitemagico/echo2/blob/rama1/echo2tutorial.pdf"&gt;echo2tutorial.pdf&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  (5) Some urls
&lt;/h2&gt;

&lt;p&gt;Storage&lt;br&gt;
&lt;a href="https://docs.rs/soroban-sdk/latest/soroban_sdk/storage/index.html"&gt;https://docs.rs/soroban-sdk/latest/soroban_sdk/storage/index.html&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Persisting Data&lt;br&gt;
&lt;a href="https://soroban.stellar.org/docs/fundamentals-and-concepts/persisting-data"&gt;https://soroban.stellar.org/docs/fundamentals-and-concepts/persisting-data&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Struct String&lt;br&gt;
&lt;a href="https://docs.rs/soroban-sdk/latest/soroban_sdk/struct.String.html"&gt;https://docs.rs/soroban-sdk/latest/soroban_sdk/struct.String.html&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Soroban struct Vec&lt;br&gt;
&lt;a href="https://docs.rs/soroban-sdk/latest/soroban_sdk/struct.Vec.html"&gt;https://docs.rs/soroban-sdk/latest/soroban_sdk/struct.Vec.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Struct Env&lt;br&gt;
&lt;a href="https://docs.rs/soroban-sdk/latest/soroban_sdk/struct.Env.html"&gt;https://docs.rs/soroban-sdk/latest/soroban_sdk/struct.Env.html&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Soroban CLI&lt;br&gt;
&lt;a href="https://soroban.stellar.org/docs/getting-started/setup#install-the-soroban-cli"&gt;https://soroban.stellar.org/docs/getting-started/setup#install-the-soroban-cli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Soroban examples doc&lt;br&gt;
&lt;a href="https://soroban.stellar.org/docs/basic-tutorials/events"&gt;https://soroban.stellar.org/docs/basic-tutorials/events&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Soroban examples&lt;br&gt;
&lt;a href="https://github.com/stellar/soroban-examples"&gt;https://github.com/stellar/soroban-examples&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rust doc&lt;br&gt;
&lt;a href="https://doc.rust-lang.org/std/index.html"&gt;https://doc.rust-lang.org/std/index.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Soroban Rust sdk&lt;br&gt;
&lt;a href="https://soroban.stellar.org/docs/reference/sdks/rust"&gt;https://soroban.stellar.org/docs/reference/sdks/rust&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github url&lt;br&gt;
(&lt;a href="https://github.com/huitemagico/echo2"&gt;https://github.com/huitemagico/echo2&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;THANKS FOR READING!&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>blockchain</category>
      <category>rust</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
