Setting Up Your Environment for Node.js
This guide explains how to install the necessary packages to start developing with OP_NET in a Node.js environment. Follow these steps to integrate the essential libraries and get started.
Installing Required Packages
1. Install opnet
The opnet
package is the primary SDK for interacting with the OP_NET metaprotocol. It provides tools to connect to the network, retrieve balances, and interact with contracts.
Install it via npm:
npm install opnet
2. Install @btc-vision/transaction
The @btc-vision/transaction
package is essential for building and signing transactions in the OP_NET ecosystem. It simplifies the process of handling UTXOs and transaction calldata.
Install it using npm:
npm install @btc-vision/transaction
3. Install @btc-vision/bitcoin
The @btc-vision/bitcoin
package is required for all Bitcoin-related operations on OP_NET. It is mandatory for any development involving Bitcoin within the metaprotocol.
Install it via npm:
npm install @btc-vision/bitcoin
Use TypeScript Instead of JavaScript
OP_NET development requires strict type handling to avoid runtime errors. Using JavaScript may lead to unexpected issues due to its lack of type enforcement. TypeScript is strongly recommended as it provides:
- Type safety for all OP_NET packages.
- Better debugging and error handling during development.
If you must use JavaScript, ensure you carefully validate all inputs and outputs, but TypeScript remains the preferred option for stability and accuracy.
Node.js Version Compatibility
Ensure you are using Node.js v22.x. Older versions or newer releases may cause compatibility issues with OP_NET packages. Check your Node.js version using:
node -v
Next Steps
Once your environment is configured, proceed to Interacting with an OP_NET Node for further guidance.