archethic-foundation / archethic-foundation/archethic-node

Add hooks to UTXO to make them smart

Open
#304 2 comments 0 reactions 0 assignees View on GitHub
core team feature mining smart contracts transaction
Dominant language
Elixir
Stars
82
Forks
24
PR merge metrics
No merged PRs in 30d

Description

### Problem to solve

UTXO allows the sending of assets natively without involving much more complexity such as smart contract.
Because once a UTXO is consumed, it's sent to a recipient, a creator or initiator loose track of its assets and any further behavior on the transmission (opposite to account model where a single contract register all the interactions)

So we have to provide a mechanism to trigger a behavior when they are consumed or sent.
Here comes the idea of a `hook` concept, which is triggered when an event comes.

This is particular true for NFT and royalties

Here a. bigger explanation : https://github.com/archethic-foundation/archethic-docs/issues/7

### Solution

The idea is to integrate a new field in the ledger transfers and UTXO data structure to embrace this concept of hook.
So any transaction and any transfer of assets can embed an arbitrary code to execute which will be triggered when the UTXO is spent.

This will involve:
- [ ] Update of the UTXO structure to add a field: `hook`
- [ ] Update of the Ledger transfers structures to a field: `hook`
- [ ] Validation of the hook's code in the ledger transfer
- [ ] Update the smart contract interpreter to define a new set of instructions by passing the `actions` and `conditions` blocks
- [ ] Handle the execution of the hook's code during the transaction validation by the coordinator and verification by the cross validation nodes

---

Epic: #305

Contributor guide

Open the contributing guide

Research direction

Start by reading the UTXO and ledger transfer structures, then trace the smart contract interpreter and transaction validation paths. Review the linked documentation issue for the hook concept; done means hooks are represented, validated, and executed consistently by the coordinator and cross-validation nodes as listed in the checklist.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
blockchain
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.