@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.
Files changed (72) hide show
  1. package/README.md +7 -7
  2. package/docs/README.md +39 -39
  3. package/docs/advanced/bitcoin-scripts.md +17 -17
  4. package/docs/advanced/{contract-upgrades.md → contract-updates.md} +90 -98
  5. package/docs/advanced/cross-contract-calls.md +4 -4
  6. package/docs/advanced/plugins.md +21 -21
  7. package/docs/advanced/quantum-resistance.md +32 -32
  8. package/docs/advanced/signature-verification.md +22 -22
  9. package/docs/api-reference/blockchain.md +14 -14
  10. package/docs/api-reference/events.md +2 -2
  11. package/docs/api-reference/op20.md +7 -7
  12. package/docs/api-reference/op721.md +7 -7
  13. package/docs/api-reference/storage.md +2 -2
  14. package/docs/contracts/op-net-base.md +15 -15
  15. package/docs/contracts/op20-token.md +3 -3
  16. package/docs/contracts/op20s-signatures.md +2 -2
  17. package/docs/contracts/op721-nft.md +3 -3
  18. package/docs/contracts/reentrancy-guard.md +5 -7
  19. package/docs/contracts/updatable.md +384 -0
  20. package/docs/core-concepts/blockchain-environment.md +10 -10
  21. package/docs/core-concepts/decorators.md +5 -5
  22. package/docs/core-concepts/events.md +6 -6
  23. package/docs/core-concepts/pointers.md +5 -5
  24. package/docs/core-concepts/security.md +5 -5
  25. package/docs/core-concepts/storage-system.md +24 -24
  26. package/docs/examples/basic-token.md +8 -8
  27. package/docs/examples/nft-with-reservations.md +9 -9
  28. package/docs/examples/oracle-integration.md +13 -13
  29. package/docs/examples/stablecoin.md +10 -10
  30. package/docs/getting-started/first-contract.md +8 -8
  31. package/docs/getting-started/installation.md +2 -2
  32. package/docs/getting-started/project-structure.md +6 -6
  33. package/docs/storage/memory-maps.md +8 -8
  34. package/docs/storage/stored-arrays.md +6 -6
  35. package/docs/storage/stored-maps.md +8 -8
  36. package/docs/storage/stored-primitives.md +6 -6
  37. package/docs/types/address.md +13 -13
  38. package/docs/types/bytes-writer-reader.md +18 -18
  39. package/docs/types/calldata.md +12 -12
  40. package/package.json +10 -10
  41. package/runtime/constants/Exports.ts +0 -30
  42. package/runtime/contracts/OP20.ts +7 -7
  43. package/runtime/contracts/OP721.ts +60 -74
  44. package/runtime/contracts/OP_NET.ts +2 -2
  45. package/runtime/contracts/ReentrancyGuard.ts +1 -5
  46. package/runtime/contracts/Updatable.ts +241 -0
  47. package/runtime/contracts/interfaces/OP721InitParameters.ts +8 -8
  48. package/runtime/env/BlockchainEnvironment.ts +5 -5
  49. package/runtime/env/global.ts +7 -6
  50. package/runtime/events/predefined/{ApprovedEvent.ts → OP20ApprovedEvent.ts} +1 -1
  51. package/runtime/events/predefined/{BurnedEvent.ts → OP20BurnedEvent.ts} +1 -1
  52. package/runtime/events/predefined/{MintedEvent.ts → OP20MintedEvent.ts} +1 -1
  53. package/runtime/events/predefined/{TransferredEvent.ts → OP20TransferredEvent.ts} +1 -1
  54. package/runtime/events/predefined/OP721ApprovedEvent.ts +17 -0
  55. package/runtime/events/predefined/{ApprovedForAll.ts → OP721ApprovedForAllEvent.ts} +1 -1
  56. package/runtime/events/predefined/OP721BurnedEvent.ts +16 -0
  57. package/runtime/events/predefined/OP721MintedEvent.ts +16 -0
  58. package/runtime/events/predefined/OP721TransferredEvent.ts +18 -0
  59. package/runtime/events/predefined/index.ts +5 -5
  60. package/runtime/events/{upgradeable/UpgradeableEvents.ts → updatable/UpdatableEvents.ts} +9 -9
  61. package/runtime/hashing/keccak256.ts +1 -1
  62. package/runtime/index.ts +3 -5
  63. package/runtime/plugins/UpdatablePlugin.ts +276 -0
  64. package/runtime/script/Networks.ts +1 -1
  65. package/runtime/storage/StoredBoolean.ts +23 -12
  66. package/runtime/types/Address.ts +1 -1
  67. package/runtime/types/ExtendedAddress.ts +1 -1
  68. package/docs/contracts/upgradeable.md +0 -396
  69. package/runtime/contracts/Upgradeable.ts +0 -242
  70. package/runtime/contracts/interfaces/IOP1155.ts +0 -33
  71. package/runtime/contracts/interfaces/OP1155InitParameters.ts +0 -11
  72. package/runtime/plugins/UpgradeablePlugin.ts +0 -279
