(these are written quickly in 10min, many aspects are not well elaborated, would be expanded into an article later, Lorenzo on 2024-05-28)
I had an interview explaining details of the first rabbit hole:
For the second, please refer to the open source implementation of brc20-swap the contract: https://github.com/brc20-devs/brc20-swap-contract the indexer: https://github.com/brc20-devs/brc20-swap-indexer the sequencer: https://github.com/brc20-devs/brc20-swap-sequencer-api
"the difference is it's protected by Ordinals indexers not nodes (strong consensus)"
could you explain this further please?
contracts on EVM are validated and executed by Ethereum nodes (the first-class consensus of a given blockchain). invalid contract is rejected and doesn't get the chance to the blocks.
contracts in inscriptions are validated and executed by Ordinals/brc-20 indexers (BestInSlots/OPI, UniSat, OKX, Nubit, etc..), not bitcoin nodes (1st-class consensus on bitcoin). Invalid contracts still get their ways into blocks as valid bitcoin transactions, but they will be invalidated by indexers like mis-typed brc-20 mintings as bad mintings.
The second-class consensus is weaker than the first one as it cannot prevent the ill inscriptions from getting into blocks. But it still works reliably for protocols like brc-20 and runes, by maintaining a shared consensus/ruleset between hundreds of indexing instances. It also provides additional level of flexibility that allows us to program in different languages (for example we use TypeScript in brc20-swap contracts, source code shared above) with a versatile execution environment.