This is a conditional transaction where funds can only be spent by specific users who were granted permission to do so when the transaction was created.
To spend funds from the conditional output of such a transaction, another transaction must be created with the required number of valid signatures from wallets that were authorized to sign such transactions.
The shared funds mechanism is designed to prevent bridges and staking from uncontrollable infinite emission, thereby enhancing the system’s security.
Any user can create such a transaction, allocate funds to its conditional output, and designate specific users who will have the right to sign a spending transaction to withdraw these funds, either fully or partially.
This can be applied to bridge emission, staking rewards and other cases, where we have to limit funds available for debit.
Commands for create such transaction and debit funds from it are available here: EMIT_DELEGATE. Node Commands
Debit Example
There are three transactions.
Shared funds initially received a definite amount of funds SUPPLY VALUE
on its item IN EMS
, and therefore, these funds can be debited from the COND OUT (SRV_EMIT_DELEGATE)
of this transaction. Also, there is an item MINIMAL NUMBER OF VALID SIGNATURES
which defines how signatures are required to debit funds from this transation. In this case - 6.
Next, the transaction successful debit receives a specified amount of funds from the COND OUT (SRV_EMIT_DELEGATE)
to its COND IN (VALUE)
item. This transfer was successful because the transaction was signed by six wallets with corresponding delegated rights. Then, this VALUE
will be used to pay for the validator fee via transfer to corresponding COND OUT (FEE)
, while the rest of the sum will be directed on OUT (VALUE)
, waiting for debit.
The transaction failed debit has the same items, but not enough valid signatures (4 instead of 6).
This transfer wil be blocked, and the funds will remain on COND OUT (SRV_EMIT_DELEGATE)
of the shared funds transaction.
Usage Example
Let’s take the following example.
Example
A user has multiple wallets. The main one with a majority of funds and two additional wallets. To ensure the safety of funds he decides to lock them with a shared funds transaction.
First, we need to retrieve public key hashes from the wallets.
Command:
cellframe-node-tool wallet pkey show <wallet name>
Examples:
cellframe-node-tool wallet pkey show main_wallet
0x0E9D0534BD148C2373CC78C5834D08246A52F6D169DEAB99F8D7CCEAF107A1CE
cellframe-node-tool wallet pkey show second_wallet
0xF8DA3298DFC838741ABAA8D8AA5056E54D0FC15E8FC0EF3A89290476778FC1D5
cellframe-node-tool wallet pkey show third_wallet
0x011FCE96B76FBA54F5EB67AA134A013C3BD52EB88A4132A7F5C1939807F3D5A7
Next step is to create a conditional shared funds transaction which locks funds on the conditional OUT.
Command syntax:
emit_delegate hold
-net <net_name>
-w <wallet_name>
-token <ticker>
-value <value>
-fee <value>
-signs_minimum <value_int>
-pkey_hashes <hash1[,hash2,...,hashN]>
[-chain <chain_name>]
[-H {hex(default) | base58}
Options:
-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-w - the name of the wallet from which funds will be taken
-token - ticker of the token
-value - amount of funds being taken for holding
-fee - commission for transaction
-signs_minimum - quantity of required valid signatures for funds debit
-pkey_hashes - public keys of users who have the right to participate in the consensus of the funds withdrawal (minimum - 1)
-chain - name of the preferred chain where transaction will be put: zerochain or mainchain (optional)
-H - hash format: HEX or base58 (optional)
Command example:
cellframe-node-cli emit_delegate hold -net raiden -w main_wallet -token tCELL -value 900000.0 -fee 1.0 -signs_minimum 2 -pkey_hashes 0x0E9D0534BD148C2373CC78C5834D08246A52F6D169DEAB99F8D7CCEAF107A1CE,0xF8DA3298DFC838741ABAA8D8AA5056E54D0FC15E8FC0EF3A89290476778FC1D5,0x011FCE96B76FBA54F5EB67AA134A013C3BD52EB88A4132A7F5C1939807F3D5A7
Result:
status: success
tx_hash: 0x608FD1A636FD6F1C35A454B268115AF939732D0E8F9D6F8B95A35C2014AABC4D
Once a transaction is processed, we can check its contents.
Let’s take a look at its conditional OUT.
cellframe-node-cli tx_history -tx 0x608FD1A636FD6F1C35A454B268115AF939732D0E8F9D6F8B95A35C2014AABC4D -net raiden
item type: OUT COND
ts_expires: never
coins: 900000.0
value: 900000000000000000000000
subtype: DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_EMIT_DELEGATE
uid: 0x0000000000000007
tsd_size: 114
Funds are successfully locked.
Next, let’s debit some of the funds and initiate a transaction using one of the wallets which were granted permissions previously.
Recipient of the funds will be a wallet that is not allowed to interact with shared funds transaction.
Command syntax:
emit_delegate take
-net <net_name>
-w <wallet_name>
-tx <transaction_hash>
-to_addr <addr>
-value <value>
-fee <value>
[-chain <chain_name>]
[-H {hex(default) | base58}]
Options:
-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-w - the name of the wallet which has a right to debit funds
-tx - hash of the shared funds transaction
-to_addr - wallet address where funds will be transferred
-value - amount of funds being taken
-fee - commission for transaction
-chain - name of the preferred chain where transaction will be put: zerochain or mainchain (optional)
-H - hash format: HEX or base58 (optional)
Command example:
cellframe-node-cli emit_delegate take -net raiden -w second_wallet -tx 0x608FD1A636FD6F1C35A454B268115AF939732D0E8F9D6F8B95A35C2014AABC4D -to_addr jrmnGqeeds4Dp67AZE9LY5uWW5zrbm8ugCYn5BJ6GXFdZiZkDgkAPPPvQkTTZxzjLj3LsabF8Zz96kkcmXZf4phyUskWZYSNW3TpKjqF -value 50000.0 -fee 1.0
Result:
status: success
tx_hash: 0x075051A67F29290D73192C13685D173C1017A973DC5E0AC7DFDA0AB3CF60AAE9
After creating a transaction, it will have only one signature, provided by the creator’s wallet.
We need to add remaining signatures to match -signs_minimum
value from EMIT_DELEGATE HOLD
transaction.
It can be done via the EMIT_DELEGATE SIGN
command.
Command syntax:
emit_delegate sign
-net <net_name>
-w <wallet_name>
-tx <transaction_hash>
[-chain <chain_name>]
[-H {hex(default) | base58}]
Options:
-net - name of the Cellframe Network. The list of networks can be found in the <Config_dir> \ etc \ network folder or received by The Cellframe-Node-CLI using command - net list
-w - the name of the signing wallet
-tx - hash of the debit transaction
-chain - name of the preferred chain where transaction will be put: zerochain or mainchain (optional)
-H - hash format: HEX or base58 (optional)
Command example:
cellframe-node-cli emit_delegate sign -net raiden -w third_wallet -tx 0x075051A67F29290D73192C13685D173C1017A973DC5E0AC7DFDA0AB3CF60AAE9
Result:
status: success
tx_hash: 0x61B12392FDD90D9A8247DFC7EDDF85DF18CC372240769EE78DC521BDF3B659AF
Once a transaction is processed, tokens are sent to the destination address and the amount of remaining funds on the conditional OUT has decreased.
Let’s check that.
Command:
cellframe-node-cli tx_history -tx 0x61B12392FDD90D9A8247DFC7EDDF85DF18CC372240769EE78DC521BDF3B659AF -net raiden
Take a look at items OUT and OUT COND.
item type: OUT
Coins: 50000.0
Value: 50000000000000000000000
Address: jrmnGqeeds4Dp67AZE9LY5uWW5zrbm8ugCYn5BJ6GXFdZiZkDgkAPPPvQkTTZxzjLj3LsabF8Zz96kkcmXZf4phyUskWZYSNW3TpKjqF
item type: OUT COND
ts_expires: never
coins: 850000.0
value: 850000000000000000000000
subtype: DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_EMIT_DELEGATE
uid: 0x0000000000000007
tsd_size: 114
Coins (value) on the conditional OUT of DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_EMIT_DELEGATE
subtype have decreased from 900000 to 850000.
Interaction
How to interact with shared funds conditional OUT?
In all subsequent transactions debiting transactions, any hash of the previously created transactions that contain conditional OUT can be used.
Note
In all subsequent transactions debiting transactions, any hash of the previously created transactions that contain conditional OUT can be used.
Here are two more examples:
- Debit funds using the hash of the original transaction.
- Debit funds using the hash of subsequent debit transaction.
First Example
Creating a transaction to debit funds:
Hash of the original transaction - 0x608FD1A636FD6F1C35A454B268115AF939732D0E8F9D6F8B95A35C2014AABC4D
.
cellframe-node-cli emit_delegate take -net raiden -w third_wallet -tx 0x608FD1A636FD6F1C35A454B268115AF939732D0E8F9D6F8B95A35C2014AABC4D -addr_to jrmnGqeeds4Dp67AZE9LY5uWW5zrbm8ugCYn5BJ6GXFdZiZkDgkAPPPvQkTTZxzjLj3LsabF8Zz96kkcmXZf4phyUskWZYSNW3TpKjqF -value 500.0 -fee 1.0
Result:
status: success
tx_hash: 0xC2C0E5F9BF4BE7D81F4C9E1B9568262B24920DCC100374989AF3C192B8C93AC1
Adding a second sign:
cellframe-node-cli emit_delegate sign -net raiden -w second_wallet -tx 0xC2C0E5F9BF4BE7D81F4C9E1B9568262B24920DCC100374989AF3C192B8C93AC1
Result:
status: success
tx_hash: 0x0D21733CE3036987F34951AEA59AC47D2D09197DFB2D08723A798B01DC799F9E
Relevant transaction OUT’s after it is processed:
cellframe-node-cli tx_history -tx 0x0D21733CE3036987F34951AEA59AC47D2D09197DFB2D08723A798B01DC799F9E -net raiden
Result:
item type: OUT (1)
Coins: 500.0
Value: 500000000000000000000
Address: jrmnGqeeds4Dp67AZE9LY5uWW5zrbm8ugCYn5BJ6GXFdZiZkDgkAPPPvQkTTZxzjLj3LsabF8Zz96kkcmXZf4phyUskWZYSNW3TpKjqF
item type: OUT COND (2)
ts_expires: never
coins: 849500.0
value: 849500000000000000000000
subtype: DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_EMIT_DELEGATE
uid: 0x0000000000000007
tsd_size: 114
Second Example
Creating a transaction to debit funds:
Hash of the subsequent transaction - 0x61B12392FDD90D9A8247DFC7EDDF85DF18CC372240769EE78DC521BDF3B659AF
.
cellframe-node-cli emit_delegate take -net raiden -w second_wallet -tx 0x61B12392FDD90D9A8247DFC7EDDF85DF18CC372240769EE78DC521BDF3B659AF -addr_to jrmnGqeeds4Dp67AZE9LY5uWW5zrbm8ugCYn5BJ6GXFdZiZkDgkAPPPvQkTTZxzjLj3LsabF8Zz96kkcmXZf4phyUskWZYSNW3TpKjqF -value 200.0 -fee 1.0
Result:
status: success
tx_hash: 0x3074E8768F374FA42BA68FC997E683443F5FACC142859032EF91C6CE3753F73F
Adding a second sign:
cellframe-node-cli emit_delegate sign -net raiden -w third_wallet -tx 0x3074E8768F374FA42BA68FC997E683443F5FACC142859032EF91C6CE3753F73F
Result:
status: success
tx_hash: 0xCD944B7E2BED8A7A0501A1DF27C7BB27744911ED8BD720A281EAF77B60749A37
Relevant transaction OUTs after it is processed:
cellframe-node-cli tx_history -tx 0xCD944B7E2BED8A7A0501A1DF27C7BB27744911ED8BD720A281EAF77B60749A37 -net raiden
Result:
item type: OUT (1)
Coins: 200.0
Value: 200000000000000000000
Address: jrmnGqeeds4Dp67AZE9LY5uWW5zrbm8ugCYn5BJ6GXFdZiZkDgkAPPPvQkTTZxzjLj3LsabF8Zz96kkcmXZf4phyUskWZYSNW3TpKjqF
item type: OUT COND (2)
ts_expires: never
coins: 849300.0
value: 849300000000000000000000
subtype: DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_EMIT_DELEGATE
uid: 0x0000000000000007
tsd_size: 114
As we can see, conditional OUT displays correct balance.