@@ -85,7 +85,7 @@ modifier onlyRole(bytes32 role) {
85
85
  _;
86
86
  }
87
87
 
88
- // OPNet - Bit flags for efficiency
88
+ // OP_NET - Bit flags for efficiency
89
89
  enum Role { ADMIN = 1, MINTER = 2, PAUSER = 4, BLACKLISTER = 8 }
90
90
 
91
91
  public hasRole(account: Address, role: u256): bool {
@@ -208,7 +208,7 @@ function pause() external onlyRole(PAUSER_ROLE) {
208
208
  _pause();
209
209
  }
210
210
 
211
- // OPNet
211
+ // OP_NET
212
212
  private whenNotPaused(): void {
213
213
  if (this._paused.value) {
214
214
  throw new Revert('Pausable: paused');
@@ -979,11 +979,11 @@ contract Stablecoin is ERC20, ERC20Pausable, AccessControl {
979
979
  }
980
980
  ```
981
981
 
982
- ## Solidity vs OPNet Comparison
982
+ ## Solidity vs OP_NET Comparison
983
983
 
984
984
  ### Key Differences Table
985
985
 
986
- | Aspect | Solidity (OpenZeppelin) | OPNet |
986
+ | Aspect | Solidity (OpenZeppelin) | OP_NET |
987
987
  |--------|------------------------|-------|
988
988
  | **Access Control** | `AccessControl` with `bytes32` role hashes | Bit flags in `u256` with enum |
989
989
  | **Role Definition** | `keccak256("MINTER_ROLE")` | `enum Role { MINTER = 2 }` (powers of 2) |
@@ -1017,7 +1017,7 @@ function grantRole(bytes32 role, address account) public onlyRole(getRoleAdmin(r
1017
1017
  }
1018
1018
  ```
1019
1019
 
1020
- **OPNet (Bit Flag System):**
1020
+ **OP_NET (Bit Flag System):**
1021
1021
  ```typescript
1022
1022
  // Roles as bit flags (powers of 2)
1023
1023
  enum Role {
@@ -1063,7 +1063,7 @@ contract MyToken is ERC20Pausable {
1063
1063
  }
1064
1064
  ```
1065
1065
 
1066
- **OPNet (Manual Implementation):**
1066
+ **OP_NET (Manual Implementation):**
1067
1067
  ```typescript
1068
1068
  private _paused: StoredBoolean;
1069
1069
 
@@ -1106,7 +1106,7 @@ function blacklist(address account) external onlyRole(BLACKLISTER_ROLE) {
1106
1106
  }
1107
1107
  ```
1108
1108
 
1109
- **OPNet:**
1109
+ **OP_NET:**
1110
1110
  ```typescript
1111
1111
  private _blacklist: AddressMemoryMap;
1112
1112
 
@@ -1129,7 +1129,7 @@ public blacklist(calldata: Calldata): BytesWriter {
1129
1129
  }
1130
1130
  ```
1131
1131
 
1132
- ### Advantages of OPNet Approach
1132
+ ### Advantages of OP_NET Approach
1133
1133
 
1134
1134
  | Feature | Benefit |
1135
1135
  |---------|---------|
@@ -1142,7 +1142,7 @@ public blacklist(calldata: Calldata): BytesWriter {
1142
1142
 
1143
1143
  ### Minter Allowance Pattern (USDC-style)
1144
1144
 
1145
- Both implementations support minter allowances, but OPNet makes this a first-class feature:
1145
+ Both implementations support minter allowances, but OP_NET makes this a first-class feature:
1146
1146
 
1147
1147
  **Solidity:**
1148
1148
  ```solidity
@@ -1155,7 +1155,7 @@ function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
1155
1155
  }
1156
1156
  ```
1157
1157
 
1158
- **OPNet:**
1158
+ **OP_NET:**
1159
1159
  ```typescript
1160
1160
  private _minterAllowance: AddressMemoryMap;
1161
1161
 
@@ -1,6 +1,6 @@
1
1
  # Your First Contract
2
2
 
3
- This tutorial guides you through creating a complete OP20 token contract from scratch. By the end, you'll understand the core concepts of OPNet smart contract development.
3
+ This tutorial guides you through creating a complete OP20 token contract from scratch. By the end, you'll understand the core concepts of OP_NET smart contract development.
4
4
 
5
5
  ## What We're Building
6
6
 
@@ -59,7 +59,7 @@ Let's break this down piece by piece.
59
59
 
60
60
  ## Contract Lifecycle Overview
61
61
 
62
- This diagram illustrates the complete lifecycle of an OPNet smart contract from deployment to execution:
62
+ This diagram illustrates the complete lifecycle of an OP_NET smart contract from deployment to execution:
63
63
 
64
64
  ```mermaid
65
65
  ---
@@ -163,10 +163,10 @@ public constructor() {
163
163
  }
164
164
  ```
165
165
 
166
- **IMPORTANT:** In OPNet, the constructor runs on **every** contract interaction, not just deployment. This is different from Solidity!
166
+ **IMPORTANT:** In OP_NET, the constructor runs on **every** contract interaction, not just deployment. This is different from Solidity!
167
167
 
168
168
  ```typescript
169
- // OPNet // Solidity
169
+ // OP_NET // Solidity
170
170
  public constructor() { // constructor() {
171
171
  super(); // // Runs ONCE at deployment
172
172
  // Runs EVERY time! // }
@@ -302,7 +302,7 @@ function mint(address to, uint256 amount) external onlyOwner {
302
302
 
303
303
  ### u256 - Big Numbers
304
304
 
305
- OPNet uses `u256` for large numbers (like balances):
305
+ OP_NET uses `u256` for large numbers (like balances):
306
306
 
307
307
  ```typescript
308
308
  import { u256 } from '@btc-vision/as-bignum/assembly';
@@ -318,7 +318,7 @@ const c = u256.fromString('99999999999999'); // From string (large numbers)
318
318
 
319
319
  **Why not native numbers?**
320
320
 
321
- | JavaScript/TypeScript | AssemblyScript/OPNet |
321
+ | JavaScript/TypeScript | AssemblyScript/OP_NET |
322
322
  |----------------------|----------------------|
323
323
  | `number` (64-bit float) | Non-deterministic! |
324
324
  | `BigInt` | Not supported in WASM |
@@ -326,7 +326,7 @@ const c = u256.fromString('99999999999999'); // From string (large numbers)
326
326
 
327
327
  ### Address
328
328
 
329
- Addresses are 32 bytes in OPNet:
329
+ Addresses are 32 bytes in OP_NET:
330
330
 
331
331
  ```typescript
332
332
  import { Address, Blockchain } from '@btc-vision/btc-runtime/runtime';
@@ -423,7 +423,7 @@ Here's a side-by-side comparison of the complete contract:
423
423
 
424
424
  <table>
425
425
  <tr>
426
- <th>OPNet (AssemblyScript)</th>
426
+ <th>OP_NET (AssemblyScript)</th>
427
427
  <th>Solidity</th>
428
428
  </tr>
429
429
  <tr>
@@ -1,6 +1,6 @@
1
1
  # Installation
2
2
 
3
- This guide walks you through setting up your development environment for building OPNet smart contracts.
3
+ This guide walks you through setting up your development environment for building OP_NET smart contracts.
4
4
 
5
5
  ## Quick Start - Clone Example Project
6
6
 
@@ -331,7 +331,7 @@ And add a build script to `package.json`:
331
331
  |---------|---------|---------|
332
332
  | `@btc-vision/btc-runtime` | ^1.10.8 | Core runtime - contracts, storage, events |
333
333
  | `@btc-vision/as-bignum` | ^0.0.6 | 128-bit and 256-bit integer types |
334
- | `@btc-vision/opnet-transform` | ^0.1.12 | AssemblyScript transform for OPNet |
334
+ | `@btc-vision/opnet-transform` | ^0.1.12 | AssemblyScript transform for OP_NET |
335
335
  | `assemblyscript` | ^0.28.9 | AssemblyScript compiler |
336
336
 
337
337
  ## Troubleshooting
@@ -1,6 +1,6 @@
1
1
  # Project Structure
2
2
 
3
- This guide explains the standard project structure for OPNet smart contract development and how the btc-runtime library is organized.
3
+ This guide explains the standard project structure for OP_NET smart contract development and how the btc-runtime library is organized.
4
4
 
5
5
  ## Your Project Structure
6
6
 
@@ -72,7 +72,7 @@ graph LR
72
72
  TOKEN -.->|"tested by"| SPEC
73
73
  ```
74
74
 
75
- A typical OPNet contract project looks like this:
75
+ A typical OP_NET contract project looks like this:
76
76
 
77
77
  ```
78
78
  my-opnet-project/
@@ -168,8 +168,8 @@ AssemblyScript compiler configuration with per-contract targets:
168
168
  | `use` | Links custom abort function for error handling |
169
169
  | `optimizeLevel` | Optimization level (0-3), higher = faster but larger |
170
170
  | `shrinkLevel` | Code size reduction (0-2) |
171
- | `transform` | OPNet transform for decorator processing |
172
- | `runtime: "stub"` | Minimal runtime (OPNet provides its own) |
171
+ | `transform` | OP_NET transform for decorator processing |
172
+ | `runtime: "stub"` | Minimal runtime (OP_NET provides its own) |
173
173
 
174
174
  ### package.json Scripts
175
175
 
@@ -384,7 +384,7 @@ import {
384
384
 
385
385
  ### Storage Pointer System
386
386
 
387
- This diagram illustrates how OPNet manages persistent storage using pointers:
387
+ This diagram illustrates how OP_NET manages persistent storage using pointers:
388
388
 
389
389
  ```mermaid
390
390
  ---
@@ -529,7 +529,7 @@ export class MyToken extends Pausable {
529
529
 
530
530
  ## Comparison with Solidity Projects
531
531
 
532
- | Solidity | OPNet | Notes |
532
+ | Solidity | OP_NET | Notes |
533
533
  |----------|-------|-------|
534
534
  | `contracts/` | `src/token/`, `src/nft/` | Contract source files (one folder per contract) |
535
535
  | `interfaces/` | `src/shared/` | Type definitions and shared logic |
@@ -145,11 +145,11 @@ flowchart LR
145
145
  H --> I
146
146
  ```
147
147
 
148
- ## Solidity vs OPNet Comparison
148
+ ## Solidity vs OP_NET Comparison
149
149
 
150
150
  ### Quick Reference Table
151
151
 
152
- | Solidity | OPNet AddressMemoryMap |
152
+ | Solidity | OP_NET AddressMemoryMap |
153
153
  |----------|------------------------|
154
154
  | `mapping(address => uint256)` | `AddressMemoryMap` |
155
155
  | `balances[addr]` | `balances.get(addr)` |
@@ -161,7 +161,7 @@ flowchart LR
161
161
 
162
162
  ### Operations Comparison
163
163
 
164
- | Operation | Solidity | OPNet |
164
+ | Operation | Solidity | OP_NET |
165
165
  |-----------|----------|-------|
166
166
  | Declare | `mapping(address => uint256) public balances;` | `private balances: AddressMemoryMap;` |
167
167
  | Initialize | Automatic | `this.balances = new AddressMemoryMap(this.balancesPointer);` |
@@ -175,7 +175,7 @@ flowchart LR
175
175
 
176
176
  ### Common Patterns
177
177
 
178
- | Pattern | Solidity | OPNet |
178
+ | Pattern | Solidity | OP_NET |
179
179
  |---------|----------|-------|
180
180
  | Transfer balance | `balances[from] -= amt; balances[to] += amt;` | `balances.set(from, SafeMath.sub(balances.get(from), amt)); balances.set(to, SafeMath.add(balances.get(to), amt));` |
181
181
  | Check sufficient | `require(balances[addr] >= amount);` | `if (balances.get(addr) < amount) throw new Revert("Insufficient");` |
@@ -186,7 +186,7 @@ flowchart LR
186
186
 
187
187
  ### Key Differences from Solidity
188
188
 
189
- | Aspect | Solidity | OPNet |
189
+ | Aspect | Solidity | OP_NET |
190
190
  |--------|----------|-------|
191
191
  | Key type | `address` (20 bytes) | `Address` (32 bytes) |
192
192
  | Value type | Any | `u256` only |
@@ -196,7 +196,7 @@ flowchart LR
196
196
 
197
197
  ### ERC-20 Style Comparison
198
198
 
199
- | ERC-20 Function | Solidity | OPNet |
199
+ | ERC-20 Function | Solidity | OP_NET |
200
200
  |-----------------|----------|-------|
201
201
  | `balanceOf(address)` | `return balances[owner];` | `return this.balances.get(owner);` |
202
202
  | `transfer(to, amount)` | `balances[msg.sender] -= amount; balances[to] += amount;` | `this.balances.set(sender, SafeMath.sub(...)); this.balances.set(to, SafeMath.add(...));` |
@@ -237,7 +237,7 @@ contract TokenBalances {
237
237
  }
238
238
  ```
239
239
 
240
- **OPNet:**
240
+ **OP_NET:**
241
241
  ```typescript
242
242
  @final
243
243
  export class TokenBalances extends OP_NET {
@@ -344,7 +344,7 @@ contract Staking {
344
344
  }
345
345
  ```
346
346
 
347
- **OPNet:**
347
+ **OP_NET:**
348
348
  ```typescript
349
349
  @final
350
350
  export class Staking extends OP_NET {
@@ -196,11 +196,11 @@ if (this.holders.getLength() === 0) {
196
196
  }
197
197
  ```
198
198
 
199
- ## Solidity vs OPNet Comparison
199
+ ## Solidity vs OP_NET Comparison
200
200
 
201
201
  ### Quick Reference Table
202
202
 
203
- | Solidity Array Type | OPNet Equivalent | Elements per Slot | Default Max |
203
+ | Solidity Array Type | OP_NET Equivalent | Elements per Slot | Default Max |
204
204
  |---------------------|------------------|-------------------|-------------|
205
205
  | `uint256[]` | `StoredU256Array` | 1 | u32.MAX_VALUE - 1 |
206
206
  | `uint128[]` | `StoredU128Array` | 2 | u32.MAX_VALUE - 1 |
@@ -213,7 +213,7 @@ if (this.holders.getLength() === 0) {
213
213
 
214
214
  ### Operations Comparison
215
215
 
216
- | Operation | Solidity | OPNet |
216
+ | Operation | Solidity | OP_NET |
217
217
  |-----------|----------|-------|
218
218
  | Declare array | `address[] public holders;` | `private holders: StoredAddressArray;` |
219
219
  | Initialize | Automatic | `this.holders = new StoredAddressArray(this.holdersPointer, EMPTY_POINTER);` |
@@ -230,7 +230,7 @@ if (this.holders.getLength() === 0) {
230
230
 
231
231
  ### Common Patterns
232
232
 
233
- | Pattern | Solidity | OPNet |
233
+ | Pattern | Solidity | OP_NET |
234
234
  |---------|----------|-------|
235
235
  | Loop through array | `for (uint i = 0; i < arr.length; i++)` | `for (let i: u32 = 0; i < arr.getLength(); i++)` |
236
236
  | Remove at index (swap) | `arr[i] = arr[arr.length-1]; arr.pop();` | `arr.set(i, arr.get(arr.getLength()-1)); arr.deleteLast(); arr.save();` |
@@ -276,7 +276,7 @@ contract AddressList {
276
276
  }
277
277
  ```
278
278
 
279
- **OPNet:**
279
+ **OP_NET:**
280
280
  ```typescript
281
281
  @final
282
282
  export class AddressList extends OP_NET {
@@ -372,7 +372,7 @@ contract ValueQueue {
372
372
  }
373
373
  ```
374
374
 
375
- **OPNet:**
375
+ **OP_NET:**
376
376
  ```typescript
377
377
  @final
378
378
  export class ValueQueue extends OP_NET {
@@ -260,11 +260,11 @@ flowchart LR
260
260
  G --> H["Commit to storage"]
261
261
  ```
262
262
 
263
- ## Solidity vs OPNet Comparison
263
+ ## Solidity vs OP_NET Comparison
264
264
 
265
265
  ### Quick Reference Table
266
266
 
267
- | Solidity Mapping Type | OPNet Equivalent | Notes |
267
+ | Solidity Mapping Type | OP_NET Equivalent | Notes |
268
268
  |-----------------------|------------------|-------|
269
269
  | `mapping(uint256 => uint256)` | `StoredMapU256` | u256 keys and values |
270
270
  | `mapping(address => uint256)` | `AddressMemoryMap` | Recommended for address keys |
@@ -274,7 +274,7 @@ flowchart LR
274
274
 
275
275
  ### Operations Comparison
276
276
 
277
- | Operation | Solidity | OPNet (StoredMapU256) |
277
+ | Operation | Solidity | OP_NET (StoredMapU256) |
278
278
  |-----------|----------|----------------------|
279
279
  | Declare | `mapping(uint256 => uint256) data;` | `private data: StoredMapU256;` |
280
280
  | Initialize | Automatic | `this.data = new StoredMapU256(this.dataPointer);` |
@@ -286,7 +286,7 @@ flowchart LR
286
286
 
287
287
  ### Nested Mapping Comparison
288
288
 
289
- | Operation | Solidity | OPNet (MapOfMap) |
289
+ | Operation | Solidity | OP_NET (MapOfMap) |
290
290
  |-----------|----------|------------------|
291
291
  | Declare | `mapping(address => mapping(address => uint256)) allowances;` | `private allowances: MapOfMap<u256>;` |
292
292
  | Read nested | `allowances[owner][spender]` | `allowances.get(owner).get(spender)` |
@@ -294,7 +294,7 @@ flowchart LR
294
294
 
295
295
  ### Address Key Patterns
296
296
 
297
- | Solidity Pattern | OPNet Equivalent |
297
+ | Solidity Pattern | OP_NET Equivalent |
298
298
  |------------------|------------------|
299
299
  | `mapping(address => uint256) balances;` | `private balances: AddressMemoryMap;` (preferred) |
300
300
  | `balances[msg.sender]` | `balances.get(Blockchain.tx.sender)` |
@@ -303,7 +303,7 @@ flowchart LR
303
303
 
304
304
  ### Common Use Cases
305
305
 
306
- | Use Case | Solidity | OPNet |
306
+ | Use Case | Solidity | OP_NET |
307
307
  |----------|----------|-------|
308
308
  | Token balances | `mapping(address => uint256) balances;` | `AddressMemoryMap` |
309
309
  | Approvals | `mapping(address => mapping(address => uint256))` | `MapOfMap<u256>` |
@@ -341,7 +341,7 @@ contract KeyValueStore {
341
341
  }
342
342
  ```
343
343
 
344
- **OPNet:**
344
+ **OP_NET:**
345
345
  ```typescript
346
346
  @final
347
347
  export class KeyValueStore extends OP_NET {
@@ -414,7 +414,7 @@ contract ApprovalSystem {
414
414
  }
415
415
  ```
416
416
 
417
- **OPNet:**
417
+ **OP_NET:**
418
418
  ```typescript
419
419
  @final
420
420
  export class ApprovalSystem extends OP_NET {
@@ -277,11 +277,11 @@ public override onDeployment(calldata: Calldata): void {
277
277
  }
278
278
  ```
279
279
 
280
- ## Solidity vs OPNet Comparison
280
+ ## Solidity vs OP_NET Comparison
281
281
 
282
282
  ### Quick Reference Table
283
283
 
284
- | Solidity | OPNet | Default Value |
284
+ | Solidity | OP_NET | Default Value |
285
285
  |----------|-------|---------------|
286
286
  | `uint256 public value;` | `StoredU256` | `u256.Zero` |
287
287
  | `uint64[4] packed;` | `StoredU64` | `[0, 0, 0, 0]` |
@@ -294,7 +294,7 @@ public override onDeployment(calldata: Calldata): void {
294
294
 
295
295
  ### Operations Comparison
296
296
 
297
- | Operation | Solidity | OPNet |
297
+ | Operation | Solidity | OP_NET |
298
298
  |-----------|----------|-------|
299
299
  | Declare state variable | `uint256 public value;` | `private _value: StoredU256 = new StoredU256(ptr, EMPTY_POINTER);` |
300
300
  | Read value | `value` or `this.value` | `this._value.value` |
@@ -309,7 +309,7 @@ public override onDeployment(calldata: Calldata): void {
309
309
 
310
310
  ### Declaration Patterns
311
311
 
312
- | Solidity Pattern | OPNet Equivalent |
312
+ | Solidity Pattern | OP_NET Equivalent |
313
313
  |------------------|------------------|
314
314
  | `uint256 public totalSupply;` | `private totalSupplyPtr: u16 = Blockchain.nextPointer;`<br>`private _totalSupply: StoredU256 = new StoredU256(this.totalSupplyPtr, EMPTY_POINTER);` |
315
315
  | `string public name = "Token";` | `private namePtr: u16 = Blockchain.nextPointer;`<br>`private _name: StoredString = new StoredString(this.namePtr, 0);`<br>Then in `onDeployment`: `this._name.value = "Token";` |
@@ -346,7 +346,7 @@ contract Counter {
346
346
  }
347
347
  ```
348
348
 
349
- **OPNet:**
349
+ **OP_NET:**
350
350
  ```typescript
351
351
  @final
352
352
  export class Counter extends OP_NET {
@@ -417,7 +417,7 @@ contract Ownable {
417
417
  }
418
418
  ```
419
419
 
420
- **OPNet:**
420
+ **OP_NET:**
421
421
  ```typescript
422
422
  @final
423
423
  export class Ownable extends OP_NET {
@@ -1,6 +1,6 @@
1
1
  # Address Type
2
2
 
3
- The `Address` type represents a 32-byte Bitcoin/OPNet address. It provides methods for creating, comparing, and serializing addresses.
3
+ The `Address` type represents a 32-byte Bitcoin/OP_NET address. It provides methods for creating, comparing, and serializing addresses.
4
4
 
5
5
  ## Overview
6
6
 
@@ -248,12 +248,12 @@ const sender: Address = reader.readAddress();
248
248
 
249
249
  ## Address Size
250
250
 
251
- OPNet addresses are **32 bytes**, compared to Ethereum's 20 bytes:
251
+ OP_NET addresses are **32 bytes**, compared to Ethereum's 20 bytes:
252
252
 
253
253
  | Platform | Address Size | Format |
254
254
  |----------|-------------|--------|
255
255
  | Ethereum | 20 bytes | 0x + 40 hex chars |
256
- | OPNet | 32 bytes | 64 hex chars |
256
+ | OP_NET | 32 bytes | 64 hex chars |
257
257
 
258
258
  ```typescript
259
259
  // Full 32-byte address (Address extends Uint8Array)
@@ -303,7 +303,7 @@ this.balances.set(userAddress, newBalance);
303
303
 
304
304
  ## ML-DSA Public Key Access
305
305
 
306
- Every `Address` in OPNet can access its ML-DSA (quantum-resistant) public key directly:
306
+ Every `Address` in OP_NET can access its ML-DSA (quantum-resistant) public key directly:
307
307
 
308
308
  ```typescript
309
309
  const sender: Address = Blockchain.tx.sender;
@@ -429,11 +429,11 @@ const deadAddr: ExtendedAddress = Blockchain.DEAD_ADDRESS;
429
429
 
430
430
  See [Quantum Resistance](../advanced/quantum-resistance.md) for details.
431
431
 
432
- ## Solidity vs OPNet Comparison
432
+ ## Solidity vs OP_NET Comparison
433
433
 
434
434
  ### Address Type Comparison Table
435
435
 
436
- | Feature | Solidity | OPNet |
436
+ | Feature | Solidity | OP_NET |
437
437
  |---------|----------|-------|
438
438
  | **Type name** | `address` | `Address` |
439
439
  | **Size** | 20 bytes (160 bits) | 32 bytes (256 bits) |
@@ -464,7 +464,7 @@ address self = address(this);
464
464
  ```
465
465
 
466
466
  ```typescript
467
- // OPNet
467
+ // OP_NET
468
468
  const sender: Address = Blockchain.tx.sender;
469
469
  const origin: Address = Blockchain.tx.origin;
470
470
  const self: Address = Blockchain.contract.address;
@@ -478,7 +478,7 @@ require(to != address(0), "Cannot send to zero address");
478
478
  ```
479
479
 
480
480
  ```typescript
481
- // OPNet
481
+ // OP_NET
482
482
  if (to.equals(Address.zero())) {
483
483
  throw new Revert('Cannot send to zero address');
484
484
  }
@@ -497,7 +497,7 @@ require(from != to, "Cannot transfer to self");
497
497
  ```
498
498
 
499
499
  ```typescript
500
- // OPNet
500
+ // OP_NET
501
501
  if (!Blockchain.tx.sender.equals(owner)) {
502
502
  throw new Revert('Not owner');
503
503
  }
@@ -528,7 +528,7 @@ function transferOwnership(address newOwner) public onlyOwner {
528
528
  ```
529
529
 
530
530
  ```typescript
531
- // OPNet
531
+ // OP_NET
532
532
  private ownerPointer: u16 = Blockchain.nextPointer;
533
533
  private _owner: StoredAddress;
534
534
 
@@ -570,7 +570,7 @@ function balanceOf(address account) public view returns (uint256) {
570
570
  ```
571
571
 
572
572
  ```typescript
573
- // OPNet
573
+ // OP_NET
574
574
  private balancesPointer: u16 = Blockchain.nextPointer;
575
575
  private balances: AddressMemoryMap;
576
576
 
@@ -600,7 +600,7 @@ bool success = recipient.send(amount); // Returns false on failure
600
600
  ```
601
601
 
602
602
  ```typescript
603
- // OPNet - No native value transfers on addresses
603
+ // OP_NET - No native value transfers on addresses
604
604
  // Bitcoin UTXO model is fundamentally different
605
605
  // Token transfers are done via contract calls instead:
606
606
  this._transfer(from, to, amount); // Internal token transfer logic
@@ -608,7 +608,7 @@ this._transfer(from, to, amount); // Internal token transfer logic
608
608
 
609
609
  ### Key Differences Explained
610
610
 
611
- | Aspect | Solidity/Ethereum | OPNet/Bitcoin |
611
+ | Aspect | Solidity/Ethereum | OP_NET/Bitcoin |
612
612
  |--------|-------------------|---------------|
613
613
  | **Address derivation** | Keccak256 hash of public key (last 20 bytes) | SHA256 of ML-DSA public key (32 bytes) |
614
614
  | **Native currency** | ETH handled via `payable` | Bitcoin UTXOs handled separately |