diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74b876a7d093222a9cfea8084edce25b35c53961..a422e01edacf89dad3d9e889529368bcf7a7a71e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ set(DAPSDK_MODULES "")
 if(NOT DEFINED CELLFRAME_MODULES)
     include (cmake/OS_Detection.cmake)
 
-    set(CELLFRAME_MODULES "core chains mining network srv cs-dag-poa cs-block-poa cs-dag-pos cs-block-pos cs-esbocs cs-none srv-app srv-app-db srv-datum srv-stake-pos-delegate srv-stake-lock srv-xchange")
+    set(CELLFRAME_MODULES "core chains mining network srv cs-dag-poa cs-block-poa cs-dag-pos cs-block-pos cs-esbocs cs-none srv-app srv-app-db srv-datum srv-stake srv-xchange")
 
     if(LINUX OR DARWIN)
         set(CELLFRAME_MODULES "${CELLFRAME_MODULES} srv-vpn")
@@ -210,18 +210,9 @@ if (CELLFRAME_MODULES MATCHES "srv-xchange")
 endif()
 
 # Enable service of stake token
-if (CELLFRAME_MODULES MATCHES "srv-stake-lock")
-    message("[+] Module 'srv-stake-lock'")
-    set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_chain_net_srv_stake_lock)
-endif()
-
-# Enable service of delegated stake
-if (CELLFRAME_MODULES MATCHES "srv-stake-pos-delegate")
-    message("[+] Module 'srv-stake-pos-delegate'")
-    #add TARGET_FILE for proper symbols resolving
-    #pos_delegate depends on symbols from this libs
-    set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_chain_net_srv_stake_pos_delegate $<TARGET_FILE:dap_chain_cs_dag_poa> $<TARGET_FILE:dap_chain_cs_block_poa> $<TARGET_FILE:dap_chain_cs_dag> $<TARGET_FILE:dap_chain_cs_blocks>)
-    set(CELLFRAME_LIBS ${CELLFRAME_LIBS} crc32c_adler)
+if (CELLFRAME_MODULES MATCHES "srv-stake")
+    message("[+] Module 'srv-stake'")
+    set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_chain_net_srv_stake)
 endif()
 
 # Enable service for dynamic modules
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
index 66cf900cedd7d54bc315393c4e688bf87bab22a4..353f1a9b41e7074ac0e827af7e07f8d8b0a163b7 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -106,14 +106,9 @@ if (CELLFRAME_MODULES MATCHES "srv-xchange")
     add_subdirectory(service/xchange)
 endif()
 
-# Service for token staking
-if (CELLFRAME_MODULES MATCHES "srv-stake-lock")
-    add_subdirectory(service/stake_lock)
-endif()
-
-# Service for PoS stake delegation
-if (CELLFRAME_MODULES MATCHES "srv-stake-pos-delegate")
-    add_subdirectory(service/stake_pos_delegate)
+# Service for token staking and PoS delegation
+if (CELLFRAME_MODULES MATCHES "srv-stake")
+    add_subdirectory(service/stake)
 endif()
 
 # Unit tests
diff --git a/modules/chain/dap_chain_ledger.c b/modules/chain/dap_chain_ledger.c
index 79eb2081ceb7716aaf49636129073fba9793b350..eac3cadd8e6b43e312c66e77de26ea27de4cfe10 100644
--- a/modules/chain/dap_chain_ledger.c
+++ b/modules/chain/dap_chain_ledger.c
@@ -62,7 +62,7 @@
 typedef struct dap_chain_ledger_verificator {
     int subtype;    // hash key
     dap_chain_ledger_verificator_callback_t callback;
-    dap_chain_ledger_verificator_callback_out_t callback_added;
+    dap_chain_ledger_updater_callback_t callback_added;
     UT_hash_handle hh;
 } dap_chain_ledger_verificator_t;
 
@@ -3128,6 +3128,7 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
     }
     dap_chain_ledger_tx_bound_t *bound_item;
     dap_chain_hash_fast_t l_hash_pkey = {};
