@btc-vision/btc-runtime 1.11.0-rc.9 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/docs/README.md +39 -39
- package/docs/advanced/bitcoin-scripts.md +17 -17
- package/docs/advanced/{contract-upgrades.md → contract-updates.md} +90 -98
- package/docs/advanced/cross-contract-calls.md +4 -4
- package/docs/advanced/plugins.md +21 -21
- package/docs/advanced/quantum-resistance.md +32 -32
- package/docs/advanced/signature-verification.md +22 -22
- package/docs/api-reference/blockchain.md +14 -14
- package/docs/api-reference/events.md +2 -2
- package/docs/api-reference/op20.md +7 -7
- package/docs/api-reference/op721.md +7 -7
- package/docs/api-reference/storage.md +2 -2
- package/docs/contracts/op-net-base.md +15 -15
- package/docs/contracts/op20-token.md +3 -3
- package/docs/contracts/op20s-signatures.md +2 -2
- package/docs/contracts/op721-nft.md +3 -3
- package/docs/contracts/reentrancy-guard.md +5 -7
- package/docs/contracts/updatable.md +384 -0
- package/docs/core-concepts/blockchain-environment.md +10 -10
- package/docs/core-concepts/decorators.md +5 -5
- package/docs/core-concepts/events.md +6 -6
- package/docs/core-concepts/pointers.md +5 -5
- package/docs/core-concepts/security.md +5 -5
- package/docs/core-concepts/storage-system.md +24 -24
- package/docs/examples/basic-token.md +8 -8
- package/docs/examples/nft-with-reservations.md +9 -9
- package/docs/examples/oracle-integration.md +13 -13
- package/docs/examples/stablecoin.md +10 -10
- package/docs/getting-started/first-contract.md +8 -8
- package/docs/getting-started/installation.md +2 -2
- package/docs/getting-started/project-structure.md +6 -6
- package/docs/storage/memory-maps.md +8 -8
- package/docs/storage/stored-arrays.md +6 -6
- package/docs/storage/stored-maps.md +8 -8
- package/docs/storage/stored-primitives.md +6 -6
- package/docs/types/address.md +13 -13
- package/docs/types/bytes-writer-reader.md +18 -18
- package/docs/types/calldata.md +12 -12
- package/package.json +10 -10
- package/runtime/constants/Exports.ts +0 -30
- package/runtime/contracts/OP20.ts +7 -7
- package/runtime/contracts/OP721.ts +60 -74
- package/runtime/contracts/OP_NET.ts +2 -2
- package/runtime/contracts/ReentrancyGuard.ts +1 -5
- package/runtime/contracts/Updatable.ts +241 -0
- package/runtime/contracts/interfaces/OP721InitParameters.ts +8 -8
- package/runtime/env/BlockchainEnvironment.ts +5 -5
- package/runtime/env/global.ts +7 -6
- package/runtime/events/predefined/{ApprovedEvent.ts → OP20ApprovedEvent.ts} +1 -1
- package/runtime/events/predefined/{BurnedEvent.ts → OP20BurnedEvent.ts} +1 -1
- package/runtime/events/predefined/{MintedEvent.ts → OP20MintedEvent.ts} +1 -1
- package/runtime/events/predefined/{TransferredEvent.ts → OP20TransferredEvent.ts} +1 -1
- package/runtime/events/predefined/OP721ApprovedEvent.ts +17 -0
- package/runtime/events/predefined/{ApprovedForAll.ts → OP721ApprovedForAllEvent.ts} +1 -1
- package/runtime/events/predefined/OP721BurnedEvent.ts +16 -0
- package/runtime/events/predefined/OP721MintedEvent.ts +16 -0
- package/runtime/events/predefined/OP721TransferredEvent.ts +18 -0
- package/runtime/events/predefined/index.ts +5 -5
- package/runtime/events/{upgradeable/UpgradeableEvents.ts → updatable/UpdatableEvents.ts} +9 -9
- package/runtime/hashing/keccak256.ts +1 -1
- package/runtime/index.ts +3 -5
- package/runtime/plugins/UpdatablePlugin.ts +276 -0
- package/runtime/script/Networks.ts +1 -1
- package/runtime/storage/StoredBoolean.ts +23 -12
- package/runtime/types/Address.ts +1 -1
- package/runtime/types/ExtendedAddress.ts +1 -1
- package/docs/contracts/upgradeable.md +0 -396
- package/runtime/contracts/Upgradeable.ts +0 -242
- package/runtime/contracts/interfaces/IOP1155.ts +0 -33
- package/runtime/contracts/interfaces/OP1155InitParameters.ts +0 -11
- package/runtime/plugins/UpgradeablePlugin.ts +0 -279
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OP_NET Smart Contract Runtime
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
## Overview
|
|
13
13
|
|
|
14
|
-
The
|
|
14
|
+
The OP_NET Smart Contract Runtime is the framework for building decentralized applications on Bitcoin L1. Written in AssemblyScript and compiled to WebAssembly, it enables smart contract development on Bitcoin with similar expressiveness to Solidity.
|
|
15
15
|
|
|
16
|
-
Unlike Bitcoin Layer 2 solutions,
|
|
16
|
+
Unlike Bitcoin Layer 2 solutions, OP_NET operates directly on Bitcoin's base layer, inheriting Bitcoin's security guarantees and decentralization properties while adding programmable smart contract capabilities.
|
|
17
17
|
|
|
18
|
-
> **What is
|
|
18
|
+
> **What is OP_NET?**
|
|
19
19
|
>
|
|
20
|
-
>
|
|
20
|
+
> OP_NET (Open Protocol Network) is a consensus-layer built on Bitcoin L1. It allows developers to write smart contracts in AssemblyScript or similar that compile to WebAssembly (WASM) and execute deterministically across all network nodes. Think of it as "Solidity for Bitcoin" - you get the programmability of Ethereum with the security of Bitcoin.
|
|
21
21
|
|
|
22
22
|
> **Why AssemblyScript?**
|
|
23
23
|
>
|
|
@@ -88,7 +88,7 @@ export class MyToken extends OP20 {
|
|
|
88
88
|
|
|
89
89
|
## Solidity Comparison
|
|
90
90
|
|
|
91
|
-
| Solidity/EVM |
|
|
91
|
+
| Solidity/EVM | OP_NET/btc-runtime |
|
|
92
92
|
|-----------------------------|-------------------------------------------|
|
|
93
93
|
| `contract MyContract` | `class MyContract extends OP_NET` |
|
|
94
94
|
| `constructor()` | `onDeployment(calldata)` |
|
|
@@ -138,7 +138,7 @@ See the [pull request template](./.github/PULL_REQUEST_TEMPLATE.md) for requirem
|
|
|
138
138
|
|
|
139
139
|
## Links
|
|
140
140
|
|
|
141
|
-
- [
|
|
141
|
+
- [OP_NET](https://opnet.org)
|
|
142
142
|
- [Documentation](./docs/)
|
|
143
143
|
- [GitHub](https://github.com/btc-vision/btc-runtime)
|
|
144
144
|
- [npm](https://www.npmjs.com/package/@btc-vision/btc-runtime)
|
package/docs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Documentation
|
|
2
2
|
|
|
3
|
-
Welcome to the comprehensive documentation for **@btc-vision/btc-runtime**, the
|
|
3
|
+
Welcome to the comprehensive documentation for **@btc-vision/btc-runtime**, the OP_NET Smart Contract Runtime for Bitcoin L1.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -98,7 +98,7 @@ npm run build:token
|
|
|
98
98
|
- [Pointer System](./core-concepts/storage-system.md#pointer-system)
|
|
99
99
|
- [Storage Types](./core-concepts/storage-system.md#storage-types)
|
|
100
100
|
- [Reading and Writing](./core-concepts/storage-system.md#reading-and-writing)
|
|
101
|
-
- [Solidity vs
|
|
101
|
+
- [Solidity vs OP_NET Comparison](./core-concepts/storage-system.md#solidity-vs-opnet-comparison)
|
|
102
102
|
- [Best Practices](./core-concepts/storage-system.md#best-practices)
|
|
103
103
|
|
|
104
104
|
#### [Pointers](./core-concepts/pointers.md)
|
|
@@ -261,7 +261,7 @@ npm run build:token
|
|
|
261
261
|
|
|
262
262
|
#### [ReentrancyGuard](./contracts/reentrancy-guard.md)
|
|
263
263
|
- [Overview](./contracts/reentrancy-guard.md#overview)
|
|
264
|
-
- [OpenZeppelin vs
|
|
264
|
+
- [OpenZeppelin vs OP_NET ReentrancyGuard](./contracts/reentrancy-guard.md#openzeppelin-vs-opnet-reentrancyguard)
|
|
265
265
|
- [What is Reentrancy?](./contracts/reentrancy-guard.md#what-is-reentrancy)
|
|
266
266
|
- [The Attack](./contracts/reentrancy-guard.md#the-attack)
|
|
267
267
|
- [The Defense](./contracts/reentrancy-guard.md#the-defense)
|
|
@@ -285,17 +285,17 @@ npm run build:token
|
|
|
285
285
|
- [Common Mistakes](./contracts/reentrancy-guard.md#common-mistakes)
|
|
286
286
|
- [Testing Reentrancy](./contracts/reentrancy-guard.md#testing-reentrancy)
|
|
287
287
|
|
|
288
|
-
#### [
|
|
289
|
-
- [Overview](./contracts/
|
|
290
|
-
- [Class Reference](./contracts/
|
|
291
|
-
- [Properties](./contracts/
|
|
292
|
-
- [Methods](./contracts/
|
|
293
|
-
- [Events](./contracts/
|
|
294
|
-
- [Usage Patterns](./contracts/
|
|
295
|
-
- [Security Considerations](./contracts/
|
|
296
|
-
- [
|
|
297
|
-
- [Combining with Other Base Classes](./contracts/
|
|
298
|
-
- [Solidity Comparison](./contracts/
|
|
288
|
+
#### [Updatable](./contracts/updatable.md)
|
|
289
|
+
- [Overview](./contracts/updatable.md#overview)
|
|
290
|
+
- [Class Reference](./contracts/updatable.md#class-reference)
|
|
291
|
+
- [Properties](./contracts/updatable.md#properties)
|
|
292
|
+
- [Methods](./contracts/updatable.md#methods)
|
|
293
|
+
- [Events](./contracts/updatable.md#events)
|
|
294
|
+
- [Usage Patterns](./contracts/updatable.md#usage-patterns)
|
|
295
|
+
- [Security Considerations](./contracts/updatable.md#security-considerations)
|
|
296
|
+
- [Update Workflow](./contracts/updatable.md#update-workflow)
|
|
297
|
+
- [Combining with Other Base Classes](./contracts/updatable.md#combining-with-other-base-classes)
|
|
298
|
+
- [Solidity Comparison](./contracts/updatable.md#solidity-comparison)
|
|
299
299
|
|
|
300
300
|
---
|
|
301
301
|
|
|
@@ -307,7 +307,7 @@ npm run build:token
|
|
|
307
307
|
- [Address Comparison](./types/address.md#address-comparison)
|
|
308
308
|
- [Special Addresses](./types/address.md#special-addresses)
|
|
309
309
|
- [Address Methods](./types/address.md#address-methods)
|
|
310
|
-
- [Solidity vs
|
|
310
|
+
- [Solidity vs OP_NET Comparison](./types/address.md#solidity-vs-opnet-comparison)
|
|
311
311
|
- [Best Practices](./types/address.md#best-practices)
|
|
312
312
|
|
|
313
313
|
#### [SafeMath](./types/safe-math.md)
|
|
@@ -322,14 +322,14 @@ npm run build:token
|
|
|
322
322
|
- [Reading Values](./types/calldata.md#reading-values)
|
|
323
323
|
- [Reading Arrays](./types/calldata.md#reading-arrays)
|
|
324
324
|
- [Reading Complex Types](./types/calldata.md#reading-complex-types)
|
|
325
|
-
- [Solidity vs
|
|
325
|
+
- [Solidity vs OP_NET Comparison](./types/calldata.md#solidity-vs-opnet-comparison)
|
|
326
326
|
- [Best Practices](./types/calldata.md#best-practices)
|
|
327
327
|
|
|
328
328
|
#### [BytesWriter/Reader](./types/bytes-writer-reader.md)
|
|
329
329
|
- [Overview](./types/bytes-writer-reader.md#overview)
|
|
330
330
|
- [BytesWriter](./types/bytes-writer-reader.md#byteswriter)
|
|
331
331
|
- [BytesReader](./types/bytes-writer-reader.md#bytesreader)
|
|
332
|
-
- [Solidity vs
|
|
332
|
+
- [Solidity vs OP_NET Comparison](./types/bytes-writer-reader.md#solidity-vs-opnet-comparison)
|
|
333
333
|
- [Migration Patterns](./types/bytes-writer-reader.md#migration-patterns)
|
|
334
334
|
- [Best Practices](./types/bytes-writer-reader.md#best-practices)
|
|
335
335
|
|
|
@@ -354,7 +354,7 @@ npm run build:token
|
|
|
354
354
|
- [Initialization](./storage/stored-primitives.md#initialization)
|
|
355
355
|
- [Default Values](./storage/stored-primitives.md#default-values)
|
|
356
356
|
- [Setting Initial Values](./storage/stored-primitives.md#setting-initial-values)
|
|
357
|
-
- [Solidity vs
|
|
357
|
+
- [Solidity vs OP_NET Comparison](./storage/stored-primitives.md#solidity-vs-opnet-comparison)
|
|
358
358
|
- [Side-by-Side Code Examples](./storage/stored-primitives.md#side-by-side-code-examples)
|
|
359
359
|
- [Counter Contract](./storage/stored-primitives.md#counter-contract)
|
|
360
360
|
- [Ownable Contract](./storage/stored-primitives.md#ownable-contract)
|
|
@@ -375,7 +375,7 @@ npm run build:token
|
|
|
375
375
|
- [Get](./storage/stored-arrays.md#get)
|
|
376
376
|
- [Set](./storage/stored-arrays.md#set)
|
|
377
377
|
- [Length](./storage/stored-arrays.md#length)
|
|
378
|
-
- [Solidity vs
|
|
378
|
+
- [Solidity vs OP_NET Comparison](./storage/stored-arrays.md#solidity-vs-opnet-comparison)
|
|
379
379
|
- [Side-by-Side Code Examples](./storage/stored-arrays.md#side-by-side-code-examples)
|
|
380
380
|
- [Simple Address List](./storage/stored-arrays.md#simple-address-list)
|
|
381
381
|
- [Value Queue (FIFO-like with array)](./storage/stored-arrays.md#value-queue-fifo-like-with-array)
|
|
@@ -399,7 +399,7 @@ npm run build:token
|
|
|
399
399
|
- [Nested Maps](./storage/stored-maps.md#nested-maps)
|
|
400
400
|
- [MapOfMap](./storage/stored-maps.md#mapofmap)
|
|
401
401
|
- [MapOfMap Get/Set Pattern](./storage/stored-maps.md#mapofmap-getset-pattern)
|
|
402
|
-
- [Solidity vs
|
|
402
|
+
- [Solidity vs OP_NET Comparison](./storage/stored-maps.md#solidity-vs-opnet-comparison)
|
|
403
403
|
- [Side-by-Side Code Examples](./storage/stored-maps.md#side-by-side-code-examples)
|
|
404
404
|
- [Simple Key-Value Store](./storage/stored-maps.md#simple-key-value-store)
|
|
405
405
|
- [Approval System with Nested Mapping](./storage/stored-maps.md#approval-system-with-nested-mapping)
|
|
@@ -417,7 +417,7 @@ npm run build:token
|
|
|
417
417
|
- [Methods](./storage/memory-maps.md#methods)
|
|
418
418
|
- [Storage Flow](./storage/memory-maps.md#storage-flow)
|
|
419
419
|
- [Address to Storage Key](./storage/memory-maps.md#address-to-storage-key)
|
|
420
|
-
- [Solidity vs
|
|
420
|
+
- [Solidity vs OP_NET Comparison](./storage/memory-maps.md#solidity-vs-opnet-comparison)
|
|
421
421
|
- [Side-by-Side Code Examples](./storage/memory-maps.md#side-by-side-code-examples)
|
|
422
422
|
- [Basic Token Balance Tracking](./storage/memory-maps.md#basic-token-balance-tracking)
|
|
423
423
|
- [Staking Contract](./storage/memory-maps.md#staking-contract)
|
|
@@ -470,7 +470,7 @@ npm run build:token
|
|
|
470
470
|
- [Schnorr Signatures](./advanced/signature-verification.md#schnorr-signatures)
|
|
471
471
|
- [ML-DSA Signatures](./advanced/signature-verification.md#ml-dsa-signatures)
|
|
472
472
|
- [Verification API](./advanced/signature-verification.md#verification-api)
|
|
473
|
-
- [Solidity vs
|
|
473
|
+
- [Solidity vs OP_NET Comparison](./advanced/signature-verification.md#solidity-vs-opnet-comparison)
|
|
474
474
|
- [Best Practices](./advanced/signature-verification.md#best-practices)
|
|
475
475
|
|
|
476
476
|
#### [Quantum Resistance](./advanced/quantum-resistance.md)
|
|
@@ -479,7 +479,7 @@ npm run build:token
|
|
|
479
479
|
- [Security Levels](./advanced/quantum-resistance.md#security-levels)
|
|
480
480
|
- [The Address Class](./advanced/quantum-resistance.md#the-address-class)
|
|
481
481
|
- [Migration Path](./advanced/quantum-resistance.md#migration-path)
|
|
482
|
-
- [Solidity vs
|
|
482
|
+
- [Solidity vs OP_NET Comparison](./advanced/quantum-resistance.md#solidity-vs-opnet-comparison)
|
|
483
483
|
- [Best Practices](./advanced/quantum-resistance.md#best-practices)
|
|
484
484
|
|
|
485
485
|
#### [Bitcoin Scripts](./advanced/bitcoin-scripts.md)
|
|
@@ -496,22 +496,22 @@ npm run build:token
|
|
|
496
496
|
- [CSV (CheckSequenceVerify)](./advanced/bitcoin-scripts.md#csv-checksequenceverify)
|
|
497
497
|
- [CLTV (CheckLockTimeVerify)](./advanced/bitcoin-scripts.md#cltv-checklockimeverify)
|
|
498
498
|
- [Script Analysis](./advanced/bitcoin-scripts.md#script-analysis)
|
|
499
|
-
- [Solidity vs
|
|
499
|
+
- [Solidity vs OP_NET Comparison](./advanced/bitcoin-scripts.md#solidity-vs-opnet-comparison)
|
|
500
500
|
- [Best Practices](./advanced/bitcoin-scripts.md#best-practices)
|
|
501
501
|
|
|
502
|
-
#### [Contract
|
|
503
|
-
- [Overview](./advanced/
|
|
504
|
-
- [How It Works](./advanced/
|
|
505
|
-
- [Basic Usage](./advanced/
|
|
506
|
-
- [The Timelock Pattern](./advanced/
|
|
507
|
-
- [Why Use a Timelock?](./advanced/
|
|
508
|
-
- [Using the
|
|
509
|
-
- [Using the
|
|
510
|
-
- [Storage Compatibility](./advanced/
|
|
511
|
-
- [Security Considerations](./advanced/
|
|
512
|
-
- [Comparison with Other Platforms](./advanced/
|
|
513
|
-
- [Complete Example](./advanced/
|
|
514
|
-
- [
|
|
502
|
+
#### [Contract Updates](./advanced/updatable)
|
|
503
|
+
- [Overview](./advanced/updatable#overview)
|
|
504
|
+
- [How It Works](./advanced/updatable#how-it-works)
|
|
505
|
+
- [Basic Usage](./advanced/updatable#basic-usage)
|
|
506
|
+
- [The Timelock Pattern](./advanced/updatable#the-timelock-pattern)
|
|
507
|
+
- [Why Use a Timelock?](./advanced/updatable#why-use-a-timelock)
|
|
508
|
+
- [Using the Updatable Base Class](./advanced/updatable#using-the-updatable-base-class)
|
|
509
|
+
- [Using the UpdatablePlugin](./advanced/updatable#using-the-updatableplugin)
|
|
510
|
+
- [Storage Compatibility](./advanced/updatable#storage-compatibility)
|
|
511
|
+
- [Security Considerations](./advanced/updatable#security-considerations)
|
|
512
|
+
- [Comparison with Other Platforms](./advanced/updatable#comparison-with-other-platforms)
|
|
513
|
+
- [Complete Example](./advanced/updatable#complete-example)
|
|
514
|
+
- [Update Workflow](./advanced/updatable#update-workflow)
|
|
515
515
|
|
|
516
516
|
#### [Plugins](./advanced/plugins.md)
|
|
517
517
|
- [Overview](./advanced/plugins.md#overview)
|
|
@@ -524,7 +524,7 @@ npm run build:token
|
|
|
524
524
|
- [onExecutionCompleted](./advanced/plugins.md#onexecutioncompleted)
|
|
525
525
|
- [execute](./advanced/plugins.md#execute)
|
|
526
526
|
- [Built-in Plugins](./advanced/plugins.md#built-in-plugins)
|
|
527
|
-
- [Solidity vs
|
|
527
|
+
- [Solidity vs OP_NET Comparison](./advanced/plugins.md#solidity-vs-opnet-comparison)
|
|
528
528
|
- [Best Practices](./advanced/plugins.md#best-practices)
|
|
529
529
|
|
|
530
530
|
---
|
|
@@ -632,7 +632,7 @@ npm run build:token
|
|
|
632
632
|
|
|
633
633
|
- [Example Tokens Repository](https://github.com/btc-vision/example-tokens)
|
|
634
634
|
- [btc-runtime Repository](https://github.com/btc-vision/btc-runtime)
|
|
635
|
-
- [
|
|
635
|
+
- [OP_NET Website](https://opnet.org)
|
|
636
636
|
|
|
637
637
|
## Solidity Developer?
|
|
638
638
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Bitcoin Scripts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OP_NET provides utilities for working with Bitcoin scripts, addresses, and timelocks. This enables contracts to interact with Bitcoin's native scripting capabilities.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
|
|
21
21
|
## Networks
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
OP_NET supports three Bitcoin networks:
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
26
|
import { Networks, Network } from '@btc-vision/btc-runtime/runtime';
|
|
@@ -291,7 +291,7 @@ flowchart LR
|
|
|
291
291
|
CSV6 -->|"No"| CSV8["Transaction invalid"]
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
OP_NET provides a built-in method for CSV scripts:
|
|
295
295
|
|
|
296
296
|
```typescript
|
|
297
297
|
import { BitcoinScript, BitcoinAddresses, Network, Networks } from '@btc-vision/btc-runtime/runtime';
|
|
@@ -425,7 +425,7 @@ if (result.success) {
|
|
|
425
425
|
|
|
426
426
|
## Script Recognition
|
|
427
427
|
|
|
428
|
-
|
|
428
|
+
OP_NET can parse and recognize common script patterns:
|
|
429
429
|
|
|
430
430
|
### Recognize CSV Timelock
|
|
431
431
|
|
|
@@ -636,13 +636,13 @@ public buildOpReturnScript(data: Uint8Array): Uint8Array {
|
|
|
636
636
|
}
|
|
637
637
|
```
|
|
638
638
|
|
|
639
|
-
## Solidity vs
|
|
639
|
+
## Solidity vs OP_NET: Bitcoin Scripts Comparison
|
|
640
640
|
|
|
641
|
-
Bitcoin scripting is fundamentally different from Solidity, as it operates on UTXOs rather than account balances.
|
|
641
|
+
Bitcoin scripting is fundamentally different from Solidity, as it operates on UTXOs rather than account balances. OP_NET uniquely bridges smart contract functionality with native Bitcoin scripting capabilities.
|
|
642
642
|
|
|
643
643
|
### Feature Comparison Table
|
|
644
644
|
|
|
645
|
-
| Feature | Solidity/EVM |
|
|
645
|
+
| Feature | Solidity/EVM | OP_NET | OP_NET Advantage |
|
|
646
646
|
|---------|--------------|-------|-----------------|
|
|
647
647
|
| **Bitcoin Script Support** | Not supported | Full support via `BitcoinOpcodes` | Native Bitcoin integration |
|
|
648
648
|
| **Address Types** | Single type (20 bytes) | P2PKH, P2SH, P2WPKH, P2WSH, P2TR | Full Bitcoin address compatibility |
|
|
@@ -657,7 +657,7 @@ Bitcoin scripting is fundamentally different from Solidity, as it operates on UT
|
|
|
657
657
|
|
|
658
658
|
### Capability Matrix
|
|
659
659
|
|
|
660
|
-
| Capability | Solidity |
|
|
660
|
+
| Capability | Solidity | OP_NET |
|
|
661
661
|
|------------|:--------:|:-----:|
|
|
662
662
|
| Create P2PKH addresses | No | Yes |
|
|
663
663
|
| Create P2SH addresses | No | Yes |
|
|
@@ -706,10 +706,10 @@ contract TimeLock {
|
|
|
706
706
|
}
|
|
707
707
|
```
|
|
708
708
|
|
|
709
|
-
####
|
|
709
|
+
#### OP_NET Approach (Consensus-Enforced)
|
|
710
710
|
|
|
711
711
|
```typescript
|
|
712
|
-
//
|
|
712
|
+
// OP_NET - CSV relative timelock (consensus-enforced)
|
|
713
713
|
import { BitcoinScript, BitcoinAddresses, Network, Networks } from '@btc-vision/btc-runtime/runtime';
|
|
714
714
|
|
|
715
715
|
// Create a timelock script - 144 blocks = ~1 day
|
|
@@ -774,10 +774,10 @@ contract MultiSig {
|
|
|
774
774
|
}
|
|
775
775
|
```
|
|
776
776
|
|
|
777
|
-
####
|
|
777
|
+
#### OP_NET Approach (Native Bitcoin Multisig)
|
|
778
778
|
|
|
779
779
|
```typescript
|
|
780
|
-
//
|
|
780
|
+
// OP_NET - native Bitcoin multisig (simple, consensus-enforced)
|
|
781
781
|
import { BitcoinScript, BitcoinAddresses, Network, Networks } from '@btc-vision/btc-runtime/runtime';
|
|
782
782
|
|
|
783
783
|
// Build a 2-of-3 multisig script - one line of code!
|
|
@@ -805,7 +805,7 @@ if (recognized.ok) {
|
|
|
805
805
|
|
|
806
806
|
### Script Building Comparison
|
|
807
807
|
|
|
808
|
-
| Task | Solidity |
|
|
808
|
+
| Task | Solidity | OP_NET |
|
|
809
809
|
|------|----------|-------|
|
|
810
810
|
| Build P2PKH script | Not possible | `buildP2PKHScript(pubkeyHash)` |
|
|
811
811
|
| Build multisig script | Custom contract | `BitcoinScript.multisig(m, pubkeys)` |
|
|
@@ -817,7 +817,7 @@ if (recognized.ok) {
|
|
|
817
817
|
|
|
818
818
|
### Transaction Introspection
|
|
819
819
|
|
|
820
|
-
| Feature | Solidity |
|
|
820
|
+
| Feature | Solidity | OP_NET |
|
|
821
821
|
|---------|----------|-------|
|
|
822
822
|
| Access tx outputs | `msg.value` only | `Blockchain.tx.outputs` (full array) |
|
|
823
823
|
| Access tx inputs | Not possible | `Blockchain.tx.inputs` (full array) |
|
|
@@ -846,7 +846,7 @@ contract DataEmbed {
|
|
|
846
846
|
```
|
|
847
847
|
|
|
848
848
|
```typescript
|
|
849
|
-
//
|
|
849
|
+
// OP_NET - OP_RETURN (native Bitcoin, permanent)
|
|
850
850
|
import { BytesWriter, BitcoinOpcodes } from '@btc-vision/btc-runtime/runtime';
|
|
851
851
|
|
|
852
852
|
function buildOpReturnScript(data: Uint8Array): Uint8Array {
|
|
@@ -869,9 +869,9 @@ function buildOpReturnScript(data: Uint8Array): Uint8Array {
|
|
|
869
869
|
// - No complex event parsing needed
|
|
870
870
|
```
|
|
871
871
|
|
|
872
|
-
### Why
|
|
872
|
+
### Why OP_NET for Bitcoin Integration?
|
|
873
873
|
|
|
874
|
-
| Solidity Limitation |
|
|
874
|
+
| Solidity Limitation | OP_NET Solution |
|
|
875
875
|
|---------------------|----------------|
|
|
876
876
|
| Cannot interact with Bitcoin | Full Bitcoin script support |
|
|
877
877
|
| No UTXO awareness | Complete transaction introspection |
|