How It Works

The Arch Network employs an innovative approach to state management on Bitcoin's layer 1, utilizing ordinals through a unique 'state chaining' process, state changes are committed in a single transaction, reducing fees and ensuring atomic execution.

What is 'State Chaining'

The UTXO securely maintains the state within smart contract addresses, separating it from execution for enhanced efficiency and security. The decoupling of state and execution allows for more expressive smart contracts, fostering a flexible development environment.

The protocol implements a prover-verifier model, where serialized smart contract transactions wait in a pool for execution. Provers retrieve and execute transactions, generating receipts that verifiers validate using a threshold signature mechanism, similar to a proof-of-stake model.

Decoupled State and Execution: This design choice allows for more expressive smart contracts and innovative use cases, fostering a flexible development environment.

Zero-Knowledge Virtual Machine (ZKVM) Utilization: Arch Network leverages RISC Zero, a leading general-purpose ZKVM, functioning like a RISC-V microprocessor and supporting languages like Rust, C, and C++.

Contract-Specific Keys: Each contract has unique keys to prevent vulnerabilities, with a random keypair generated upon deployment, ensuring that contracts don't share keys and maintain their integrity.

Transaction Journey

Step 1: The invocation of the smart contract occurs via a Bitcoin transaction encompassing essential information for execution, including the latest state, Partially Signed Bitcoin Transaction (PSBT), and smart contract input.

An Arch Indexer, constantly listening for new bitcoin blocks, checks each transaction in the new bitcoin block to see if it fits within this invocation format:

OP_FALSE
OP_IF
  OP_PUSH "arch"
  OP_PUSH "state"
  OP_PUSH "insert_state_string_here"
  OP_PUSH "psbt"
  OP_PUSH "insert_base64_psbt_string_here"
  OP_PUSH "inputs"
  OP_PUSH "insert_stringified_input_json"
OP_ENDIF

Step 2: Upon detection of said transaction, Arch deciphers the pertinent details and proceeds with smart contract execution. Subsequently, the smart contract produces a resulting state and an unsigned transaction, reflecting asset transfers from the execution, along with proof validating the smart contract execution.

Step 3: Everything is transmitted to the verifier network, specifically to a leader node. During each Arch Epoch, a leader is randomly chosen based on stake. The leader node disseminates the received information to all other nodes within the network.

Step 4: Each node undertakes the verification of the proof and incorporates the state change into the transaction before endorsing said transaction. The leader consolidates signatures from these nodes until reaching a predefined threshold.

Step 5: Once the transaction is signed by the requisite number of nodes, it can be broadcasted across the Bitcoin network.

Example: Borrower takes loan against his Bitcoin Frog

Signed Smart Contract Transaction:

State Info before Signed Smart Contract Transaction:


{
    "id":"5ba59eca41925d020feb370ab1405d9afc26f4dfcfdaac2ff68d181432c0b81b",
    "data":{
        "utxo":{
            "txid":"bf39e253fed74ead7cc7b679a7e90464a5c27e013d4aab3026c49b1bca62bf88",
            "vout":1,
            "value":1000,
            "owner":"tb1pl02mqcgmzge4837fvevtw3mjh5wcdhlumcgevv8q3q4p0kefe4jskyca6r"
        },
        "loan_value":1100,
        "loan_period":2592000,
        "lender_ordinals_address":"tb1pgkjr6r8apfvdm5fk6xk0vryrhzea5pv8rvn2vt34lsx65tclvp4sfn0hz2",
        "lender_payments_address":"2MzcAVUFfHb1ni46AXCn5z7ADQKrKvz52nn",
        "collection":"frogs",
        "inscription":null,
        "borrower_ordinals_address":null,
        "borrower_payments_address":null,
        "loan_started_at":null
    },
    "utxo":{
        "txid":"5ba59eca41925d020feb370ab1405d9afc26f4dfcfdaac2ff68d181432c0b81b",
        "vout":0,
        "value":500,
        "owner":"tb1pl02mqcgmzge4837fvevtw3mjh5wcdhlumcgevv8q3q4p0kefe4jskyca6r"
    }
}

State Info after Signed Smart Contract Transaction:

{
    "id":"5ba59eca41925d020feb370ab1405d9afc26f4dfcfdaac2ff68d181432c0b81b",
    "data":{
        "utxo":{
            "txid":"bf39e253fed74ead7cc7b679a7e90464a5c27e013d4aab3026c49b1bca62bf88",
            "vout":1,
            "value":1000,
            "owner":
            "tb1pl02mqcgmzge4837fvevtw3mjh5wcdhlumcgevv8q3q4p0kefe4jskyca6r"
        },
        "loan_value":1100,
        "loan_period":2592000,
        "lender_ordinals_address":"tb1pgkjr6r8apfvdm5fk6xk0vryrhzea5pv8rvn2vt34lsx65tclvp4sfn0hz2",
        "lender_payments_address":"2MzcAVUFfHb1ni46AXCn5z7ADQKrKvz52nn",
        "collection":"frogs",
        "inscription": {
            "inscription_id":"39a97675c3468f72bfd739108890e3041d623c2e54913eebd00cf689d6aa26e2i0",
            "utxo":{
                "txid":"4fefcb0b026047b868a20b87bcbdcc1a1fb76ae96b58dee969a52253d2317094",
                "vout":0,
                "value":500,
                "owner":"tb1pl02mqcgmzge4837fvevtw3mjh5wcdhlumcgevv8q3q4p0kefe4jskyca6r"
            }
        },
        "borrower_ordinals_address":"tb1pgkjr6r8apfvdm5fk6xk0vryrhzea5pv8rvn2vt34lsx65tclvp4sfn0hz2",
        "borrower_payments_address":"2MzcAVUFfHb1ni46AXCn5z7ADQKrKvz52nn",
        "loan_started_at":1707568045
    },
    "utxo": {
        "txid":"7eb471480aa8926c186519629baa462cd9046ce326a0047406a10d583a364f6a",
        "vout":0,
        "value":500,
        "owner":"tb1pl02mqcgmzge4837fvevtw3mjh5wcdhlumcgevv8q3q4p0kefe4jskyca6r"
    }
}

Last updated