+    bool l_girdled_ems_used = false;
      // find all previous transactions
     dap_list_t *l_list_tmp = l_list_in;
     for (int l_list_tmp_num = 0; l_list_tmp; l_list_tmp = dap_list_next(l_list_tmp), l_list_tmp_num++) {
@@ -3169,6 +3170,7 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
         dap_chain_datum_tx_t *l_tx_prev = NULL;
         dap_chain_ledger_token_emission_item_t *l_emission_item = NULL;
         dap_chain_ledger_stake_lock_item_t *l_stake_lock_emission = NULL;
+        bool l_girdled_ems = false;
         if (l_cond_type == TX_ITEM_TYPE_IN_EMS) {   // It's the emission (base) TX
             l_token = l_tx_in_ems->header.ticker;
             l_emission_hash = &l_tx_in_ems->header.token_emission_hash;
@@ -3180,16 +3182,33 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
                     break;
                 }
                 bound_item->item_emission = l_emission_item;
-            } else if ( (l_stake_lock_emission = s_emissions_for_stake_lock_item_find(a_ledger, l_emission_hash)) ) {
+            } else if ((l_girdled_ems = dap_hash_fast_is_blank(l_emission_hash)) ||
+                            (l_stake_lock_emission = s_emissions_for_stake_lock_item_find(a_ledger, l_emission_hash))) {
+                dap_chain_datum_tx_t *l_tx_stake_lock = a_tx;
                 // check emission for STAKE_LOCK
-                dap_hash_fast_t cur_tx_hash;
-                dap_hash_fast(a_tx, dap_chain_datum_tx_get_size(a_tx), &cur_tx_hash);
-                if (!dap_hash_fast_is_blank(&l_stake_lock_emission->tx_used_out)) {
-                    if (!dap_hash_fast_compare(&cur_tx_hash, &l_stake_lock_emission->tx_used_out))
-                        debug_if(s_debug_more, L_WARNING, "stake_lock_emission already present in cache for IN_EMS [%s]", l_token);
-                    else
+                if (!dap_hash_fast_is_blank(l_emission_hash)) {
+                    dap_hash_fast_t cur_tx_hash;
+                    dap_hash_fast(a_tx, dap_chain_datum_tx_get_size(a_tx), &cur_tx_hash);
+                    if (!dap_hash_fast_is_blank(&l_stake_lock_emission->tx_used_out)) {
+                        if (!dap_hash_fast_compare(&cur_tx_hash, &l_stake_lock_emission->tx_used_out))
+                            debug_if(s_debug_more, L_WARNING, "stake_lock_emission already present in cache for IN_EMS [%s]", l_token);
+                        else
+                            debug_if(s_debug_more, L_WARNING, "stake_lock_emission is used out for IN_EMS [%s]", l_token);
+                        l_err_num = -22;
+                        break;
+                    }
+                    l_tx_stake_lock = dap_chain_ledger_tx_find_by_hash(a_ledger, l_emission_hash);
+                } else {
+                    if (l_girdled_ems_used) {    // Only one allowed item with girdled emission
                         debug_if(s_debug_more, L_WARNING, "stake_lock_emission is used out for IN_EMS [%s]", l_token);
-                    l_err_num = -22;
+                        l_err_num = -22;
+                        break;
+                    } else
+                        l_girdled_ems_used = true;
+                }
+                if (!l_tx_stake_lock) {
+                    debug_if(s_debug_more, L_WARNING, "Not found stake_lock transaction");
+                    l_err_num = DAP_CHAIN_CS_VERIFY_CODE_TX_NO_EMISSION;
                     break;
                 }
                 dap_tsd_t *l_tsd;
@@ -3211,18 +3230,16 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
                     l_err_num = -31;
                     break;
                 }
-                dap_chain_datum_token_tsd_delegate_from_stake_lock_t l_tsd_section = dap_tsd_get_scalar(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
-                if (!dap_chain_ledger_token_ticker_check(a_ledger, (char *)l_tsd_section.ticker_token_from)) {
-                    debug_if(s_debug_more, L_WARNING, "Token [%s] no found", l_tsd_section.ticker_token_from);
+                dap_chain_datum_token_tsd_delegate_from_stake_lock_t *l_tsd_section = dap_tsd_get_object(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
+                if (!dap_chain_ledger_token_ticker_check(a_ledger, (char *)l_tsd_section->ticker_token_from)) {
+                    debug_if(s_debug_more, L_WARNING, "Token [%s] no found", l_tsd_section->ticker_token_from);
                     l_err_num = -23;
                     break;
                 }
-                dap_chain_datum_tx_t *l_tx_stake_lock = dap_chain_ledger_tx_find_by_hash(a_ledger, l_emission_hash);
-                if (!l_tx_stake_lock) {
-                    debug_if(s_debug_more, L_WARNING, "Not found stake_lock transaction");
-                    l_err_num = DAP_CHAIN_CS_VERIFY_CODE_TX_NO_EMISSION;
-                    break;
-                }
+
+                if (l_girdled_ems)
+                    l_main_ticker = (const char *)l_tsd_section->ticker_token_from;
+
                 dap_chain_tx_out_cond_t *l_tx_stake_lock_out_cond = dap_chain_datum_tx_out_cond_get(l_tx_stake_lock, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK, NULL);
                 if (!l_tx_stake_lock_out_cond) {
                     debug_if(s_debug_more, L_WARNING, "No OUT_COND of stake_lock subtype for IN_EMS [%s]", l_tx_in_ems->header.ticker);
@@ -3230,9 +3247,9 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
                     break;
                 }
                 uint256_t l_value_expected ={};
-                if (MULT_256_COIN(l_tx_stake_lock_out_cond->header.value, l_tsd_section.emission_rate, &l_value_expected)!=0){
+                if (MULT_256_COIN(l_tx_stake_lock_out_cond->header.value, l_tsd_section->emission_rate, &l_value_expected)!=0){
                     if(s_debug_more){
-                        char * l_emission_rate_str = dap_chain_balance_print(l_tsd_section.emission_rate);
+                        char * l_emission_rate_str = dap_chain_balance_print(l_tsd_section->emission_rate);
                         char * l_locked_value_str = dap_chain_balance_print(l_tx_stake_lock_out_cond->header.value);
                         log_it( L_WARNING, "Multiplication overflow for %s emission: locked value %s emission rate %s"
                         , l_tx_in_ems->header.ticker, l_locked_value_str, l_emission_rate_str);
@@ -3247,8 +3264,14 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
                 int l_item_idx = 0;
                 do {
                     l_tx_out_ext = (dap_chain_tx_out_ext_t *)dap_chain_datum_tx_item_get(a_tx, &l_item_idx, TX_ITEM_TYPE_OUT_EXT, NULL);
-                    if (!l_tx_out_ext)
+                    if (!l_tx_out_ext) {
+                        if (l_girdled_ems) {
+                            debug_if(s_debug_more, L_WARNING, "No OUT_EXT for girdled IN_EMS [%s]", l_tx_in_ems->header.ticker);
+                            l_err_num = -36;
+                        }
                         break;
+                    }
+                    l_item_idx++;
                 } while (strcmp(l_tx_out_ext->token, l_token));
                 if (!l_tx_out_ext) {
                     dap_chain_tx_out_t *l_tx_out = (dap_chain_tx_out_t *)dap_chain_datum_tx_item_get(a_tx, NULL, TX_ITEM_TYPE_OUT, NULL);
@@ -3283,22 +3306,27 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
                     l_err_num = -34;
                     break;
                 }
-                // check tiker
-                const char *tx_tiker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, l_emission_hash);
-                if (!tx_tiker) {
-                    debug_if(s_debug_more, L_WARNING, "No ticker stake_lock to for IN_EMS [%s]", l_tx_in_ems->header.ticker);
-                    l_err_num = -33;
-                    break;
-                }
-                if (strcmp(tx_tiker, (char *)l_tsd_section.ticker_token_from)) {
-                    debug_if(s_debug_more, L_WARNING, "Tickers not equal for [%s]", l_tx_in_ems->header.ticker);
-                    l_err_num = -35;
-                    break;
+                if (!l_girdled_ems) {
+                    // check tiker
+                    const char *l_tx_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, l_emission_hash);
+                    if (!l_tx_ticker) {
+                        debug_if(s_debug_more, L_WARNING, "No ticker found for sake_lock tx [wait %s]", l_tx_in_ems->header.ticker);
+                        l_err_num = -33;
+                        break;
+                    }
+                    if (strcmp(l_tx_ticker, (char *)l_tsd_section->ticker_token_from)) {
+                        debug_if(s_debug_more, L_WARNING, "Ticker %s in different for expected %s", l_tx_ticker, l_tx_in_ems->header.ticker);
+                        l_err_num = -35;
+                        break;
+                    }
                 }
                 debug_if(s_debug_more, L_NOTICE, "Check emission passed for IN_EMS [%s]", l_tx_in_ems->header.ticker);
                 bound_item->tx_prev = l_tx_stake_lock;
-                bound_item->stake_lock_item = l_stake_lock_emission;
-                bound_item->stake_lock_item->ems_value = l_value_expected;
+                if (l_stake_lock_emission) {
+                    bound_item->stake_lock_item = l_stake_lock_emission;
+                    bound_item->stake_lock_item->ems_value = l_value_expected;
+                } else // girdled emission
+                    bound_item->out.tx_prev_out_ext_256 = l_tx_out_ext;
             } else {
                 l_err_num = DAP_CHAIN_CS_VERIFY_CODE_TX_NO_EMISSION;
                 break;
@@ -3420,7 +3448,7 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
                 l_err_num = -13;
                 break;
             }
-            if (l_verificator->callback(a_ledger, &l_tx_prev_hash, l_tx_prev_out_cond, a_tx, l_owner) == false) {
+            if (l_verificator->callback(a_ledger, l_tx_prev_out_cond, a_tx, l_owner) == false) {
                 debug_if(s_debug_more, L_WARNING, "Verificator check error for conditional output %s",
                                                     dap_chain_tx_out_cond_subtype_to_str(l_sub_tmp));
                 l_err_num = -14;
@@ -3433,6 +3461,9 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
             if (l_stake_lock_emission) {
                 l_token = bound_item->in.tx_cur_in_ems->header.ticker;
                 l_value = bound_item->stake_lock_item->ems_value;
+            } else if (l_girdled_ems) {
+                l_token = bound_item->in.tx_cur_in_ems->header.ticker;
+                l_value = bound_item->out.tx_prev_out_ext_256->header.value;
             } else {
                 l_token = bound_item->item_emission->datum_token_emission->hdr.ticker;
                 l_value = bound_item->item_emission->datum_token_emission->hdr.value_256;
@@ -3528,7 +3559,6 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
         HASH_ADD_STR(l_values_from_cur_tx, token_ticker, l_value_cur);
     }
 
-
     // find 'out' items
     dap_list_t *l_list_out = dap_chain_datum_tx_items_get((dap_chain_datum_tx_t*) a_tx, TX_ITEM_TYPE_OUT_ALL, NULL);
     uint256_t l_value = {}, l_fee_sum = {};
@@ -3551,12 +3581,8 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t
         case TX_ITEM_TYPE_OUT: { // 256
             dap_chain_tx_out_t *l_tx_out = (dap_chain_tx_out_t *)l_list_tmp->data;
             if (l_multichannel) { // token ticker is mandatory for multichannel transactions
-                if (l_main_ticker)
-                    l_token = l_main_ticker;
-                else {
-                    l_err_num = -16;
-                    break;
-                }
+                l_err_num = -16;
+                break;
             }
             l_value = l_tx_out->header.value;
             l_tx_out_to = l_tx_out->addr;
@@ -3892,34 +3918,34 @@ static inline int s_tx_add(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, d
         dap_chain_tx_item_type_t l_type = *(uint8_t *)l_item_in;
         if (l_type == TX_ITEM_TYPE_IN_EMS) {
              // It's the emission behind
-            // Find token ticker for emission
-            dap_chain_tx_in_ems_t * l_in_ems = (dap_chain_tx_in_ems_t *) dap_chain_datum_tx_item_get(a_tx, NULL, TX_ITEM_TYPE_IN_EMS, NULL);
-            if (!l_in_ems) {
-                log_it(L_ERROR, "No token item with blank prev tx hash");
-                break;
-            }
+            dap_chain_tx_in_ems_t *l_in_ems = bound_item->in.tx_cur_in_ems;
+            const char *l_delegated_ticker_str = l_in_ems->header.ticker;
             if (bound_item->tx_prev) { // It's the stake lock emission
                 dap_chain_ledger_token_item_t *l_token_item = NULL;
                 pthread_rwlock_rdlock(&l_ledger_pvt->tokens_rwlock);
-                HASH_FIND_STR(l_ledger_pvt->tokens, l_main_token_ticker, l_token_item);
+                HASH_FIND_STR(l_ledger_pvt->tokens, l_delegated_ticker_str, l_token_item);
                 pthread_rwlock_unlock(&l_ledger_pvt->tokens_rwlock);
-                if (!l_token_item) {
-                    log_it(L_ERROR, "No token item found for token %s", l_main_token_ticker);
-                    break;
-                }
-                if (!IS_ZERO_256(l_token_item->total_supply)) {
-                    SUBTRACT_256_256(l_token_item->current_supply, bound_item->stake_lock_item->ems_value,
-                                     &l_token_item->current_supply);
-                    char *l_balance = dap_chain_balance_print(l_token_item->current_supply);
-                    log_it(L_DEBUG, "New current supply %s for token %s", l_balance, l_token_item->ticker);
-                    DAP_DEL_Z(l_balance);
+                if (l_token_item) {
+                    if (!IS_ZERO_256(l_token_item->total_supply)) {
+                        uint256_t *l_value = bound_item->stake_lock_item ?
+                                    &bound_item->stake_lock_item->ems_value :
+                                    &bound_item->out.tx_prev_out_ext_256->header.value;
+                        SUBTRACT_256_256(l_token_item->current_supply, *l_value,
+                                         &l_token_item->current_supply);
+                        char *l_balance = dap_chain_balance_print(l_token_item->current_supply);
+                        log_it(L_DEBUG, "New current supply %s for token %s", l_balance, l_token_item->ticker);
+                        DAP_DEL_Z(l_balance);
+                        if (PVT(a_ledger)->cached)
+                            s_ledger_token_cache_update(a_ledger, l_token_item);
+                    }
+                } else
+                    log_it(L_ERROR, "No token item found for token %s", l_delegated_ticker_str);
+                if (bound_item->stake_lock_item) {
+                    bound_item->stake_lock_item->tx_used_out = *a_tx_hash;
                     if (PVT(a_ledger)->cached)
-                        s_ledger_token_cache_update(a_ledger, l_token_item);
+                        // Mirror it in cache
+                        s_ledger_stake_lock_cache_update(a_ledger, bound_item->stake_lock_item);
                 }
-                bound_item->stake_lock_item->tx_used_out = *a_tx_hash;
-                if (PVT(a_ledger)->cached)
-                    // Mirror it in cache
-                    s_ledger_stake_lock_cache_update(a_ledger, bound_item->stake_lock_item);
             } else {    // It's the general emission
                 // Mark it as used with base tx hash
                 bound_item->item_emission->tx_used_out = *a_tx_hash;
@@ -4974,7 +5000,7 @@ dap_list_t *dap_chain_ledger_get_list_tx_outs_with_val(dap_ledger_t *a_ledger, c
 }
 
 // Add new verificator callback with associated subtype. Returns 1 if callback replaced, overwise returns 0
-int dap_chain_ledger_verificator_add(dap_chain_tx_out_cond_subtype_t a_subtype, dap_chain_ledger_verificator_callback_t a_callback, dap_chain_ledger_verificator_callback_out_t a_callback_added)
+int dap_chain_ledger_verificator_add(dap_chain_tx_out_cond_subtype_t a_subtype, dap_chain_ledger_verificator_callback_t a_callback, dap_chain_ledger_updater_callback_t a_callback_added)
 {
     dap_chain_ledger_verificator_t *l_new_verificator;
     int l_tmp = (int)a_subtype;
diff --git a/modules/chain/include/dap_chain_ledger.h b/modules/chain/include/dap_chain_ledger.h
index e0cc9f45e2b47ad6fc6c244095aeb61186f803da..cf7e88eefac8fae19a9dae49fe04c94acfe424ef 100644
--- a/modules/chain/include/dap_chain_ledger.h
+++ b/modules/chain/include/dap_chain_ledger.h
@@ -42,9 +42,8 @@ typedef struct dap_ledger {
     void *_internal;
 } dap_ledger_t;
 
-typedef bool (* dap_chain_ledger_verificator_callback_t)(dap_ledger_t * a_ledger, dap_hash_fast_t *a_tx_out_hash,  dap_chain_tx_out_cond_t *a_tx_out_cond,
-                                                         dap_chain_datum_tx_t *a_tx_in, bool a_owner);
-typedef void (*dap_chain_ledger_verificator_callback_out_t)(dap_ledger_t* a_ledger, dap_chain_datum_tx_t* a_tx, dap_chain_tx_out_cond_t* a_cond);
+typedef bool (*dap_chain_ledger_verificator_callback_t)(dap_ledger_t *a_ledger, dap_chain_tx_out_cond_t *a_tx_out_cond, dap_chain_datum_tx_t *a_tx_in, bool a_owner);
+typedef void (*dap_chain_ledger_updater_callback_t)(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_t *a_prev_cond);
 typedef void (* dap_chain_ledger_tx_add_notify_t)(void *a_arg, dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx);
 typedef bool (*dap_chain_ledger_cache_tx_check_callback_t)(dap_hash_fast_t *a_tx_hash);
 typedef struct dap_chain_net dap_chain_net_t;
@@ -263,7 +262,7 @@ dap_list_t *dap_chain_ledger_get_list_tx_cond_outs_with_val(dap_ledger_t *a_ledg
 
 // Add new verificator callback with associated subtype. Returns 1 if callback replaced, overwise returns 0
 int dap_chain_ledger_verificator_add(dap_chain_tx_out_cond_subtype_t a_subtype, dap_chain_ledger_verificator_callback_t a_callback,
-                                     dap_chain_ledger_verificator_callback_out_t a_callback_added);
+                                     dap_chain_ledger_updater_callback_t a_callback_added);
 
 // Getting a list of transactions from the ledger.
 dap_list_t * dap_chain_ledger_get_txs(dap_ledger_t *a_ledger, size_t a_count, size_t a_page, bool a_reverse);
diff --git a/modules/channel/chain-net/CMakeLists.txt b/modules/channel/chain-net/CMakeLists.txt
index 49b7ffcd15a5861562fc973e5fd0fba37e60a567..5972b985cc2fb8ce4bf225da11ce8ad00b02ee71 100644
--- a/modules/channel/chain-net/CMakeLists.txt
+++ b/modules/channel/chain-net/CMakeLists.txt
@@ -7,7 +7,7 @@ file(GLOB DAP_STREAM_CH_CHAIN_NET_HDRS include/*.h)
 add_library(${PROJECT_NAME} STATIC ${DAP_STREAM_CH_CHAIN_NET_SRCS} ${DAP_STREAM_CH_CHAIN_NET_HDRS})
 
 target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_stream dap_stream_ch dap_stream_ch_chain
-                                               dap_chain_net)
+                                               dap_chain_net dap_chain_net_srv_stake)
 
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/common/dap_chain_datum.c b/modules/common/dap_chain_datum.c
index 5cb3bc3ecc574425062b59f4803c0417a311d5ae..85c1d4ca1c319cdcc76f442132bed874bed647e5 100644
--- a/modules/common/dap_chain_datum.c
+++ b/modules/common/dap_chain_datum.c
@@ -137,9 +137,9 @@ void s_datum_token_dump_tsd(dap_string_t *a_str_out, dap_chain_datum_token_t *a_
             break;
             case DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK: {
                 char *balance = NULL;
-                dap_chain_datum_token_tsd_delegate_from_stake_lock_t l_tsd_section = dap_tsd_get_scalar(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
+                dap_chain_datum_token_tsd_delegate_from_stake_lock_t *l_tsd_section = dap_tsd_get_object(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
                 dap_string_append_printf(a_str_out, "ticker_token_from: %s\nemission_rate: %s\n",
-                                         l_tsd_section.ticker_token_from, (balance = dap_chain_balance_to_coins(l_tsd_section.emission_rate)));
+                                         l_tsd_section->ticker_token_from, (balance = dap_chain_balance_to_coins(l_tsd_section->emission_rate)));
                 DAP_DEL_Z(balance);
             }break;
             case DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_ALLOWED_ADD  :
diff --git a/modules/common/dap_chain_datum_tx_items.c b/modules/common/dap_chain_datum_tx_items.c
index 7b64c29b965fc0f0d7ba5085fa87072cb90a925b..e5a8d4df031e8d4ce5b0e29e3f9fe16f5118944b 100644
--- a/modules/common/dap_chain_datum_tx_items.c
+++ b/modules/common/dap_chain_datum_tx_items.c
@@ -584,9 +584,9 @@ json_object *dap_chain_datum_tx_item_out_cond_srv_stake_to_json(dap_chain_tx_out
  * @param token
  * @return
  */
-dap_chain_tx_out_cond_t *dap_chain_net_srv_stake_lock_create_cond_out(dap_pkey_t *a_key, dap_chain_net_srv_uid_t a_srv_uid,
-                                                                      uint256_t a_value, uint64_t a_time_staking,
-                                                                      uint256_t a_reinvest_percent, bool create_base_tx)
+dap_chain_tx_out_cond_t *dap_chain_datum_tx_item_out_cond_create_srv_stake_lock(dap_chain_net_srv_uid_t a_srv_uid,
+                                                                                uint256_t a_value, uint64_t a_time_staking,
+                                                                                uint256_t a_reinvest_percent)
 {
     if (IS_ZERO_256(a_value))
         return NULL;
@@ -595,17 +595,9 @@ dap_chain_tx_out_cond_t *dap_chain_net_srv_stake_lock_create_cond_out(dap_pkey_t
     l_item->header.value = a_value;
     l_item->header.subtype = DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK;
     l_item->header.srv_uid = a_srv_uid;
+    l_item->subtype.srv_stake_lock.flags = DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_BY_TIME | DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_EMIT;
     l_item->subtype.srv_stake_lock.reinvest_percent = a_reinvest_percent;
-    if (a_time_staking) {
-//		l_item->header.ts_expires = dap_time_now() + a_time_staking;
-        l_item->subtype.srv_stake_lock.time_unlock = dap_time_now() + a_time_staking;
-        l_item->subtype.srv_stake_lock.flags |= DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_BY_TIME;
-    }
-    if (create_base_tx)
-        l_item->subtype.srv_stake_lock.flags |= DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX;
-    if (a_key)
-        dap_hash_fast(a_key->pkey, a_key->header.size, &l_item->subtype.srv_stake_lock.pkey_delegated);
-
+    l_item->subtype.srv_stake_lock.time_unlock = dap_time_now() + a_time_staking;
     return l_item;
 }
 
@@ -622,15 +614,11 @@ json_object *dap_chain_net_srv_stake_lock_cond_out_to_json(dap_chain_tx_out_cond
         DAP_DELETE(l_reinvest_precent);
         json_object *l_obj_time_unlock = json_object_new_uint64(a_stake_lock->subtype.srv_stake_lock.time_unlock);
         json_object *l_obj_flags = json_object_new_uint64(a_stake_lock->subtype.srv_stake_lock.flags);
-        char *l_pkey_delegate_hash = dap_hash_fast_to_str_new(&a_stake_lock->subtype.srv_stake_lock.pkey_delegated);
-        json_object *l_obj_pkey_delegate_hash = json_object_new_string(l_pkey_delegate_hash);
-        DAP_DELETE(l_pkey_delegate_hash);
         json_object_object_add(l_object, "value", l_obj_value);
         json_object_object_add(l_object, "srvUID", l_obj_srv_uid);
         json_object_object_add(l_object, "reinvestPercent", l_obj_reinvest_percent);
         json_object_object_add(l_object, "timeUnlock", l_obj_time_unlock);
         json_object_object_add(l_object, "flags", l_obj_flags);
-        json_object_object_add(l_object, "pkeyDelegateHash", l_obj_pkey_delegate_hash);
         return l_object;
     }
     return NULL;
diff --git a/modules/common/include/dap_chain_common.h b/modules/common/include/dap_chain_common.h
index 3eb823c5a78d916f99a0c1fd96ec349a57c5eb86..bac63b331a4e0cf7bbc7948234e28b603c059f9e 100644
--- a/modules/common/include/dap_chain_common.h
+++ b/modules/common/include/dap_chain_common.h
@@ -166,10 +166,10 @@ typedef struct dap_chain_addr{
 typedef union {
     uint8_t raw[DAP_CHAIN_NET_SRV_UID_SIZE];
 #if DAP_CHAIN_NET_SRV_UID_SIZE == 8
-    uint64_t raw_ui64[1];
+    uint64_t raw_ui64;
     uint64_t uint64;
 #elif DAP_CHAIN_NET_SRV_UID_SIZE == 16
-    uint64_t raw_ui64[1];
+    uint64_t raw_ui64[2];
     uint128_t uint128;
 #endif
 } dap_chain_net_srv_uid_t;
@@ -259,6 +259,7 @@ int dap_chain_addr_fill_from_key(dap_chain_addr_t *a_addr, dap_enc_key_t *a_key,
 int dap_chain_addr_fill_from_sign(dap_chain_addr_t *a_addr, dap_sign_t *a_sign, dap_chain_net_id_t a_net_id);
 
 int dap_chain_addr_check_sum(const dap_chain_addr_t *a_addr);
+
 DAP_STATIC_INLINE bool dap_chain_addr_compare(const dap_chain_addr_t *a_addr1, const dap_chain_addr_t *a_addr2)
 {
     return !memcmp(a_addr1, a_addr2, sizeof(dap_chain_addr_t));
diff --git a/modules/common/include/dap_chain_datum_tx_items.h b/modules/common/include/dap_chain_datum_tx_items.h
index d1747b1450fc6c79f0232829a36c5ce342562017..13a728fbc469102b4cab01da8c047e3cb2ba3354 100644
--- a/modules/common/include/dap_chain_datum_tx_items.h
+++ b/modules/common/include/dap_chain_datum_tx_items.h
@@ -158,13 +158,6 @@ dap_chain_tx_out_cond_t *dap_chain_datum_tx_item_out_cond_create_fee(uint256_t a
 
 json_object *dap_chain_datum_tx_item_out_cond_fee_to_json(dap_chain_tx_out_cond_t *a_fee);
 
-/**
- * Create item dap_chain_tx_out_cond_t with fee stake subtype
- *
- * return item, NULL Error
- */
-dap_chain_tx_out_cond_t *dap_chain_datum_tx_item_out_cond_create_fee_stake(uint256_t a_value);
-
 /**
  * Create item dap_chain_tx_out_cond_t
  *
@@ -200,9 +193,9 @@ dap_chain_tx_out_cond_t *dap_chain_datum_tx_item_out_cond_create_srv_stake(dap_c
 json_object *dap_chain_datum_tx_item_out_cond_srv_stake_to_json(dap_chain_tx_out_cond_t* a_srv_stake);
 
 // Create cond out
-dap_chain_tx_out_cond_t	*dap_chain_net_srv_stake_lock_create_cond_out(dap_pkey_t *a_key, dap_chain_net_srv_uid_t a_srv_uid,
-                                                                      uint256_t a_value, uint64_t a_time_staking,
-                                                                      uint256_t a_reinvest_percent, bool create_base_tx);
+dap_chain_tx_out_cond_t *dap_chain_datum_tx_item_out_cond_create_srv_stake_lock(dap_chain_net_srv_uid_t a_srv_uid,
+                                                                                  uint256_t a_value, uint64_t a_time_staking,
+                                                                                  uint256_t a_reinvest_percent);
 
 json_object *dap_chain_net_srv_stake_lock_cond_out_to_json(dap_chain_tx_out_cond_t *a_stake_lock);
 
diff --git a/modules/common/include/dap_chain_datum_tx_out_cond.h b/modules/common/include/dap_chain_datum_tx_out_cond.h
index 96e868ac15e7adce5c1b95b83283aa71e8e918ad..5bce661a7e0c06a61fd4f86a6fab3bef6e6a5e6d 100644
--- a/modules/common/include/dap_chain_datum_tx_out_cond.h
+++ b/modules/common/include/dap_chain_datum_tx_out_cond.h
@@ -53,17 +53,13 @@ DAP_STATIC_INLINE const char *dap_chain_tx_out_cond_subtype_to_str(dap_chain_tx_
     return "UNDEFINED";
 }
 
-// Allow to spend stake by network
-// Need for service staking to enable network governance to fee the service provider
-#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_ENABLE_NET_FEE           0x00000001
-// Delegate token to prove thats stake is provided
-#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_DELEGATE_TOKEN           0x00000002
-// Delegate public key's hash
-#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_DELEGATE_PKEY            0x00000004
+// Stake lock base flags
 // Lock by time
-#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_BY_TIME                  0x00000008
+#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_BY_TIME           0x00000008
 // Create base tx for delegated token
-#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX           0x00000010
+#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX    0x00000010
+// Emit with single lock TX
+#define DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_EMIT              0x00000020
 
 /**
  * @struct dap_chain_tx_out
@@ -116,7 +112,7 @@ typedef struct dap_chain_tx_out_cond {
         } DAP_ALIGN_PACKED srv_stake_pos_delegate;
         struct {
             dap_time_t		time_unlock;
-            dap_hash_fast_t	pkey_delegated;
+            dap_hash_fast_t	unused;
             uint256_t		reinvest_percent;
             uint32_t		flags;
             byte_t          padding[4];
diff --git a/modules/consensus/block-poa/CMakeLists.txt b/modules/consensus/block-poa/CMakeLists.txt
index 65426cad101cc232df6a4a3ccde628af513f3517..e6046505a9475a1139004f8fcd2e03a159fe2ec0 100644
--- a/modules/consensus/block-poa/CMakeLists.txt
+++ b/modules/consensus/block-poa/CMakeLists.txt
@@ -6,6 +6,6 @@ file(GLOB DAP_CHAIN_BLOCK_CS_POA_HEADERS include/*.h)
 
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_BLOCK_CS_POA_SRCS} ${DAP_CHAIN_BLOCK_CS_POA_HEADERS})
 
-target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_blocks dap_chain_net_srv_stake_pos_delegate)
+target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_blocks)
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/consensus/block-pos/CMakeLists.txt b/modules/consensus/block-pos/CMakeLists.txt
index 7e60d80f903b10fce4ff964cff42c76ca62838f0..82db9813d05fe2dd9cff3c19cd96c8164462ed8e 100644
--- a/modules/consensus/block-pos/CMakeLists.txt
+++ b/modules/consensus/block-pos/CMakeLists.txt
@@ -6,6 +6,6 @@ file(GLOB DAP_CHAIN_CS_BLOCK_POS_HEADERS include/*.h)
 
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_CS_BLOCK_POS_SRCS} ${DAP_CHAIN_CS_BLOCK_POS_HEADERS})
 
-target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_blocks dap_chain_net_srv_stake_pos_delegate)
+target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_blocks dap_chain_net_srv_stake)
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/consensus/dag-pos/CMakeLists.txt b/modules/consensus/dag-pos/CMakeLists.txt
index 2afb0ea826ecf84ea468a807a29903ff7456ebbe..1e5cecca4333ca95873fbe794694732148f98ee3 100644
--- a/modules/consensus/dag-pos/CMakeLists.txt
+++ b/modules/consensus/dag-pos/CMakeLists.txt
@@ -6,6 +6,6 @@ file(GLOB DAP_CHAIN_CS_DAG_POS_HEADERS include/*.h)
 
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_CS_DAG_POS_SRCS} ${DAP_CHAIN_CS_DAG_POS_HEADERS})
 
-target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_dag dap_chain_net_srv_stake_pos_delegate)
+target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_dag dap_chain_net_srv_stake)
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/consensus/esbocs/CMakeLists.txt b/modules/consensus/esbocs/CMakeLists.txt
index beada9e5a9f93e97c545212b9a73c83bfd95d610..f04707f128ce6c6075ea2cf8078f2b1bb9495ffc 100644
--- a/modules/consensus/esbocs/CMakeLists.txt
+++ b/modules/consensus/esbocs/CMakeLists.txt
@@ -6,6 +6,6 @@ file(GLOB DAP_CHAIN_CS_ESBOCS_HEADERS include/*.h)
 
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_ESBOCS_SRCS} ${DAP_CHAIN_CS_ESBOCS_HEADERS})
 
-target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_blocks dap_chain_net_srv_stake_pos_delegate dap_stream_ch_chain_voting)
+target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_cs_blocks dap_chain_net_srv_stake dap_stream_ch_chain_voting)
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/consensus/none/dap_chain_cs_none.c b/modules/consensus/none/dap_chain_cs_none.c
index 78a86c04eef9c92a9f6d49e256696fecd1a20a7d..96731e5774fe7117c44f40fe9b7d3dd10e922dee 100644
--- a/modules/consensus/none/dap_chain_cs_none.c
+++ b/modules/consensus/none/dap_chain_cs_none.c
@@ -369,7 +369,7 @@ static dap_chain_atom_verify_res_t s_chain_callback_atom_add(dap_chain_t * a_cha
     dap_chain_gdb_datum_hash_item_t * l_hash_item = DAP_NEW_Z(dap_chain_gdb_datum_hash_item_t);
     size_t l_datum_size = dap_chain_datum_size(l_datum);
     dap_hash_fast(l_datum->data,l_datum->header.data_size,&l_hash_item->datum_data_hash );
-    dap_chain_hash_fast_to_str(&l_hash_item->datum_data_hash,l_hash_item->key,sizeof(l_hash_item->key)-1);
+    dap_chain_hash_fast_to_str(&l_hash_item->datum_data_hash, l_hash_item->key, sizeof(l_hash_item->key));
     if (!l_gdb_priv->is_load_mode) {
         dap_global_db_set(l_gdb_priv->group_datums, l_hash_item->key, l_datum, l_datum_size, false, NULL, NULL);
     } else
diff --git a/modules/mempool/CMakeLists.txt b/modules/mempool/CMakeLists.txt
index c187a6b5398d8f280cd9e7853100629b95a65c78..6501dd4a3ad3d47826e6422ac8dfcc6d7d441f88 100644
--- a/modules/mempool/CMakeLists.txt
+++ b/modules/mempool/CMakeLists.txt
@@ -6,6 +6,6 @@ file(GLOB DAP_CHAIN_MEMPOOL_HDR include/*.h)
 
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_MEMPOOL_SRC} ${DAP_CHAIN_MEMPOOL_HDR})
 
-target_link_libraries(${PROJECT_NAME} dap_http_server dap_client dap_chain_net dap_global_db dap_core dap_json_rpc)
+target_link_libraries(${PROJECT_NAME} dap_http_server dap_client dap_chain_net dap_global_db dap_core dap_json_rpc dap_chain_cs_blocks)
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/mempool/dap_chain_mempool.c b/modules/mempool/dap_chain_mempool.c
index e7807cd696e953a5b10bde866093c132c1b88734..3bf6fcba0106e4bba35506aafb306570d9e8c2e5 100644
--- a/modules/mempool/dap_chain_mempool.c
+++ b/modules/mempool/dap_chain_mempool.c
@@ -150,7 +150,7 @@ char *dap_chain_mempool_tx_create(dap_chain_t * a_chain, dap_enc_key_t *a_key_fr
     SUM_256_256(l_net_fee, a_value_fee, &l_total_fee);
     if (l_single_channel)
         SUM_256_256(l_value_need, l_total_fee, &l_value_need);
-    else {
+    else if (!IS_ZERO_256(l_total_fee)) {
         l_list_fee_out = dap_chain_ledger_get_list_tx_outs_with_val(a_chain->ledger, l_native_ticker,
                                                                     a_addr_from, l_total_fee, &l_fee_transfer);
         if (!l_list_fee_out) {
@@ -223,7 +223,7 @@ char *dap_chain_mempool_tx_create(dap_chain_t * a_chain, dap_enc_key_t *a_key_fr
         uint256_t l_value_back;
         SUBTRACT_256_256(l_value_transfer, a_value, &l_value_back);
         if(!IS_ZERO_256(l_value_back)) {
-            if(dap_chain_datum_tx_add_out_item(&l_tx, a_addr_from, l_value_back) != 1) {
+            if(dap_chain_datum_tx_add_out_ext_item(&l_tx, a_addr_from, l_value_back, a_token_ticker) != 1) {
                 dap_chain_datum_tx_delete(l_tx);
                 return NULL;
             }
diff --git a/modules/net/CMakeLists.txt b/modules/net/CMakeLists.txt
index f8cb5ff9f35f2ad94b556d525642d01ab4bcb45e..eb3f4321f931327793257660901dcf04dcc374d2 100644
--- a/modules/net/CMakeLists.txt
+++ b/modules/net/CMakeLists.txt
@@ -36,21 +36,13 @@ endif()
 
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_NET_SRCS} ${DAP_CHAIN_NET_HEADERS} ${IPUTILS_SRCS} ${IPUTILS_HEADERS})
 
-if(WIN32)
-  target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_client dap_io dap_notify_srv dap_cli_server dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_chain dap_chain_wallet dap_chain_net_srv dap_stream_ch_chain_voting
-                            dap_chain_mempool dap_global_db dap_chain_cs_none dap_chain_net_srv_stake_pos_delegate dap_chain_net_srv_xchange)
-endif()
-
+target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_client dap_io dap_notify_srv dap_cli_server dap_chain dap_chain_wallet
+                                        dap_chain_net_srv dap_chain_mempool dap_global_db dap_chain_net_srv_xchange dap_chain_cs_none
+                                        dap_stream_ch_chain_net dap_stream_ch_chain_voting)
 if(LINUX)
-    target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_io dap_notify_srv dap_cli_server dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_stream_ch_chain_voting dap_chain
-      dap_chain_wallet dap_chain_net_srv dap_chain_mempool dap_global_db dap_chain_cs_none dap_chain_net_srv_stake_pos_delegate dap_chain_net_srv_xchange
-      resolv )
-elseif(BSD)
-    target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_io dap_notify_srv dap_cli_server dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_stream_ch_chain_voting dap_chain
-      dap_chain_wallet dap_chain_net_srv dap_chain_mempool dap_global_db dap_chain_cs_none dap_chain_net_srv_stake_pos_delegate dap_chain_net_srv_xchange)
+    target_link_libraries(${PROJECT_NAME} resolv)
 endif()
 
-
 target_include_directories(${PROJECT_NAME} INTERFACE . )
 target_include_directories(${PROJECT_NAME} PUBLIC include)
 target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../dap-sdk/3rdparty/uthash/src)
diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c
index b169e5f033d9aa24455c606742471fe9592a903c..db32f159abced3df15295bc187906792556254fc 100644
--- a/modules/net/dap_chain_node_cli_cmd.c
+++ b/modules/net/dap_chain_node_cli_cmd.c
@@ -3685,7 +3685,7 @@ int com_token_decl(int a_argc, char ** a_argv, char ** a_str_reply)
     // Calc datum's hash
     dap_chain_hash_fast_t l_key_hash;
     dap_hash_fast(l_datum->data, l_datum->header.data_size, &l_key_hash);
-    char * l_key_str = dap_strcmp(l_hash_out_type, "hex") ?
+    char * l_key_str = !dap_strcmp(l_hash_out_type, "hex") ?
                 dap_chain_hash_fast_to_str_new(&l_key_hash) :
                 dap_enc_base58_encode_hash_to_str(&l_key_hash);
 
diff --git a/modules/net/srv/CMakeLists.txt b/modules/net/srv/CMakeLists.txt
index e1f948bc1fe33b75075a3f202613203ab60fd953..c3e5655091cc61a077dee09979a17606b12bb69d 100644
--- a/modules/net/srv/CMakeLists.txt
+++ b/modules/net/srv/CMakeLists.txt
@@ -7,11 +7,7 @@ add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_NET_SRV_SRCS} ${DAP_CHAIN_NET_SRV
 
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/libmaxminddb ${CMAKE_CURRENT_BINARY_DIR}/../../../3rdparty/libmaxminddb)
 
-set(NET_SRV_LIBS maxminddb dap_core dap_crypto dap_chain dap_chain_net dap_chain_wallet)
-if (CELLFRAME_MODULES MATCHES "modules-dynamic")
-    set(NET_SRV_LIBS ${NET_SRV_LIBS} dap_modules_dynamic_cdb)
-endif()
-target_link_libraries(${PROJECT_NAME} ${NET_SRV_LIBS})
+target_link_libraries(${PROJECT_NAME} maxminddb dap_core dap_crypto dap_chain dap_chain_net dap_chain_wallet dap_stream_ch_chain_net_srv)
 
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/net/srv/dap_chain_net_srv.c b/modules/net/srv/dap_chain_net_srv.c
index 122ea42a1f6fc8ef418f10b561cabb8c522f8c78..2756f1433d953f2befa23760a5a3a06a1dddfc5f 100644
--- a/modules/net/srv/dap_chain_net_srv.c
+++ b/modules/net/srv/dap_chain_net_srv.c
@@ -80,9 +80,9 @@ static int s_cli_net_srv(int argc, char **argv, char **a_str_reply);
 static void s_load(const char * a_path);
 static void s_load_all(void);
 
-static bool s_pay_verificator_callback(dap_ledger_t * a_ledger,dap_hash_fast_t *a_tx_out_hash, dap_chain_tx_out_cond_t *a_cond,
+static bool s_pay_verificator_callback(dap_ledger_t * a_ledger, dap_chain_tx_out_cond_t *a_cond,
                                        dap_chain_datum_tx_t *a_tx_in, bool a_owner);
-static bool s_fee_verificator_callback(dap_ledger_t * a_ledger, dap_hash_fast_t *a_tx_out_hash,dap_chain_tx_out_cond_t *a_cond,
+static bool s_fee_verificator_callback(dap_ledger_t * a_ledger, dap_chain_tx_out_cond_t *a_cond,
                                        dap_chain_datum_tx_t *a_tx_in, bool a_owner);
 
 /**
@@ -632,8 +632,7 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
  * @param a_owner
  * @return
  */
-static bool s_fee_verificator_callback(dap_ledger_t *a_ledger, UNUSED_ARG dap_hash_fast_t *a_tx_out_hash,
-                                       UNUSED_ARG dap_chain_tx_out_cond_t *a_cond,
+static bool s_fee_verificator_callback(dap_ledger_t *a_ledger, UNUSED_ARG dap_chain_tx_out_cond_t *a_cond,
                                        dap_chain_datum_tx_t *a_tx_in, UNUSED_ARG bool a_owner)
 {
     dap_chain_net_t *l_net = dap_chain_net_by_name(a_ledger->net_name);
@@ -643,7 +642,12 @@ static bool s_fee_verificator_callback(dap_ledger_t *a_ledger, UNUSED_ARG dap_ha
     DL_FOREACH(l_net->pub.chains, l_chain) {
         if (!l_chain->callback_block_find_by_tx_hash)
             continue;
-        const dap_chain_block_cache_t *l_block_cache = l_chain->callback_block_find_by_tx_hash(l_chain, a_tx_out_hash);
+        dap_chain_tx_in_cond_t *l_tx_in_cond = (dap_chain_tx_in_cond_t *)dap_chain_datum_tx_item_get(a_tx_in, 0, TX_ITEM_TYPE_IN_COND, 0);
+        if (!l_tx_in_cond)
+            return false;
+        if (dap_hash_fast_is_blank(&l_tx_in_cond->header.tx_prev_hash))
+            return false;
+        const dap_chain_block_cache_t *l_block_cache = l_chain->callback_block_find_by_tx_hash(l_chain, &l_tx_in_cond->header.tx_prev_hash);
         if (!l_block_cache)
             continue;
         dap_sign_t *l_sign_block = dap_chain_block_sign_get(l_block_cache->block, l_block_cache->block_size, 0);
@@ -667,11 +671,10 @@ static bool s_fee_verificator_callback(dap_ledger_t *a_ledger, UNUSED_ARG dap_ha
  * @param a_owner
  * @return
  */
-static bool s_pay_verificator_callback(dap_ledger_t * a_ledger,dap_hash_fast_t *a_tx_out_hash, dap_chain_tx_out_cond_t *a_cond,
+static bool s_pay_verificator_callback(dap_ledger_t * a_ledger, dap_chain_tx_out_cond_t *a_cond,
                                        dap_chain_datum_tx_t *a_tx_in, bool a_owner)
 {
     UNUSED(a_ledger);
-    UNUSED(a_tx_out_hash);
     if (!a_owner)
         return false;
     dap_chain_datum_tx_receipt_t *l_receipt = (dap_chain_datum_tx_receipt_t *)
diff --git a/modules/net/srv/include/dap_chain_net_srv.h b/modules/net/srv/include/dap_chain_net_srv.h
index fe6d85e9ccb84e756d37e03fd7ce728306ad67ed..f7737949022b50f0789b3bf7934dcd03075e2e86 100755
--- a/modules/net/srv/include/dap_chain_net_srv.h
+++ b/modules/net/srv/include/dap_chain_net_srv.h
@@ -342,6 +342,15 @@ DAP_STATIC_INLINE bool dap_chain_net_srv_uid_compare(dap_chain_net_srv_uid_t a,
 #endif
 }
 
+DAP_STATIC_INLINE bool dap_chain_net_srv_uid_compare_scalar(const dap_chain_net_srv_uid_t a_uid1, const uint64_t a_id)
+{
+#if DAP_CHAIN_NET_SRV_UID_SIZE == 8
+    return a_uid1.uint64 == a_id;
+#else
+    return compare128(a_uid1.uint128, GET_128_FROM_64(a_id));
+#endif
+}
+
 DAP_STATIC_INLINE const char *dap_chain_net_srv_fee_type_to_str(dap_chain_net_srv_fee_type_t a_fee_type) {
     switch (a_fee_type) {
         case SERVICE_FEE_OWN_FIXED: return "SERVICE_FEE_OWN_FIXED";
diff --git a/modules/service/stake_lock/CMakeLists.txt b/modules/service/stake/CMakeLists.txt
similarity index 53%
rename from modules/service/stake_lock/CMakeLists.txt
rename to modules/service/stake/CMakeLists.txt
index 72e269fc3e7dedcc1518981fbca6492a0a4b3ec8..acc98b08bfb058754935a8d3731f185de04ca73c 100644
--- a/modules/service/stake_lock/CMakeLists.txt
+++ b/modules/service/stake/CMakeLists.txt
@@ -1,11 +1,11 @@
 cmake_minimum_required(VERSION 3.10)
-project (dap_chain_net_srv_stake_lock)
+project (dap_chain_net_srv_stake)
 
-file(GLOB DAP_SRV_STAKE_LOCK_SRCS *.c)
+file(GLOB DAP_SRV_STAKE_SRCS *.c)
 
-file(GLOB DAP_SRV_STAKE_LOCK_HEADERS include/*.h)
+file(GLOB DAP_SRV_STAKE_HEADERS include/*.h)
 
-add_library(${PROJECT_NAME} STATIC ${DAP_SRV_STAKE_LOCK_SRCS} ${DAP_SRV_STAKE_LOCK_HEADERS})
+add_library(${PROJECT_NAME} STATIC ${DAP_SRV_STAKE_SRCS} ${DAP_SRV_STAKE_HEADERS})
 
 target_include_directories(${PROJECT_NAME} INTERFACE .)
 target_include_directories(${PROJECT_NAME} PUBLIC include)
diff --git a/modules/service/stake_lock/dap_chain_net_srv_stake_lock.c b/modules/service/stake/dap_chain_net_srv_stake_lock.c
similarity index 53%
rename from modules/service/stake_lock/dap_chain_net_srv_stake_lock.c
rename to modules/service/stake/dap_chain_net_srv_stake_lock.c
index 15838d6281754c4eccd9e1c993781c3edcc9739e..8122567af7cbf0baa92a784cfc8e38d0fbe64264 100644
--- a/modules/service/stake_lock/dap_chain_net_srv_stake_lock.c
+++ b/modules/service/stake/dap_chain_net_srv_stake_lock.c
@@ -61,7 +61,7 @@ enum error_code {
     NO_TX_ERROR					= 22,
     CREATE_LOCK_TX_ERROR		= 23,
     TX_TICKER_ERROR				= 24,
-    NO_DELEGATE_TOKEN_ERROR		= 25,
+    NO_DELEGATED_TOKEN_ERROR	= 25,
     NO_VALID_SUBTYPE_ERROR		= 26,
     IS_USED_OUT_ERROR			= 27,
     OWNER_KEY_ERROR				= 28,
@@ -79,9 +79,6 @@ enum error_code {
     HASH_TYPE_ARG_ERROR         = 41,
     FEE_ARG_ERROR               = 42,
     FEE_FORMAT_ERROR            = 43,
-    FEE_ADD_NTW_ERROR           = 44,
-    FEE_ADD_VAL_ERROR           = 45,
-    COIN_BACK_ERROR             = 46
 };
 
 typedef struct dap_chain_ledger_token_emission_for_stake_lock_item {
@@ -95,33 +92,38 @@ typedef struct dap_chain_ledger_token_emission_for_stake_lock_item {
 #define MONTH_INDEX	8
 #define YEAR_INDEX	12
 
-static int												s_cli_stake_lock(int a_argc, char **a_argv, char **a_str_reply);
-static char                                             *dap_chain_mempool_base_tx_for_stake_lock_create(dap_chain_t *a_chain, dap_chain_hash_fast_t *a_emission_hash,
-                                                                              dap_chain_id_t a_emission_chain_id, uint256_t a_emission_value, const char *a_ticker,
-                                                                              dap_chain_addr_t *a_addr_to, dap_enc_key_t *a_key_from, const char *a_hash_out_type, uint256_t a_value_fee,
-                                                                              uint256_t a_value_change, uint32_t a_tx_out_prev_idx);
+static int s_cli_stake_lock(int a_argc, char **a_argv, char **a_str_reply);
+
+// Create stake lock datum
+static dap_chain_datum_t *s_stake_lock_datum_create(dap_chain_net_t *a_net, dap_enc_key_t *a_key_from,
+                                                    const char *a_main_ticker, uint256_t a_value,
+                                                    uint256_t a_value_fee,
+                                                    dap_time_t a_time_staking, uint256_t a_reinvest_percent,
+                                                    const char *a_delegated_ticker_str, uint256_t a_delegated_value);
+// Create unlock datum
+dap_chain_datum_t *s_stake_unlock_datum_create(dap_chain_net_t *a_net, dap_enc_key_t *a_key_from,
+                                               dap_hash_fast_t *a_stake_tx_hash, uint32_t a_prev_cond_idx,
+                                               const char *a_main_ticker, uint256_t a_value,
+                                               uint256_t a_value_fee,
+                                               const char *a_delegated_ticker_str, uint256_t a_delegated_value);
 // Callbacks
-static void												s_callback_decree (dap_chain_net_srv_t * a_srv, dap_chain_net_t *a_net, dap_chain_t * a_chain,
-                                                                              dap_chain_datum_decree_t * a_decree, size_t a_decree_size);
-static void s_stake_lock_callback_verificator_added(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_t *a_tx_item);
-static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_hash_fast_t *a_tx_out_hash, dap_chain_tx_out_cond_t *a_cond,
-                                   dap_chain_datum_tx_t *a_tx_in, bool a_owner);
+static void s_stake_lock_callback_updater(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_t *a_prev_out_item);
+static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_chain_tx_out_cond_t *a_cond, dap_chain_datum_tx_t *a_tx_in, bool a_owner);
 /**
  * @brief dap_chain_net_srv_external_stake_init
  * @return
  */
 int dap_chain_net_srv_stake_lock_init()
 {
-    dap_chain_ledger_verificator_add(DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK, s_stake_lock_callback_verificator, s_stake_lock_callback_verificator_added);
+    dap_chain_ledger_verificator_add(DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK, s_stake_lock_callback_verificator, s_stake_lock_callback_updater);
     dap_cli_server_cmd_add("stake_lock", s_cli_stake_lock, "Stake lock service commands",
        "Command:"
                 "stake_lock hold\n"
                 "Required parameters:\n"
                 "-net <net name> -wallet <wallet name> -time_staking <in YYMMDD>\n"
-                "-token <ticker> -coins <value> -fee <value>\n"
+                "-token <ticker> -value <value> -fee <value>\n"
                 "Optional parameters:\n"
-                "-cert <name> -chain <chain> -reinvest <percentage from 1 to 100>\n"
-                "-no_base_tx(flag to create a transaction without base transaction)\n"
+                "-chain <chain> -reinvest <percentage from 1 to 100>\n"
                 "Command:"
                 "stake_lock take\n"
                 "Required parameters:\n"
@@ -129,14 +131,7 @@ int dap_chain_net_srv_stake_lock_init()
                 "Optional parameters:\n"
                 "-chain <chain>\n"
     );
-
-    s_debug_more = dap_config_get_item_bool_default(g_config,"ledger","debug_more",false);
-
-    dap_chain_net_srv_uid_t l_uid = { .uint64 = DAP_CHAIN_NET_SRV_STAKE_LOCK_ID };
-    dap_chain_net_srv_callbacks_t l_srv_callbacks = {};
-    l_srv_callbacks.decree = s_callback_decree;
-
-    dap_chain_net_srv_t *l_srv = dap_chain_net_srv_add(l_uid, "stake_lock", &l_srv_callbacks);
+    s_debug_more = dap_config_get_item_bool_default(g_config, "ledger", "debug_more", false);
     return 0;
 }
 
@@ -148,41 +143,6 @@ void dap_chain_net_srv_stake_lock_deinit()
 
 }
 
-/**
- * @brief s_callback_decree
- * @param a_srv
- * @param a_net
- * @param a_chain
- * @param a_decree
- * @param a_decree_size
- */
-static void s_callback_decree (dap_chain_net_srv_t * a_srv, dap_chain_net_t *a_net, dap_chain_t * a_chain, dap_chain_datum_decree_t * a_decree, size_t a_decree_size)
-{
-
-}
-
-/**
- * @brief s_receipt_create
- * @param hash_burning_transaction
- * @param token
- * @param datoshi_burned
- * @return
- */
-static dap_chain_datum_tx_receipt_t *s_receipt_create(dap_hash_fast_t *hash_burning_transaction, const char *token, uint256_t datoshi_burned)
-{
-    uint32_t l_ext_size	= sizeof(dap_hash_fast_t) + dap_strlen(token) + 1;
-    uint8_t *l_ext		= DAP_NEW_STACK_SIZE(uint8_t, l_ext_size);
-
-    memcpy(l_ext, hash_burning_transaction, sizeof(dap_hash_fast_t));
-    strcpy((char *)&l_ext[sizeof(dap_hash_fast_t)], token);
-
-    dap_chain_net_srv_price_unit_uid_t l_unit	= { .uint32 = SERV_UNIT_UNDEFINED};
-    dap_chain_net_srv_uid_t l_uid				= { .uint64 = DAP_CHAIN_NET_SRV_STAKE_LOCK_ID };
-    dap_chain_datum_tx_receipt_t *l_receipt		= dap_chain_datum_tx_receipt_create(l_uid, l_unit, 0, datoshi_burned,
-                                                                                 l_ext, l_ext_size);
-    return l_receipt;
-}
-
 /**
  * @brief s_cli_hold
  * @param a_argc
@@ -193,30 +153,27 @@ static dap_chain_datum_tx_receipt_t *s_receipt_create(dap_hash_fast_t *hash_burn
  */
 static enum error_code s_cli_hold(int a_argc, char **a_argv, int a_arg_index, dap_string_t *output_line)
 {
-    const char *l_net_str, *l_ticker_str, *l_coins_str, *l_wallet_str, *l_cert_str, *l_chain_str, /* *l_chain_emission_str,*/ *l_time_staking_str, *l_reinvest_percent_str, *l_value_fee_str;
-    l_net_str = l_ticker_str = l_coins_str = l_wallet_str = l_cert_str = l_chain_str = /*l_chain_emission_str =*/ l_time_staking_str = l_reinvest_percent_str = l_value_fee_str = NULL;
+    const char *l_net_str = NULL, *l_ticker_str = NULL, *l_coins_str = NULL,
+            *l_wallet_str = NULL, *l_cert_str = NULL, *l_chain_str = NULL,
+            *l_time_staking_str = NULL, *l_reinvest_percent_str = NULL, *l_value_fee_str = NULL;
+
     const char *l_wallets_path								=	dap_chain_wallet_get_path(g_config);
-    char 	delegate_ticker_str[DAP_CHAIN_TICKER_SIZE_MAX] 	=	{};
+    char 	l_delegated_ticker_str[DAP_CHAIN_TICKER_SIZE_MAX] 	=	{};
     dap_chain_net_t						*l_net				=	NULL;
     dap_chain_t							*l_chain			=	NULL;
-    dap_hash_fast_t                     l_tx_cond_hash;
-    dap_cert_t							*l_cert				=	NULL;
-    dap_pkey_t							*l_key_cond			=	NULL;
-    dap_chain_net_srv_uid_t				l_uid				=	{ .uint64 = DAP_CHAIN_NET_SRV_STAKE_LOCK_ID };
     dap_time_t              			l_time_staking		=	0;
     uint256_t						    l_reinvest_percent	=	{};
     uint256_t							l_value_delegated	=	{};
     uint256_t                           l_value_fee     	=	{};
-    bool								create_base_tx		=	true;
     uint256_t 							l_value;
     dap_ledger_t						*l_ledger;
     char								*l_hash_str;
     dap_enc_key_t						*l_key_from;
     dap_chain_wallet_t					*l_wallet;
     dap_chain_addr_t					*l_addr_holder;
-    dap_chain_datum_token_t 			*delegate_token;
+    dap_chain_datum_token_t 			*l_delegated_token;
     dap_tsd_t							*l_tsd;
-    dap_chain_datum_token_tsd_delegate_from_stake_lock_t l_tsd_section;
+    dap_chain_datum_token_tsd_delegate_from_stake_lock_t *l_tsd_section;
 
     dap_string_append_printf(output_line, "---> HOLD <---\n");
 
@@ -248,48 +205,37 @@ static enum error_code s_cli_hold(int a_argc, char **a_argv, int a_arg_index, da
         return TOKEN_ERROR;
     }
 
-    if (dap_cli_server_cmd_check_option(a_argv, a_arg_index, a_argc, "-no_base_tx") >= 0)
-        create_base_tx = false;
+    if ((!dap_cli_server_cmd_find_option_val(a_argv, a_arg_index, a_argc, "-coins", &l_coins_str) || NULL == l_coins_str) &&
+            (!dap_cli_server_cmd_find_option_val(a_argv, a_arg_index, a_argc, "-value", &l_coins_str) || NULL == l_coins_str))
+        return COINS_ARG_ERROR;
 
-    if (create_base_tx) {
-        dap_chain_datum_token_get_delegated_ticker(delegate_ticker_str, l_ticker_str);
+    if (IS_ZERO_256( (l_value = dap_chain_balance_scan(l_coins_str)) ))
+        return COINS_FORMAT_ERROR;
 
-        if (NULL == (delegate_token = dap_chain_ledger_token_ticker_check(l_ledger, delegate_ticker_str))
-        ||	(delegate_token->subtype != DAP_CHAIN_DATUM_TOKEN_SUBTYPE_NATIVE)
-        ||	!delegate_token->header_native_decl.tsd_total_size
-        ||	NULL == (l_tsd = dap_tsd_find(delegate_token->data_n_tsd, delegate_token->header_native_decl.tsd_total_size, DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK))) {
-            dap_string_append_printf(output_line, "'%s'", delegate_ticker_str);
-            return NO_DELEGATE_TOKEN_ERROR;
-        }
+    dap_chain_datum_token_get_delegated_ticker(l_delegated_ticker_str, l_ticker_str);
 
-        l_tsd_section = dap_tsd_get_scalar(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
-        if (strcmp(l_ticker_str, (char *)l_tsd_section.ticker_token_from))
-            return TOKEN_ERROR;
+    if (NULL == (l_delegated_token = dap_chain_ledger_token_ticker_check(l_ledger, l_delegated_ticker_str))
+    ||	(l_delegated_token->subtype != DAP_CHAIN_DATUM_TOKEN_SUBTYPE_NATIVE)
+    ||	!l_delegated_token->header_native_decl.tsd_total_size
+    ||	NULL == (l_tsd = dap_tsd_find(l_delegated_token->data_n_tsd, l_delegated_token->header_native_decl.tsd_total_size,
+                                      DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK))) {
+        dap_string_append_printf(output_line, "'%s'", l_delegated_ticker_str);
+        return NO_DELEGATED_TOKEN_ERROR;
     }
 
-    if (!dap_cli_server_cmd_find_option_val(a_argv, a_arg_index, a_argc, "-coins", &l_coins_str)
-    ||	NULL == l_coins_str)
-        return COINS_ARG_ERROR;
+    l_tsd_section = dap_tsd_get_object(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
+    if (strcmp(l_ticker_str, (char *)l_tsd_section->ticker_token_from))
+        return TOKEN_ERROR;
 
-    if (IS_ZERO_256( (l_value = dap_chain_balance_scan(l_coins_str)) ))
-        return COINS_FORMAT_ERROR;
+    if (IS_ZERO_256(l_tsd_section->emission_rate))
+        return TOKEN_ERROR;
 
-    if (create_base_tx
-    &&	!IS_ZERO_256(l_tsd_section.emission_rate)) {
-        MULT_256_COIN(l_value, l_tsd_section.emission_rate, &l_value_delegated);
-        if (IS_ZERO_256(l_value_delegated))
-            return COINS_FORMAT_ERROR;
-    } else
-        l_value_delegated = l_value;
+    MULT_256_COIN(l_value, l_tsd_section->emission_rate, &l_value_delegated);
+    if (IS_ZERO_256(l_value_delegated))
+        return COINS_FORMAT_ERROR;
 
     dap_cli_server_cmd_find_option_val(a_argv, a_arg_index, a_argc, "-cert", &l_cert_str);
 
-    if (NULL != l_cert_str
-    &&	NULL == (l_cert = dap_cert_find_by_name(l_cert_str))) {
-        dap_string_append_printf(output_line, "'%s'", l_cert_str);
-        return CERT_LOAD_ERROR;
-    }
-
     if (dap_cli_server_cmd_find_option_val(a_argv, a_arg_index, a_argc, "-chain", &l_chain_str)
     &&	l_chain_str)
         l_chain = dap_chain_net_get_chain_by_name(l_net, l_chain_str);
@@ -317,14 +263,13 @@ static enum error_code s_cli_hold(int a_argc, char **a_argv, int a_arg_index, da
     if (dap_strlen(l_time_staking_str) != 6)
         return TIME_ERROR;
 
-    char l_time_staking_day_str[3] = {l_time_staking_str[4], l_time_staking_str[5], 0};
-    int l_time_staking_day = atoi(l_time_staking_day_str);
     char l_time_staking_month_str[3] = {l_time_staking_str[2], l_time_staking_str[3], 0};
     int l_time_staking_month = atoi(l_time_staking_month_str);
-
     if (l_time_staking_month < 1 || l_time_staking_month > 12)
         return TIME_ERROR;
 
+    char l_time_staking_day_str[3] = {l_time_staking_str[4], l_time_staking_str[5], 0};
+    int l_time_staking_day = atoi(l_time_staking_day_str);
     if (l_time_staking_day < 1 || l_time_staking_day > 31)
         return TIME_ERROR;
 
@@ -351,8 +296,6 @@ static enum error_code s_cli_hold(int a_argc, char **a_argv, int a_arg_index, da
         }
     }
 
-/*________________________________________________________________________________________________________________*/
-
     if(NULL == (l_wallet = dap_chain_wallet_open(l_wallet_str, l_wallets_path))) {
         dap_string_append_printf(output_line, "'%s'", l_wallet_str);
         return WALLET_OPEN_ERROR;
@@ -371,53 +314,24 @@ static enum error_code s_cli_hold(int a_argc, char **a_argv, int a_arg_index, da
 
     l_key_from = dap_chain_wallet_get_key(l_wallet, 0);
 
-    if (NULL != l_cert
-    &&	NULL == (l_key_cond = dap_pkey_from_enc_key(l_cert->enc_key))) {
-        dap_chain_wallet_close(l_wallet);
-        DAP_DEL_Z(l_addr_holder);
-        dap_string_append_printf(output_line, "'%s'", l_cert_str);
-        return CERT_KEY_ERROR;
-    }
-    uint256_t l_value_change = {};
-    uint32_t l_tx_out_prev_idx = 0;
-
     // Make transfer transaction
-    dap_chain_datum_t *l_datum = dap_chain_net_srv_stake_lock_datum_create(l_net, l_key_from, l_key_cond,
-                                                                           l_ticker_str, l_value, l_value_fee, l_uid,
-                                                                           l_time_staking, l_reinvest_percent, create_base_tx,
-                                                                           &l_value_change, &l_tx_out_prev_idx);
-    DAP_DEL_Z(l_key_cond);
-    if (create_base_tx)
-        dap_hash_fast(l_datum->data, l_datum->header.data_size, &l_tx_cond_hash);
+    dap_chain_datum_t *l_datum = s_stake_lock_datum_create(l_net, l_key_from,
+                                                           l_ticker_str, l_value, l_value_fee,
+                                                           l_time_staking, l_reinvest_percent,
+                                                           l_delegated_ticker_str, l_value_delegated);
+    dap_chain_wallet_close(l_wallet);
+
     l_hash_str = dap_chain_mempool_datum_add(l_datum, l_chain, l_hash_out_type);
     DAP_DEL_Z(l_datum);
 
     if (l_hash_str)
-        dap_string_append_printf(output_line, "TX STAKE LOCK CREATED\nSuccessfully hash=%s\nSave to take!\n", l_hash_str);
+        dap_string_append_printf(output_line, "TX STAKE LOCK CREATED\nSuccessfully hash = %s\nSave to take!\n", l_hash_str);
     else {
-        dap_chain_wallet_close(l_wallet);
         DAP_DEL_Z(l_addr_holder);
         return CREATE_LOCK_TX_ERROR;
     }
 
     DAP_DEL_Z(l_hash_str);
-
-    if (create_base_tx)
-        l_hash_str = dap_chain_mempool_base_tx_for_stake_lock_create(l_chain, &l_tx_cond_hash, l_chain->id,
-                                                      l_value_delegated, delegate_ticker_str, l_addr_holder,
-                                                      l_key_from, l_hash_out_type, l_value_fee,l_value_change,l_tx_out_prev_idx);
-
-    dap_chain_wallet_close(l_wallet);
-
-    if (create_base_tx) {
-        if (l_hash_str)
-            dap_string_append_printf(output_line, "BASE_TX_DATUM_HASH=%s\n", l_hash_str);
-        else {
-            DAP_DEL_Z(l_addr_holder);
-            return BASE_TX_CREATE_ERROR;
-        }
-    }
-
     DAP_DEL_Z(l_addr_holder);
     DAP_DEL_Z(l_hash_str);
 
@@ -429,33 +343,23 @@ static enum error_code s_cli_take(int a_argc, char **a_argv, int a_arg_index, da
     const char *l_net_str, *l_ticker_str, *l_wallet_str, *l_tx_str, *l_tx_burning_str, *l_chain_str, *l_value_fee_str;
     l_net_str = l_ticker_str = l_wallet_str = l_tx_str = l_tx_burning_str = l_chain_str = NULL;
     dap_chain_net_t						*l_net				=	NULL;
-    dap_chain_datum_t					*l_datum_burning_tx	=	NULL;
     const char							*l_wallets_path		=	dap_chain_wallet_get_path(g_config);
-    char 	delegate_ticker_str[DAP_CHAIN_TICKER_SIZE_MAX] 	=	{};
+    char l_delegated_ticker_str[DAP_CHAIN_TICKER_SIZE_MAX] 	=	{};
     int									l_prev_cond_idx		=	0;
     uint256_t							l_value_delegated	= 	{};
     uint256_t                           l_value_fee     	=	{};
-    uint256_t                           l_net_fee           =   {};
-    uint256_t                           l_value_transfer    =   {};
-    uint256_t                           l_value_need        =   {};
     char 								*l_datum_hash_str;
     dap_ledger_t						*l_ledger;
     dap_chain_wallet_t					*l_wallet;
     dap_hash_fast_t						l_tx_hash;
-    dap_hash_fast_t 					l_tx_burning_hash;
-    dap_chain_datum_tx_receipt_t		*l_receipt;
-    dap_chain_datum_tx_t				*l_tx;
     dap_chain_datum_tx_t				*l_cond_tx;
     dap_chain_tx_out_cond_t				*l_tx_out_cond;
-    dap_chain_addr_t					*l_owner_addr;
-    dap_chain_addr_t                     l_addr_fee         = {};
     dap_enc_key_t						*l_owner_key;
-    size_t								l_tx_size;
     dap_chain_datum_t					*l_datum;
     dap_chain_t							*l_chain;
-    dap_chain_datum_token_t				*delegate_token;
+    dap_chain_datum_token_t				*l_delegated_token;
     dap_tsd_t							*l_tsd;
-    dap_chain_datum_token_tsd_delegate_from_stake_lock_t l_tsd_section;
+    dap_chain_datum_token_tsd_delegate_from_stake_lock_t *l_tsd_section;
 
     dap_string_append_printf(output_line, "---> TAKE <---\n");
 
@@ -508,29 +412,31 @@ static enum error_code s_cli_take(int a_argc, char **a_argv, int a_arg_index, da
     if (NULL == (l_ticker_str = dap_chain_ledger_tx_get_token_ticker_by_hash(l_ledger, &l_tx_hash)))
         return TX_TICKER_ERROR;
 
-    if (l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) {
-        dap_chain_datum_token_get_delegated_ticker(delegate_ticker_str, l_ticker_str);
+    if (l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX ||
+            l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_EMIT) {
+
+        dap_chain_datum_token_get_delegated_ticker(l_delegated_ticker_str, l_ticker_str);
 
-        if (NULL == (delegate_token = dap_chain_ledger_token_ticker_check(l_ledger, delegate_ticker_str))
-            ||	(delegate_token->subtype != DAP_CHAIN_DATUM_TOKEN_SUBTYPE_NATIVE)
-            ||	!delegate_token->header_native_decl.tsd_total_size
-            ||	NULL == (l_tsd = dap_tsd_find(delegate_token->data_n_tsd, delegate_token->header_native_decl.tsd_total_size, DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK))) {
-            dap_string_append_printf(output_line, "'%s'", delegate_ticker_str);
-            return NO_DELEGATE_TOKEN_ERROR;
+        if (NULL == (l_delegated_token = dap_chain_ledger_token_ticker_check(l_ledger, l_delegated_ticker_str))
+            ||	(l_delegated_token->subtype != DAP_CHAIN_DATUM_TOKEN_SUBTYPE_NATIVE)
+            ||	!l_delegated_token->header_native_decl.tsd_total_size
+            ||	NULL == (l_tsd = dap_tsd_find(l_delegated_token->data_n_tsd,
+                                              l_delegated_token->header_native_decl.tsd_total_size,
+                                              DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK))) {
+            dap_string_append_printf(output_line, "'%s'", l_delegated_ticker_str);
+            return NO_DELEGATED_TOKEN_ERROR;
         }
 
-        l_tsd_section = dap_tsd_get_scalar(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
-        if (strcmp(l_ticker_str, (char *)l_tsd_section.ticker_token_from))
+        l_tsd_section = dap_tsd_get_object(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
+        if (strcmp(l_ticker_str, (char *)l_tsd_section->ticker_token_from))
             return TOKEN_ERROR;
-    }
 
-    if ((l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX)
-    &&	!IS_ZERO_256(l_tsd_section.emission_rate)) {
-        MULT_256_COIN(l_tx_out_cond->header.value, l_tsd_section.emission_rate, &l_value_delegated);
-        if (IS_ZERO_256(l_value_delegated))
-            return COINS_FORMAT_ERROR;
-    } else
-        l_value_delegated = l_tx_out_cond->header.value;
+        if (!IS_ZERO_256(l_tsd_section->emission_rate)) {
+            MULT_256_COIN(l_tx_out_cond->header.value, l_tsd_section->emission_rate, &l_value_delegated);
+            if (IS_ZERO_256(l_value_delegated))
+                return COINS_FORMAT_ERROR;
+        }
+    }
 
     if (!dap_cli_server_cmd_find_option_val(a_argv, a_arg_index, a_argc, "-wallet", &l_wallet_str)
     ||	NULL == l_wallet_str)
@@ -564,152 +470,21 @@ static enum error_code s_cli_take(int a_argc, char **a_argv, int a_arg_index, da
         return OWNER_KEY_ERROR;
     }
 
-    if (NULL == (l_owner_addr = (dap_chain_addr_t *)dap_chain_wallet_get_addr(l_wallet, l_net->pub.id))) {
-        dap_chain_wallet_close(l_wallet);
-        return WALLET_ADDR_ERROR;
-    }
-
     if (l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_BY_TIME &&
             l_tx_out_cond->subtype.srv_stake_lock.time_unlock > dap_time_now()) {
         dap_chain_wallet_close(l_wallet);
-        DAP_DEL_Z(l_owner_addr);
         return NOT_ENOUGH_TIME;
     }
-/*________________________________________________________________________________________________________________*/
 
-
-    bool l_net_fee_used = dap_chain_net_tx_get_fee(l_chain->net_id, &l_net_fee, &l_addr_fee);
-    if(l_net_fee_used)
-        SUM_256_256(l_value_need,l_net_fee,&l_value_need);
-    SUM_256_256(l_value_need,l_value_fee,&l_value_need);
-
-
-    //add tx
-    if (NULL == (l_tx = dap_chain_datum_tx_create())) {//malloc
-        dap_chain_wallet_close(l_wallet);
-        DAP_DEL_Z(l_owner_addr);
-        return CREATE_TX_ERROR;
-    }
-
-    dap_chain_datum_tx_add_in_cond_item(&l_tx, &l_tx_hash, l_prev_cond_idx, 0);
-
-    dap_chain_datum_tx_add_out_item(&l_tx, l_owner_addr, l_tx_out_cond->header.value);
-
-    uint256_t l_value_back = {},l_value_pack = {};
-    // Network fee
-    if (l_net_fee_used) {
-        if (dap_chain_datum_tx_add_out_item(&l_tx, &l_addr_fee, l_net_fee) != 1) {
-            dap_chain_datum_tx_delete(l_tx);
-            return FEE_ADD_NTW_ERROR;
-        }
-        SUM_256_256(l_value_pack, l_net_fee, &l_value_pack);
-    }
-    // Validator's fee
-    if (!IS_ZERO_256(l_value_fee)) {
-        if (dap_chain_datum_tx_add_fee_item(&l_tx, l_value_fee) != 1) {
-            dap_chain_datum_tx_delete(l_tx);
-            return FEE_ADD_VAL_ERROR;
-        }
-        SUM_256_256(l_value_pack, l_value_fee, &l_value_pack);
-    }
-
-    //add burning tx
-    if (l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) {
-        uint32_t l_tx_out_prev_idx = 0;
-        uint256_t l_value_change = {};
-        if (NULL == (l_datum_burning_tx = dap_chain_burning_tx_create(l_chain, l_owner_key, l_owner_addr, &c_dap_chain_addr_blank,
-                                                                  delegate_ticker_str, l_value_delegated, l_value_fee,&l_tx_out_prev_idx,&l_value_change))) {//malloc
-            dap_chain_wallet_close(l_wallet);
-            DAP_DEL_Z(l_owner_addr);
-            dap_chain_datum_tx_delete(l_tx);
-            return CREATE_BURNING_TX_ERROR;
-        }
-
-        //get tx hash
-        dap_hash_fast(l_datum_burning_tx->data, l_datum_burning_tx->header.data_size, &l_tx_burning_hash);
-
-        if (NULL == (l_receipt = s_receipt_create(&l_tx_burning_hash, delegate_ticker_str, l_value_delegated))) {
-            dap_chain_wallet_close(l_wallet);
-            DAP_DEL_Z(l_owner_addr);
-            dap_chain_datum_tx_delete(l_tx);
-            DAP_DEL_Z(l_datum_burning_tx);
-            return CREATE_RECEIPT_ERROR;
-        }
-
-        dap_chain_datum_tx_add_item(&l_tx, (byte_t *)l_receipt);
-
-        dap_chain_tx_in_t *l_in = dap_chain_datum_tx_item_in_create(&l_tx_burning_hash, l_tx_out_prev_idx-1);
-        dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_in);
-        l_value_transfer = l_value_change;
-    }
-    else
-    {
-            dap_list_t *l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(l_ledger, l_ticker_str,
-                                                                                     l_owner_addr, l_value_need, &l_value_transfer);
-            if(!l_list_used_out) {
-                log_it( L_ERROR, "Nothing to transfer (not enough funds)");
-                return -1;
-            }
-
-            {
-                uint256_t l_value_to_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_used_out);
-                assert(EQUAL_256(l_value_to_items, l_value_transfer));
-                dap_list_free_full(l_list_used_out, free);
-            }
-    }
-    // coin back
-
-    SUBTRACT_256_256(l_value_transfer, l_value_pack, &l_value_back);
-    //SUM_256_256(l_value_back, l_tx_out_cond->header.value, &l_value_back);
-    if (!IS_ZERO_256(l_value_back)) {
-        if(dap_chain_datum_tx_add_out_item(&l_tx, l_owner_addr, l_value_back) != 1)
-        {
-            dap_chain_datum_tx_delete(l_tx);
-            return COIN_BACK_ERROR;
-        }
-    }
-
-    if(dap_chain_datum_tx_add_sign_item(&l_tx, l_owner_key) != 1) {
-        dap_chain_wallet_close(l_wallet);
-        DAP_DEL_Z(l_owner_addr);
-        dap_chain_datum_tx_delete(l_tx);
-        DAP_DEL_Z(l_datum_burning_tx);
-        log_it(L_ERROR, "Can't add sign output");
-        return SIGN_ERROR;
-    }
-
-    dap_chain_wallet_close(l_wallet);
-    DAP_DEL_Z(l_owner_addr);
-
-    // Put the transaction to mempool or directly to chains
-    l_tx_size = dap_chain_datum_tx_get_size(l_tx);
-    if (NULL == (l_datum = dap_chain_datum_create(DAP_CHAIN_DATUM_TX, l_tx, l_tx_size))) {
-        dap_chain_datum_tx_delete(l_tx);
-        DAP_DEL_Z(l_datum_burning_tx);
-        return CREATE_DATUM_ERROR;
-    }
-
-    dap_chain_datum_tx_delete(l_tx);
-
-    if (l_tx_out_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) {
-        if (NULL == (l_datum_hash_str = dap_chain_mempool_datum_add(l_datum_burning_tx, l_chain, l_hash_out_type))) {
-            DAP_DEL_Z(l_datum_burning_tx);
-            DAP_DEL_Z(l_datum);
-            return ADD_DATUM_BURNING_TX_ERROR;
-        }
-
-        dap_string_append_printf(output_line, "BURNING_TX_DATUM_HASH=%s\n", l_datum_hash_str);
-        DAP_DEL_Z(l_datum_burning_tx);
-        DAP_DEL_Z(l_datum_hash_str);
-    }
+    l_datum = s_stake_unlock_datum_create(l_net, l_owner_key, &l_tx_hash, l_prev_cond_idx,
+                                          l_ticker_str, l_tx_out_cond->header.value, l_value_fee,
+                                          l_delegated_ticker_str, l_value_delegated);
 
     // Processing will be made according to autoprocess policy
-    if (NULL == (l_datum_hash_str = dap_chain_mempool_datum_add(l_datum, l_chain, l_hash_out_type))) {
-        DAP_DEL_Z(l_datum);
+    if (NULL == (l_datum_hash_str = dap_chain_mempool_datum_add(l_datum, l_chain, l_hash_out_type)))
         return ADD_DATUM_TX_TAKE_ERROR;
-    }
 
-    dap_string_append_printf(output_line, "TAKE_TX_DATUM_HASH=%s\n", l_datum_hash_str);
+    dap_string_append_printf(output_line, "TAKE_TX_DATUM_HASH = %s\n", l_datum_hash_str);
 
     DAP_DEL_Z(l_datum_hash_str);
     DAP_DEL_Z(l_datum);
@@ -826,7 +601,7 @@ static void s_error_handler(enum error_code errorCode, dap_string_t *output_line
             dap_string_append_printf(output_line, "ticker not found");
             } break;
 
-        case NO_DELEGATE_TOKEN_ERROR: {
+        case NO_DELEGATED_TOKEN_ERROR: {
             dap_string_append_printf(output_line, " ^^^ delegated token not found");
             } break;
 
@@ -894,18 +669,6 @@ static void s_error_handler(enum error_code errorCode, dap_string_t *output_line
             dap_string_append_printf(output_line, "Format -fee <256 bit integer>");
         } break;
 
-        case FEE_ADD_NTW_ERROR: {
-            dap_string_append_printf(output_line, "Cant add network fee output");
-        } break;
-
-        case FEE_ADD_VAL_ERROR: {
-            dap_string_append_printf(output_line, "Cant add validator's fee output");
-        } break;
-
-        case COIN_BACK_ERROR: {
-            dap_string_append_printf(output_line, "Cant add coin back output");
-        } break;
-
         default: {
             dap_string_append_printf(output_line, "STAKE_LOCK: Unrecognized error");
             } break;
@@ -1108,21 +871,18 @@ static char *s_update_date_by_using_month_count(char *time, uint8_t month_count)
  * @param a_owner
  * @return
  */
-static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_hash_fast_t *a_tx_out_hash, dap_chain_tx_out_cond_t *a_cond,
-                                   dap_chain_datum_tx_t *a_tx_in, bool a_owner)
+static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_chain_tx_out_cond_t *a_cond, dap_chain_datum_tx_t *a_tx_in, bool a_owner)
 {
-    UNUSED(a_tx_out_hash);
-    dap_chain_datum_tx_t									*burning_tx					= NULL;
-    dap_chain_datum_tx_receipt_t							*l_receipt					= NULL;
-    uint256_t												l_value_delegated			= {};
-    dap_hash_fast_t											hash_burning_transaction;
-    dap_chain_datum_token_tsd_delegate_from_stake_lock_t	l_tsd_section;
+    dap_chain_datum_tx_t									*l_burning_tx       = NULL;
+    dap_chain_datum_tx_receipt_t							*l_receipt          = NULL;
+    uint256_t												l_value_delegated   = {};
+    dap_hash_fast_t											l_burning_tx_hash;
+    dap_chain_datum_token_tsd_delegate_from_stake_lock_t	*l_tsd_section;
     dap_tsd_t												*l_tsd;
-    dap_chain_tx_out_t										*l_tx_out;
     dap_chain_tx_in_cond_t									*l_tx_in_cond;
-    const char												*l_tx_ticker;
-    dap_chain_datum_token_t									*delegate_token;
-    char 													delegated_ticker[DAP_CHAIN_TICKER_SIZE_MAX];
+    const char												*l_prev_tx_ticker;
+    dap_chain_datum_token_t									*l_delegated_token;
+    char 													l_delegated_ticker_str[DAP_CHAIN_TICKER_SIZE_MAX];
 
     if (!a_owner)
         return false;
@@ -1131,70 +891,51 @@ static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_hash_f
         if (a_cond->subtype.srv_stake_lock.time_unlock > dap_time_now())
             return false;
     }
-
-    if (a_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) {
-        l_receipt = (dap_chain_datum_tx_receipt_t *)dap_chain_datum_tx_item_get(a_tx_in, 0, TX_ITEM_TYPE_RECEIPT, 0);
-        if (!l_receipt)
-            return false;
-
-#if DAP_CHAIN_NET_SRV_UID_SIZE == 8
-        if (l_receipt->receipt_info.srv_uid.uint64 != DAP_CHAIN_NET_SRV_STAKE_LOCK_ID)
-            return false;
-#elif DAP_CHAIN_NET_SRV_UID_SIZE == 16
-        if (l_receipt->receipt_info.srv_uid.uint128 != DAP_CHAIN_NET_SRV_EXTERNAL_STAKE_ID)
-            return false;
-#endif
-
-        if (l_receipt->exts_size) {
-            hash_burning_transaction = *(dap_hash_fast_t*)l_receipt->exts_n_signs;
-            strcpy(delegated_ticker, (char *)&l_receipt->exts_n_signs[sizeof(dap_hash_fast_t)]);
-        } else
-            return false;
-
-        if (dap_hash_fast_is_blank(&hash_burning_transaction))
-            return false;
-    }
-
-    l_tx_out = (dap_chain_tx_out_t *)dap_chain_datum_tx_item_get(a_tx_in, 0, TX_ITEM_TYPE_OUT, 0);
-
-    if (!l_tx_out)
+    if (NULL == (l_tx_in_cond = (dap_chain_tx_in_cond_t *)dap_chain_datum_tx_item_get(
+                                                            a_tx_in, 0, TX_ITEM_TYPE_IN_COND, 0)))
         return false;
-
-    if (!EQUAL_256(a_cond->header.value, l_tx_out->header.value))
-    {
-        char *l_balance_coins = dap_chain_balance_to_coins(a_cond->header.value);
-        log_it(L_ERROR, "a_cond->header.value - %s", l_balance_coins);
-        l_balance_coins = dap_chain_balance_to_coins(l_tx_out->header.value);
-        log_it(L_ERROR, "l_tx_out->header.value - %s", l_balance_coins);
+    if (dap_hash_fast_is_blank(&l_tx_in_cond->header.tx_prev_hash))
         return false;
-    }
+    if (NULL == (l_prev_tx_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(
+                                                            a_ledger, &l_tx_in_cond->header.tx_prev_hash)))
+        return false;
+
+    dap_chain_datum_token_get_delegated_ticker(l_delegated_ticker_str, l_prev_tx_ticker);
 
-    if (a_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) {
-        if (NULL == (delegate_token = dap_chain_ledger_token_ticker_check(a_ledger, delegated_ticker))
-            ||	(delegate_token->subtype != DAP_CHAIN_DATUM_TOKEN_SUBTYPE_NATIVE)
-            ||	!delegate_token->header_native_decl.tsd_total_size
-            ||	NULL == (l_tsd = dap_tsd_find(delegate_token->data_n_tsd, delegate_token->header_native_decl.tsd_total_size, DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK))) {
+    if (a_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX ||
+            a_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_EMIT) {
+        if (NULL == (l_delegated_token = dap_chain_ledger_token_ticker_check(a_ledger, l_delegated_ticker_str))
+            ||	(l_delegated_token->subtype != DAP_CHAIN_DATUM_TOKEN_SUBTYPE_NATIVE)
+            ||	!l_delegated_token->header_native_decl.tsd_total_size
+            ||	NULL == (l_tsd = dap_tsd_find(l_delegated_token->data_n_tsd,
+                                              l_delegated_token->header_native_decl.tsd_total_size,
+                                              DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DELEGATE_EMISSION_FROM_STAKE_LOCK))) {
             return false;
         }
 
-        l_tsd_section = dap_tsd_get_scalar(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
+        l_tsd_section = dap_tsd_get_object(l_tsd, dap_chain_datum_token_tsd_delegate_from_stake_lock_t);
 
-        if (NULL == (l_tx_in_cond = (dap_chain_tx_in_cond_t *)dap_chain_datum_tx_item_get(a_tx_in, 0, TX_ITEM_TYPE_IN_COND, 0)))
-            return false;
-        if (dap_hash_fast_is_blank(&l_tx_in_cond->header.tx_prev_hash))
-            return false;
-        if (NULL == (l_tx_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, &l_tx_in_cond->header.tx_prev_hash)))
-            return false;
-        if (strcmp(l_tx_ticker, (char *)l_tsd_section.ticker_token_from))
-            return false;
-        if (NULL == (l_tx_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, &hash_burning_transaction)))
-            return false;
-        if (strcmp(l_tx_ticker, delegated_ticker))
-            return false;
+        if (!IS_ZERO_256(l_tsd_section->emission_rate)) {
+            MULT_256_COIN(a_cond->header.value, l_tsd_section->emission_rate, &l_value_delegated);
+            if (IS_ZERO_256(l_value_delegated))
+                return false;
+        }
+
+        l_receipt = (dap_chain_datum_tx_receipt_t *)dap_chain_datum_tx_item_get(a_tx_in, 0, TX_ITEM_TYPE_RECEIPT, 0);
+        if (l_receipt) {
+            if (!dap_chain_net_srv_uid_compare_scalar(l_receipt->receipt_info.srv_uid, DAP_CHAIN_NET_SRV_STAKE_LOCK_ID))
+                return false;
+            if (!l_receipt->exts_size)
+                return false;
+            l_burning_tx_hash = *(dap_hash_fast_t*)l_receipt->exts_n_signs;
+            if (dap_hash_fast_is_blank(&l_burning_tx_hash))
+                return false;
+            l_burning_tx = dap_chain_ledger_tx_find_by_hash(a_ledger, &l_burning_tx_hash);
+        } else
+            l_burning_tx = a_tx_in;
 
-        burning_tx = dap_chain_ledger_tx_find_by_hash(a_ledger, &hash_burning_transaction);
         int l_outs_count = 0;
-        dap_list_t *l_outs_list = dap_chain_datum_tx_items_get(burning_tx, TX_ITEM_TYPE_OUT_ALL, &l_outs_count);
+        dap_list_t *l_outs_list = dap_chain_datum_tx_items_get(l_burning_tx, TX_ITEM_TYPE_OUT_ALL, &l_outs_count);
         uint256_t l_blank_out_value = {};
         for (dap_list_t *it = l_outs_list; it; it = it->next) {
             byte_t l_type = *(byte_t *)it->data;
@@ -1207,7 +948,7 @@ static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_hash_f
             } else if (l_type == TX_ITEM_TYPE_OUT_EXT) {
                 dap_chain_tx_out_ext_t *l_out = it->data;
                 if (dap_chain_addr_is_blank(&l_out->addr) &&
-                        !strcmp(l_out->token, delegated_ticker)) {
+                        !strcmp(l_out->token, l_delegated_ticker_str)) {
                     l_blank_out_value = l_out->header.value;
                     break;
                 }
@@ -1219,20 +960,13 @@ static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_hash_f
             return false;
         }
 
-        if (!IS_ZERO_256(l_tsd_section.emission_rate)) {
-            MULT_256_COIN(l_tx_out->header.value, l_tsd_section.emission_rate, &l_value_delegated);
-            if (IS_ZERO_256(l_value_delegated))
-                return COINS_FORMAT_ERROR;
-        } else
-            l_value_delegated = l_tx_out->header.value;
-
         if (s_debug_more) {
-            char *str1 = dap_chain_balance_print(l_blank_out_value);
-            char *str2 = dap_chain_balance_print(l_tx_out->header.value);
-            char *str3 = dap_chain_balance_print(l_value_delegated);
-            log_it(L_INFO, "burning_value: |%s|",	str1);
-            log_it(L_INFO, "hold/take_value: |%s|",	str2);
-            log_it(L_INFO, "delegated_value |%s|",	str3);
+            char *str1 = dap_chain_balance_print(a_cond->header.value);
+            char *str2 = dap_chain_balance_print(l_value_delegated);
+            char *str3 = dap_chain_balance_print(l_blank_out_value);
+            log_it(L_INFO, "hold/take_value: %s",	str1);
+            log_it(L_INFO, "delegated_value: %s",	str2);
+            log_it(L_INFO, "burning_value:   %s",	str3);
             DAP_DEL_Z(str1);
             DAP_DEL_Z(str2);
             DAP_DEL_Z(str3);
@@ -1252,60 +986,56 @@ static bool s_stake_lock_callback_verificator(dap_ledger_t *a_ledger, dap_hash_f
  * @param a_tx_item_idx
  * @return
  */
-static void s_stake_lock_callback_verificator_added(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_t *a_tx_item)
+static void s_stake_lock_callback_updater(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_t *a_prev_out_item)
 {
-    if (a_tx_item)  // this is IN_COND tx
+    if (a_prev_out_item)  // this is IN_COND tx
         return;
     int l_out_num = 0;
     dap_chain_tx_out_cond_t *l_cond = dap_chain_datum_tx_out_cond_get(a_tx, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK, &l_out_num);
     if (l_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) {
         dap_chain_hash_fast_t l_tx_cond_hash;
-        dap_hash_fast( a_tx, dap_chain_datum_tx_get_size(a_tx), &l_tx_cond_hash);
-        if (!dap_hash_fast_is_blank(&l_tx_cond_hash))
-            dap_chain_ledger_emission_for_stake_lock_item_add(a_ledger, &l_tx_cond_hash);
+        dap_hash_fast(a_tx, dap_chain_datum_tx_get_size(a_tx), &l_tx_cond_hash);
+        dap_chain_ledger_emission_for_stake_lock_item_add(a_ledger, &l_tx_cond_hash);
     }
 }
 
-/**
- * @brief s_mempool_create
- * @param a_net
- * @param a_key_from
- * @param a_key_cond
- * @param a_token_ticker
- * @param a_value
- * @param a_srv_uid
- * @param a_addr_holder
- * @param a_count_months
- * @return
- */
-dap_chain_datum_t *dap_chain_net_srv_stake_lock_datum_create(dap_chain_net_t *a_net,
-                                                   dap_enc_key_t *a_key_from, dap_pkey_t *a_key_cond,
-                                                   const char a_token_ticker[DAP_CHAIN_TICKER_SIZE_MAX],
-                                                   uint256_t a_value, uint256_t a_value_fee, dap_chain_net_srv_uid_t a_srv_uid,
-                                                   dap_time_t a_time_staking, uint256_t a_reinvest_percent,
-                                                   bool a_create_base_tx,uint256_t *a_value_change, uint32_t *a_tx_out_prev_idx)
+static dap_chain_datum_t *s_stake_lock_datum_create(dap_chain_net_t *a_net, dap_enc_key_t *a_key_from,
+                                                    const char *a_main_ticker,
+                                                    uint256_t a_value, uint256_t a_value_fee,
+                                                    dap_time_t a_time_staking, uint256_t a_reinvest_percent,
+                                                    const char *a_delegated_ticker_str, uint256_t a_delegated_value)
 {
+    dap_chain_net_srv_uid_t l_uid = { .uint64 = DAP_CHAIN_NET_SRV_STAKE_LOCK_ID };
     dap_ledger_t * l_ledger = a_net ? dap_chain_ledger_by_net_name( a_net->pub.name ) : NULL;
     // check valid param
     if (!a_net || !l_ledger || !a_key_from ||
         !a_key_from->priv_key_data || !a_key_from->priv_key_data_size || IS_ZERO_256(a_value))
         return NULL;
 
+    const char *l_native_ticker = a_net->pub.native_ticker;
+    bool l_main_native = !dap_strcmp(a_main_ticker, l_native_ticker);
     // find the transactions from which to take away coins
     uint256_t l_value_transfer = {}; // how many coins to transfer
-    uint256_t l_value_need = {}, l_net_fee = {};
-    SUM_256_256(a_value, a_value_fee, &l_value_need);
-    // where to take coins for service
-    dap_chain_addr_t l_addr_from;
-    dap_chain_addr_t l_net_fee_addr = {};
-    bool l_net_fee_used = dap_chain_net_tx_get_fee(a_net->pub.id, &l_net_fee, &l_net_fee_addr);
-    if(l_net_fee_used)
-        SUM_256_256(l_value_need,l_net_fee,&l_value_need);
-
-    dap_chain_addr_fill_from_key(&l_addr_from, a_key_from, a_net->pub.id);
+    uint256_t l_value_need = a_value, l_net_fee = {}, l_total_fee = {}, l_fee_transfer = {};
+    dap_chain_addr_t l_addr_fee = {}, l_addr = {};
+
+    dap_chain_addr_fill_from_key(&l_addr, a_key_from, a_net->pub.id);
+    dap_list_t *l_list_fee_out = NULL;
+    bool l_net_fee_used = dap_chain_net_tx_get_fee(a_net->pub.id, &l_net_fee, &l_addr_fee);
+    SUM_256_256(l_net_fee, a_value_fee, &l_total_fee);
+    if (l_main_native)
+        SUM_256_256(l_value_need, l_total_fee, &l_value_need);
+    else if (!IS_ZERO_256(l_total_fee)) {
+        l_list_fee_out = dap_chain_ledger_get_list_tx_outs_with_val(a_net->pub.ledger, l_native_ticker,
+                                                                    &l_addr, l_total_fee, &l_fee_transfer);
+        if (!l_list_fee_out) {
+            log_it(L_WARNING, "Not enough funds to pay fee");
+            return NULL;
+        }
+    }
     // list of transaction with 'out' items
-    dap_list_t *l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(l_ledger, a_token_ticker,
-                                                                             &l_addr_from, l_value_need, &l_value_transfer);
+    dap_list_t *l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(l_ledger, a_main_ticker,
+                                                                             &l_addr, l_value_need, &l_value_transfer);
     if(!l_list_used_out) {
         log_it( L_ERROR, "Nothing to transfer (not enough funds)");
         return NULL;
@@ -1313,37 +1043,54 @@ dap_chain_datum_t *dap_chain_net_srv_stake_lock_datum_create(dap_chain_net_t *a_
 
     // create empty transaction
     dap_chain_datum_tx_t *l_tx = dap_chain_datum_tx_create();
+
     // add 'in' items
     {
         uint256_t l_value_to_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_used_out);
         assert(EQUAL_256(l_value_to_items, l_value_transfer));
-        dap_list_free_full(l_list_used_out, free);
+        dap_list_free_full(l_list_used_out, NULL);
+        if (l_list_fee_out) {
+            uint256_t l_value_fee_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_fee_out);
+            assert(EQUAL_256(l_value_fee_items, l_fee_transfer));
+            dap_list_free_full(l_list_fee_out, NULL);
+        }
     }
-    // add 'out_cond' and 'out' items
+
+    // add 'in_ems' item
+    {
+        dap_chain_id_t l_chain_id = dap_chain_net_get_default_chain_by_chain_type(a_net, CHAIN_TYPE_TX)->id;
+        dap_hash_fast_t l_blank_hash = {};
+        dap_chain_tx_in_ems_t *l_in_ems = dap_chain_datum_tx_item_in_ems_create(l_chain_id, &l_blank_hash, a_delegated_ticker_str);
+        dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_in_ems);
+    }
+
+    // add 'out_cond' and 'out_ext' items
     {
-        uint256_t l_value_pack = {}; // how much coin add to 'out' items
-        dap_chain_tx_out_cond_t* l_tx_out_cond = dap_chain_net_srv_stake_lock_create_cond_out(a_key_cond, a_srv_uid, a_value, a_time_staking, a_reinvest_percent, a_create_base_tx);
-        if(l_tx_out_cond) {
+        uint256_t l_value_pack = {}, l_native_pack = {}; // how much coin add to 'out_ext' items
+        dap_chain_tx_out_cond_t* l_tx_out_cond = dap_chain_datum_tx_item_out_cond_create_srv_stake_lock(
+                                                        l_uid, a_value, a_time_staking, a_reinvest_percent);
+        if (l_tx_out_cond) {
             SUM_256_256(l_value_pack, a_value, &l_value_pack);
             dap_chain_datum_tx_add_item(&l_tx, (const uint8_t *)l_tx_out_cond);
             DAP_DEL_Z(l_tx_out_cond);
-            // transaction fee
-//			if (!IS_ZERO_256(a_value_fee)) {
-                // TODO add condition with fee for mempool-as-service
-//			}
-        }//TODO: else return false;
-        (*a_tx_out_prev_idx)++;
+        } else {
+            dap_chain_datum_tx_delete(l_tx);
+            log_it(L_ERROR, "Cant add conditional output");
+            return NULL;
+        }
 
         uint256_t l_value_back = {};
         // Network fee
         if (l_net_fee_used) {
-            if (dap_chain_datum_tx_add_out_item(&l_tx, &l_net_fee_addr, l_net_fee) != 1) {
+            if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr_fee, l_net_fee, l_native_ticker) != 1) {
                 dap_chain_datum_tx_delete(l_tx);
                 log_it(L_ERROR, "Cant add network fee output");
                 return NULL;
             }
-            SUM_256_256(l_value_pack, l_net_fee, &l_value_pack);
-            (*a_tx_out_prev_idx)++;
+            if (l_main_native)
+                SUM_256_256(l_value_pack, l_net_fee, &l_value_pack);
+            else
+                SUM_256_256(l_native_pack, l_net_fee, &l_native_pack);
         }
         // Validator's fee
         if (!IS_ZERO_256(a_value_fee)) {
@@ -1352,24 +1099,42 @@ dap_chain_datum_t *dap_chain_net_srv_stake_lock_datum_create(dap_chain_net_t *a_
                 log_it(L_ERROR, "Cant add validator's fee output");
                 return NULL;
             }
-            SUM_256_256(l_value_pack, a_value_fee, &l_value_pack);
-            (*a_tx_out_prev_idx)++;
+            if (l_main_native)
+                SUM_256_256(l_value_pack, a_value_fee, &l_value_pack);
+            else
+                SUM_256_256(l_native_pack, a_value_fee, &l_native_pack);
         }
         // coin back
         SUBTRACT_256_256(l_value_transfer, l_value_pack, &l_value_back);
         if (!IS_ZERO_256(l_value_back)) {
-            if(dap_chain_datum_tx_add_out_item(&l_tx, &l_addr_from, l_value_back) != 1) {
+            if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr, l_value_back, a_main_ticker) != 1) {
                 dap_chain_datum_tx_delete(l_tx);
-                log_it( L_ERROR, "Cant add coin back output");
+                log_it( L_ERROR, "Cant add coin back output for main ticker");
                 return NULL;
             }
-            (*a_tx_out_prev_idx)++;
-            *a_value_change = l_value_back;
+        }
+        // fee coin back
+        if (!IS_ZERO_256(l_fee_transfer)) {
+            SUBTRACT_256_256(l_fee_transfer, l_native_pack, &l_value_back);
+            if (!IS_ZERO_256(l_value_back)) {
+                if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr, l_value_back, l_native_ticker) != 1) {
+                    dap_chain_datum_tx_delete(l_tx);
+                    log_it( L_ERROR, "Cant add coin back output for native ticker");
+                    return NULL;
+                }
+            }
         }
     }
 
-    // add 'sign' items
-    if(dap_chain_datum_tx_add_sign_item(&l_tx, a_key_from) != 1) {
+    // add delegated token emission 'out_ext'
+    if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr, a_delegated_value, a_delegated_ticker_str) != 1) {
+        dap_chain_datum_tx_delete(l_tx);
+        log_it( L_ERROR, "Cant add delegated token emission output");
+        return NULL;
+    }
+
+    // add 'sign' item
+    if (dap_chain_datum_tx_add_sign_item(&l_tx, a_key_from) != 1) {
         dap_chain_datum_tx_delete(l_tx);
         log_it( L_ERROR, "Can't add sign output");
         return NULL;
@@ -1381,71 +1146,67 @@ dap_chain_datum_t *dap_chain_net_srv_stake_lock_datum_create(dap_chain_net_t *a_
     return l_datum;
 }
 
-dap_chain_datum_t *dap_chain_burning_tx_create(dap_chain_t *a_chain, dap_enc_key_t *a_key_from,
-                                             const dap_chain_addr_t* a_addr_from, const dap_chain_addr_t* a_addr_to,
-                                             const char a_token_ticker[DAP_CHAIN_TICKER_SIZE_MAX],
-                                             uint256_t a_value, uint256_t a_value_fee, uint32_t *a_tx_out_prev_idx,uint256_t *a_value_change)
+dap_chain_datum_t *s_stake_unlock_datum_create(dap_chain_net_t *a_net, dap_enc_key_t *a_key_from,
+                                               dap_hash_fast_t *a_stake_tx_hash, uint32_t a_prev_cond_idx,
+                                               const char *a_main_ticker, uint256_t a_value,
+                                               uint256_t a_value_fee,
+                                               const char *a_delegated_ticker_str, uint256_t a_delegated_value)
 {
     // check valid param
-    if(!a_chain | !a_key_from || ! a_addr_from || !a_key_from->priv_key_data || !a_key_from->priv_key_data_size ||
-       !dap_chain_addr_check_sum(a_addr_from) || !a_addr_to || !dap_chain_addr_check_sum(a_addr_to) || IS_ZERO_256(a_value))
+    if (!a_net | !a_key_from || !a_key_from->priv_key_data || !a_key_from->priv_key_data_size || dap_hash_fast_is_blank(a_stake_tx_hash))
         return NULL;
 
+    const char *l_native_ticker = a_net->pub.native_ticker;
+    bool l_main_native = !dap_strcmp(a_main_ticker, l_native_ticker);
     // find the transactions from which to take away coins
     uint256_t l_value_transfer = {}; // how many coins to transfer
-    uint256_t l_net_fee = {};
-    uint256_t l_total_fee = a_value_fee;
-    dap_chain_addr_t l_addr_fee = {};
-    const char *l_native_ticker = dap_chain_net_by_id(a_chain->net_id)->pub.native_ticker;
-    dap_list_t *l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(a_chain->ledger, a_token_ticker,
-                                                                             a_addr_from, a_value, &l_value_transfer);
-    bool l_net_fee_used = dap_chain_net_tx_get_fee(a_chain->net_id, &l_net_fee, &l_addr_fee);
-    if(l_net_fee_used)
-        SUM_256_256(l_total_fee,l_net_fee,&l_total_fee);
-
-    if (!l_list_used_out) {
-        log_it(L_WARNING,"Not enough funds to transfer");
-        return NULL;
-    }
-    // create empty transaction    
-    dap_chain_datum_tx_t *l_tx = dap_chain_datum_tx_create();
-    //----------burning add transaction------------
-    // add 'in' items
-    {
-        uint256_t l_value_to_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_used_out);
-        assert(EQUAL_256(l_value_to_items, l_value_transfer));
-        dap_list_free_full(l_list_used_out, free);
+    uint256_t l_net_fee = {}, l_total_fee = {}, l_fee_transfer = {};
+    dap_chain_addr_t l_addr_fee = {}, l_addr = {};
+
+    dap_chain_addr_fill_from_key(&l_addr, a_key_from, a_net->pub.id);
+    dap_list_t *l_list_fee_out = NULL, *l_list_used_out = NULL;
+    bool l_net_fee_used = dap_chain_net_tx_get_fee(a_net->pub.id, &l_net_fee, &l_addr_fee);
+    SUM_256_256(l_net_fee, a_value_fee, &l_total_fee);
+
+    if (!IS_ZERO_256(l_total_fee)) {
+        l_list_fee_out = dap_chain_ledger_get_list_tx_outs_with_val(a_net->pub.ledger, l_native_ticker,
+                                                                    &l_addr, l_total_fee, &l_fee_transfer);
+        if (!l_list_fee_out) {
+            log_it(L_WARNING, "Not enough funds to pay fee");
+            return NULL;
+        }
     }
-    // add 'out' items
-    {
-        uint256_t l_value_pack = {}; // how much datoshi add to 'out' items
-        if (dap_chain_datum_tx_add_out_ext_item(&l_tx, a_addr_to, a_value, a_token_ticker)==1){
-            SUM_256_256(l_value_pack, a_value, &l_value_pack);
-            (*a_tx_out_prev_idx)++;
+    if (!IS_ZERO_256(a_delegated_value)) {
+        l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(a_net->pub.ledger, a_delegated_ticker_str,
+                                                                                 &l_addr, a_delegated_value, &l_value_transfer);
+        if(!l_list_used_out) {
+            log_it( L_ERROR, "Nothing to transfer (not enough delegated tokens)");
+            return NULL;
         }
-        // coin back
-        uint256_t l_value_back;
-        SUBTRACT_256_256(l_value_transfer, l_value_pack, &l_value_back);
-        if(!IS_ZERO_256(l_value_back)) {
-            if (!dap_chain_datum_tx_add_out_ext_item(&l_tx, a_addr_from, l_value_back, a_token_ticker)){
-                dap_chain_datum_tx_delete(l_tx);
-                return NULL;
-            }
-            (*a_tx_out_prev_idx)++;
-        }        
     }
-    //----------fee add transaction------------
-    l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(a_chain->ledger, l_native_ticker,
-                                                                                 a_addr_from, l_total_fee, &l_value_transfer);
-    // add 'in' items
+
+    // create empty transaction
+    dap_chain_datum_tx_t *l_tx = dap_chain_datum_tx_create();
+
+    // add 'in_cond' & 'in' items
     {
-        uint256_t l_value_to_items_fee = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_used_out);
-        assert(EQUAL_256(l_value_to_items_fee, l_value_transfer));
-        dap_list_free_full(l_list_used_out, free);
+        dap_chain_datum_tx_add_in_cond_item(&l_tx, a_stake_tx_hash, a_prev_cond_idx, 0);
+        if (l_list_used_out) {
+            uint256_t l_value_to_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_used_out);
+            assert(EQUAL_256(l_value_to_items, l_value_transfer));
+            dap_list_free_full(l_list_used_out, NULL);
+        }
+        if (l_list_fee_out) {
+            uint256_t l_value_fee_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_fee_out);
+            assert(EQUAL_256(l_value_fee_items, l_fee_transfer));
+            dap_list_free_full(l_list_fee_out, NULL);
+        }
     }
-    // add 'out fee' items
+
+    // add 'out_ext' items
+    uint256_t l_value_back;
     {
-        uint256_t l_value_pack = {};
+        uint256_t l_value_pack = {}; // how much datoshi add to 'out' items
         // Network fee
         if(l_net_fee_used){
             if (!dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr_fee, l_net_fee, l_native_ticker)){
@@ -1453,14 +1214,12 @@ dap_chain_datum_t *dap_chain_burning_tx_create(dap_chain_t *a_chain, dap_enc_key
                 return NULL;
             }
             SUM_256_256(l_value_pack, l_net_fee, &l_value_pack);
-            (*a_tx_out_prev_idx)++;
         }
         // Validator's fee
         if (!IS_ZERO_256(a_value_fee)) {
             if (dap_chain_datum_tx_add_fee_item(&l_tx, a_value_fee) == 1)
             {
                 SUM_256_256(l_value_pack, a_value_fee, &l_value_pack);
-                (*a_tx_out_prev_idx)++;
             }
             else {
                 dap_chain_datum_tx_delete(l_tx);
@@ -1468,16 +1227,38 @@ dap_chain_datum_t *dap_chain_burning_tx_create(dap_chain_t *a_chain, dap_enc_key
             }
         }
         // coin back
-        uint256_t l_value_back;
-        SUBTRACT_256_256(l_value_transfer, l_value_pack, &l_value_back);
+        SUBTRACT_256_256(l_fee_transfer, l_value_pack, &l_value_back);
+        if (l_main_native) {
+            // add unlock value to coin back
+            SUM_256_256(l_value_back, a_value, &l_value_back);
+        } else if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr, a_value, a_main_ticker)!=1) {
+            dap_chain_datum_tx_delete(l_tx);
+            return NULL;
+        }
         if(!IS_ZERO_256(l_value_back)) {
-            if(dap_chain_datum_tx_add_out_ext_item(&l_tx, a_addr_from, l_value_back,l_native_ticker) != 1) {
+            if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr, l_value_back, l_native_ticker) != 1) {
+                dap_chain_datum_tx_delete(l_tx);
+                return NULL;
+            }
+        }
+    }
+
+    // add burning 'out_ext'
+    if (!IS_ZERO_256(a_delegated_value)) {
+        if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &c_dap_chain_addr_blank,
+                                               a_delegated_value, a_delegated_ticker_str) != 1) {
+            dap_chain_datum_tx_delete(l_tx);
+            return NULL;
+        }
+        // delegated token coin back
+        SUBTRACT_256_256(l_value_transfer, a_delegated_value, &l_value_back);
+        if (!IS_ZERO_256(l_value_back)) {
+            if (dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_addr, l_value_back, a_delegated_ticker_str) != 1) {
                 dap_chain_datum_tx_delete(l_tx);
                 return NULL;
             }
-            (*a_tx_out_prev_idx)++;
-            *a_value_change = l_value_back;
         }
+
     }
 
     // add 'sign' items
@@ -1493,104 +1274,3 @@ dap_chain_datum_t *dap_chain_burning_tx_create(dap_chain_t *a_chain, dap_enc_key
 
     return l_datum;
 }
-
-static char *dap_chain_mempool_base_tx_for_stake_lock_create(dap_chain_t *a_chain, dap_chain_hash_fast_t *a_emission_hash,
-                                                        dap_chain_id_t a_emission_chain_id, uint256_t a_emission_value, const char *a_ticker,
-                                                        dap_chain_addr_t *a_addr_to, dap_enc_key_t *a_key_from, const char *a_hash_out_type,
-                                                        uint256_t a_value_fee, uint256_t a_value_change, uint32_t a_tx_out_prev_idx)
-{
-
-    uint256_t l_net_fee = {};
-    uint256_t l_value_transfer = {}; // how many coins to transfer
-    uint256_t l_value_need = a_value_fee;
-    dap_chain_addr_t l_net_fee_addr = {};
-    dap_chain_addr_t *l_addr_from;
-    dap_chain_net_t *l_net = dap_chain_net_by_id(a_chain->net_id);
-
-    const char *l_native_ticker = l_net->pub.native_ticker;
-    bool l_net_fee_used = dap_chain_net_tx_get_fee(a_chain->net_id, &l_net_fee, &l_net_fee_addr);
-    if(l_net_fee_used)
-        SUM_256_256(l_value_need,l_net_fee,&l_value_need);
-
-    // create first transaction (with tx_token)
-    dap_chain_datum_tx_t *l_tx = DAP_NEW_Z_SIZE(dap_chain_datum_tx_t, sizeof(dap_chain_datum_tx_t));
-    l_tx->header.ts_created = time(NULL);
-
-    l_addr_from = DAP_NEW_Z(dap_chain_addr_t);
-    dap_chain_addr_fill_from_key(l_addr_from, a_key_from, l_net->pub.id);
-    // create items
-
-    dap_chain_tx_in_ems_t *l_tx_token = dap_chain_datum_tx_item_in_ems_create(a_emission_chain_id, a_emission_hash, a_ticker);
-
-    dap_chain_tx_in_t *l_in = dap_chain_datum_tx_item_in_create(a_emission_hash, a_tx_out_prev_idx-1);
-    //dap_chain_tx_out_t *l_out = dap_chain_datum_tx_item_out_create(a_addr_to, a_emission_value);
-
-    // pack items to transaction
-    dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_tx_token);
-    dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_in);
-    //dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_out);
-    if (!dap_chain_datum_tx_add_out_ext_item(&l_tx, a_addr_to, a_emission_value, a_ticker)){
-        dap_chain_datum_tx_delete(l_tx);
-        return NULL;
-    }
-
-//    dap_list_t *l_list_used_out = dap_chain_ledger_get_list_tx_outs_with_val(a_chain->ledger, l_native_ticker,
-//                                                                             l_addr_from, l_value_need, &l_value_transfer);
-    if(compare256(a_value_change,l_value_need)<0) {
-        log_it(L_WARNING,"Not enough funds to transfer");
-        DAP_DEL_Z(l_addr_from);
-        dap_chain_datum_tx_delete(l_tx);
-        return NULL;
-    }
-    l_value_transfer = a_value_change;
-    uint256_t l_value_back = l_value_transfer;
-    //add in
-//    uint256_t l_value_to_items = dap_chain_datum_tx_add_in_item_list(&l_tx, l_list_used_out);
-//    assert(EQUAL_256(l_value_to_items, l_value_transfer));
-//    dap_list_free_full(l_list_used_out, NULL);
-    // Network fee
-    if(l_net_fee_used){
-        if (!dap_chain_datum_tx_add_out_ext_item(&l_tx, &l_net_fee_addr, l_net_fee, l_native_ticker)){
-            dap_chain_datum_tx_delete(l_tx);
-            DAP_DEL_Z(l_addr_from);
-            return NULL;
-        }
-        SUBTRACT_256_256(l_value_back, l_net_fee, &l_value_back);
-    }
-    // Validator's fee
-    if (dap_chain_datum_tx_add_fee_item(&l_tx, a_value_fee) != 1) {
-        dap_chain_datum_tx_delete(l_tx);
-        log_it(L_ERROR, "Cant add validator's fee output");
-        return NULL;
-    }
-    SUBTRACT_256_256(l_value_back, a_value_fee, &l_value_back);
-    // coin back
-    if (!dap_chain_datum_tx_add_out_ext_item(&l_tx, l_addr_from, l_value_back, l_native_ticker)){
-        dap_chain_datum_tx_delete(l_tx);
-        DAP_DEL_Z(l_addr_from);
-        return NULL;
-    }
-    DAP_DEL_Z(l_addr_from);
-
-    if (a_key_from) {
-        if(dap_chain_datum_tx_add_sign_item(&l_tx, a_key_from) < 0) {
-            log_it(L_WARNING, "Private key not valid");
-            return NULL;
-        }
-    } else {
-        log_it(L_WARNING, "No private key for base TX!");
-        return NULL;
-    }
-
-    DAP_DEL_Z(l_tx_token);
-    DAP_DEL_Z(l_addr_from);
-    //DAP_DEL_Z(l_in);
-   // DAP_DEL_Z(l_out);
-
-    size_t l_tx_size = dap_chain_datum_tx_get_size(l_tx);
-
-    // Pack transaction into the datum
-    dap_chain_datum_t * l_datum_tx = dap_chain_datum_create(DAP_CHAIN_DATUM_TX, l_tx, l_tx_size);
-    DAP_DEL_Z(l_tx);
-    return dap_chain_mempool_datum_add(l_datum_tx, a_chain, a_hash_out_type);
-}
diff --git a/modules/service/stake_pos_delegate/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
similarity index 99%
rename from modules/service/stake_pos_delegate/dap_chain_net_srv_stake_pos_delegate.c
rename to modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
index c6505a8e987f16e513f6e5dca4c50958df81a340..c64ecf391a5cf917db4316b43d85c114199ebf47 100644
--- a/modules/service/stake_pos_delegate/dap_chain_net_srv_stake_pos_delegate.c
+++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
@@ -32,8 +32,6 @@
 #include "dap_chain_mempool.h"
 #include "dap_chain_net_tx.h"
 #include "dap_chain_net_srv.h"
-#include "dap_chain_cs_block_poa.h"
-#include "dap_chain_cs_dag_poa.h"
 #include "dap_chain_net_srv_stake_pos_delegate.h"
 
 #include "rand/dap_rand.h"
@@ -47,7 +45,7 @@
 
 static int s_cli_srv_stake(int a_argc, char **a_argv, char **a_str_reply);
 
-static bool s_stake_verificator_callback(dap_ledger_t * a_ledger,dap_hash_fast_t *a_tx_out_hash, dap_chain_tx_out_cond_t *a_cond,
+static bool s_stake_verificator_callback(dap_ledger_t *a_ledger, dap_chain_tx_out_cond_t *a_cond,
                                                       dap_chain_datum_tx_t *a_tx_in, bool a_owner);
 static void s_stake_updater_callback(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_t *a_cond);
 
@@ -126,9 +124,8 @@ void dap_chain_net_srv_stake_pos_delegate_deinit()
     DAP_DEL_Z(s_srv_stake);
 }
 
-static bool s_stake_verificator_callback(dap_ledger_t UNUSED_ARG *a_ledger, dap_hash_fast_t UNUSED_ARG *a_tx_out_hash,
-                                         dap_chain_tx_out_cond_t UNUSED_ARG *a_cond, dap_chain_datum_tx_t UNUSED_ARG *a_tx_in,
-                                         bool a_owner)
+static bool s_stake_verificator_callback(dap_ledger_t UNUSED_ARG *a_ledger, dap_chain_tx_out_cond_t UNUSED_ARG *a_cond,
+                                         dap_chain_datum_tx_t UNUSED_ARG *a_tx_in, bool a_owner)
 {
     assert(s_srv_stake);
     if (!a_owner)
diff --git a/modules/service/stake/include/dap_chain_net_srv_stake_lock.h b/modules/service/stake/include/dap_chain_net_srv_stake_lock.h
new file mode 100644
index 0000000000000000000000000000000000000000..6893e2a2f709697637a784f118362252560fd989
--- /dev/null
+++ b/modules/service/stake/include/dap_chain_net_srv_stake_lock.h
@@ -0,0 +1,30 @@
+/*
+ * Authors:
+ * Davlet Sibgatullin <davlet.sibgatullin@demlabs.net>
+ * DeM Labs Inc.   https://demlabs.net
+ * DeM Labs Open source community https://gitlab.demlabs.net
+ * Copyright  (c) 2022
+ * All rights reserved.
+
+ This file is part of DAP (Deus Applications Prototypes) the open source project
+
+    DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    DAP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#define DAP_CHAIN_NET_SRV_STAKE_LOCK_ID 0x12
+
+int dap_chain_net_srv_stake_lock_init(void);
+void dap_chain_net_srv_stake_lock_deinit(void);
diff --git a/modules/service/stake_pos_delegate/include/dap_chain_net_srv_stake_pos_delegate.h b/modules/service/stake/include/dap_chain_net_srv_stake_pos_delegate.h
similarity index 100%
rename from modules/service/stake_pos_delegate/include/dap_chain_net_srv_stake_pos_delegate.h
rename to modules/service/stake/include/dap_chain_net_srv_stake_pos_delegate.h
diff --git a/modules/service/stake_lock/include/dap_chain_net_srv_stake_lock.h b/modules/service/stake_lock/include/dap_chain_net_srv_stake_lock.h
deleted file mode 100644
index ea615ba5cb4602a966ce43357b5fd4ae5514da31..0000000000000000000000000000000000000000
--- a/modules/service/stake_lock/include/dap_chain_net_srv_stake_lock.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Authors:
- * Davlet Sibgatullin <davlet.sibgatullin@demlabs.net>
- * DeM Labs Inc.   https://demlabs.net
- * DeM Labs Open source community https://gitlab.demlabs.net
- * Copyright  (c) 2022
- * All rights reserved.
-
- This file is part of DAP (Deus Applications Prototypes) the open source project
-
-    DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    DAP is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#pragma once
-
-#include "dap_chain_net.h"
-#include "dap_chain_common.h"
-#include "dap_chain_datum_tx_out_cond.h"
-
-#define DAP_CHAIN_NET_SRV_STAKE_LOCK_ID 0x12
-
-/**
- * @brief The cond_params struct thats placed in tx_cond->params[] section
- */
-
-
-int 					dap_chain_net_srv_stake_lock_init(void);
-void					dap_chain_net_srv_stake_lock_deinit(void);
-
-// Create stake lock datum
-dap_chain_datum_t *dap_chain_net_srv_stake_lock_datum_create(dap_chain_net_t *a_net,
-                                                   dap_enc_key_t *a_key_from, dap_pkey_t *a_key_cond,
-                                                   const char a_token_ticker[DAP_CHAIN_TICKER_SIZE_MAX],
-                                                   uint256_t a_value, uint256_t a_value_fee, dap_chain_net_srv_uid_t a_srv_uid,
-                                                   dap_time_t a_time_staking, uint256_t a_reinvest_percent,
-                                                   bool a_create_base_tx,uint256_t *a_value_change, uint32_t *a_tx_out_prev_idx);
-// Burning_tx_create
-dap_chain_datum_t *dap_chain_burning_tx_create(dap_chain_t* a_chain, dap_enc_key_t* a_key_from,
-                                                    const dap_chain_addr_t* a_addr_from, const dap_chain_addr_t* a_addr_to,
-                                                    const char a_token_ticker[DAP_CHAIN_TICKER_SIZE_MAX],
-                                                    uint256_t a_value,uint256_t a_value_fee,uint32_t *a_tx_out_prev_idx,uint256_t *a_value_change);
diff --git a/modules/service/stake_pos_delegate/CMakeLists.txt b/modules/service/stake_pos_delegate/CMakeLists.txt
deleted file mode 100644
index 958cc783e4de4029bb603949a7e0357647f00cef..0000000000000000000000000000000000000000
--- a/modules/service/stake_pos_delegate/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project (dap_chain_net_srv_stake_pos_delegate)
-
-file(GLOB DAP_SRV_STAKE_POS_DELEGATE_SRCS *.c)
-
-file(GLOB DAP_SRV_STAKE_POS_DELEGATE_HEADERS include/*.h)
-
-add_library(${PROJECT_NAME} STATIC ${DAP_SRV_STAKE_POS_DELEGATE_SRCS} ${DAP_SRV_STAKE_POS_DELEGATE_HEADERS})
-
-target_include_directories(${PROJECT_NAME} INTERFACE .)
-target_include_directories(${PROJECT_NAME} PUBLIC include)
-target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_net dap_chain_net_srv dap_chain_cs_dag_poa dap_chain_cs_block_poa)
diff --git a/modules/service/xchange/dap_chain_net_srv_xchange.c b/modules/service/xchange/dap_chain_net_srv_xchange.c
index 2dac02ab5511eb7f64a7b2d19b3eaad0b684b0e4..35da1900bbb96632eec685745585a52bdfef5164 100644
--- a/modules/service/xchange/dap_chain_net_srv_xchange.c
+++ b/modules/service/xchange/dap_chain_net_srv_xchange.c
@@ -54,7 +54,7 @@ static dap_chain_net_srv_fee_item_t *s_service_fees = NULL; // Governance statem
 static pthread_rwlock_t s_service_fees_rwlock = PTHREAD_RWLOCK_INITIALIZER;
 
 static void s_callback_decree (dap_chain_net_srv_t * a_srv, dap_chain_net_t *a_net, dap_chain_t * a_chain, dap_chain_datum_decree_t * a_decree, size_t a_decree_size);
-static bool s_xchange_verificator_callback(dap_ledger_t * a_ledger,dap_hash_fast_t *a_tx_out_hash,  dap_chain_tx_out_cond_t *a_cond,
+static bool s_xchange_verificator_callback(dap_ledger_t * a_ledger, dap_chain_tx_out_cond_t *a_cond,
                             dap_chain_datum_tx_t *a_tx_in, bool a_owner);
 const dap_chain_net_srv_uid_t c_dap_chain_net_srv_xchange_uid = {.uint64= DAP_CHAIN_NET_SRV_XCHANGE_ID};
 
@@ -155,16 +155,21 @@ void dap_chain_net_srv_xchange_deinit()
  * @param a_owner
  * @return
  */
-static bool s_xchange_verificator_callback(dap_ledger_t * a_ledger,dap_hash_fast_t *a_tx_out_hash,  dap_chain_tx_out_cond_t *a_tx_out_cond,
+static bool s_xchange_verificator_callback(dap_ledger_t *a_ledger, dap_chain_tx_out_cond_t *a_tx_out_cond,
                                            dap_chain_datum_tx_t *a_tx_in, bool a_owner)
 {
     return true;//for tests
     if (a_owner)
         return true;
-    if(!a_tx_out_hash || !a_tx_in || !a_tx_out_cond)
+    if(!a_tx_in || !a_tx_out_cond)
         return false;
 
-    const char *l_sell_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger,a_tx_out_hash);
+    dap_chain_tx_in_cond_t *l_tx_in_cond = (dap_chain_tx_in_cond_t *)dap_chain_datum_tx_item_get(a_tx_in, 0, TX_ITEM_TYPE_IN_COND, 0);
+    if (!l_tx_in_cond)
+        return false;
+    if (dap_hash_fast_is_blank(&l_tx_in_cond->header.tx_prev_hash))
+        return false;
+    const char *l_sell_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, &l_tx_in_cond->header.tx_prev_hash);
     if (!l_sell_ticker)
         return false;
     const char *l_buy_ticker = a_tx_out_cond->subtype.srv_xchange.buy_token;