Skip to content

Conversation

@ClemensLey
Copy link
Contributor

No description provided.

In a Bitcoin Computer transaction, a JavaScript expression is embedded within a standard Bitcoin transaction. The result of evaluating this expression is linked to an output. If the result contains objects, each of these objects is assigned to a separate output.

If the expression contains a free variable (for example the variable `x` is free in the expression `x + 1`), then that free variable has to be associated with an input of the transaction. To determine the values of the outputs, the Bitcoin Computer recursively determines the values of each output spent. The free variable is then substituted with the value before the expression is evaluated.
For expressions with an undefined variable (for example, the variable x is undefined in the expression x + 1), the smart contract developer can associate that variables with an input of the transaction. The Bitcoin Computer then recursively calculates the values of these outputs, and replaces the undefined variables with their computed values from previous transactions to evaluate the expression.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revisit quotes

Consider a transaction with the expression `1+2` inscribed. As this expression evaluates to `3`, the Bitcoin Computer will associate the first output with the value `3`.

If this output is spent by a transaction with an inscription `x+4` and the first input is associated with `x`, the Bitcoin Computer determines the value of the output spent by that input. In the example that output has the value `3`. Hence, the output of the second transaction has the value `7`.
In this example, the transaction is inscribed with the arithmetic expression 1+2, which evaluates to 3. This value is then associated with the transaction’s first output. In a subsequent transaction, an expression x+4 uses this output's value as its variable “x”. Given that the output from the first transaction was 3, the expression in the second transaction evaluates to 7, and this new value is assigned to its output. This demonstrates how values can be propagated and transformed across transactions in the Bitcoin Computer system.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revisit quotes

@ltardivo ltardivo merged commit dbaf81d into main Aug 16, 2024
@ltardivo ltardivo deleted the ian-comments-1 branch August 16, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants