Installation Guide
Complete installation instructions for all Opacus Protocol components across different platforms and environments.
System Requirements
💻
TypeScript/JavaScript
Node.js 18+
npm 9+ / yarn 3+ / pnpm 8+
Modern browser
🦀
Rust
Rust 1.70+
cargo
Linux/macOS/Windows
⛓️
Blockchain
0G Chain access
Wallet with testnet tokens
RPC endpoint
💾
Storage
500 MB disk space
4 GB RAM minimum
Stable internet
TypeScript SDK Installation
Using npm
npm install @opacus/sdk ethers
Using yarn
yarn add @opacus/sdk ethers
Using pnpm
pnpm add @opacus/sdk ethers
Browser (CDN)
<script type="module">
import { OpacusClient } from 'https://esm.sh/@opacus/sdk@1.0.0';
</script>
Deno
import { OpacusClient } from "npm:@opacus/sdk@1.0.0";
Verify Installation
import { OpacusClient } from '@opacus/sdk';
console.log('✅ Opacus SDK installed successfully!');
console.log('Version:', require('@opacus/sdk/package.json').version);
Rust SDK Installation
Add to Cargo.toml
[dependencies]
opacus-sdk = "1.0"
tokio = { version = "1.36", features = ["full"] }
ed25519-dalek = "2.1"
x25519-dalek = "2.0"
Install from crates.io
cargo add opacus-sdk tokio
Build from Source
git clone https://github.com/Opacus-xyz/Opacus/opacus-sdk-rust.git
cd opacus-sdk-rust
cargo build --release
Verify Installation
cargo check
// Should output:
// Checking opacus-sdk v1.0.0
// Finished dev [unoptimized + debuginfo] target(s)
Smart Contracts Setup
Clone Repository
git clone https://github.com/Opacus-xyz/Opacus/contracts.git
cd contracts
npm install
Configure Network
Create .env file:
PRIVATE_KEY=your_wallet_private_key
RPC_URL=https://evmrpc-testnet.0g.ai
CHAIN_ID=16661
Compile Contracts
npx hardhat compile
Deploy Contracts
npx hardhat run scripts/deploy.ts --network og-testnet
Environment Configuration
TypeScript Environment
# .env
OPACUS_RPC_URL=https://evmrpc-testnet.0g.ai
OPACUS_CONTRACT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
OPACUS_PRIVATE_KEY=your_private_key
OPACUS_CHAIN_ID=16661
Rust Environment
# config.toml
[opacus]
rpc_url = "https://evmrpc-testnet.0g.ai"
contract_address = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
private_key = "your_private_key"
chain_id = 16661
Get Testnet Tokens
💰 0G Chain Testnet Faucet
To use Opacus Protocol on testnet, you need 0G tokens:
- Visit:
https://faucet.0g.ai - Connect your wallet (MetaMask recommended)
- Request testnet tokens (0.1 0G per request)
- Wait ~30 seconds for tokens to arrive
Platform-Specific Setup
macOS
# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.js
brew install node
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Opacus SDK
npm install -g @opacus/sdk
Linux (Ubuntu/Debian)
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install build essentials
sudo apt install -y build-essential pkg-config libssl-dev
# Install Opacus SDK
npm install -g @opacus/sdk
Windows
# Install Node.js from: https://nodejs.org/
# Download and run installer
# Install Rust from: https://rustup.rs/
# Download and run rustup-init.exe
# Install Visual Studio Build Tools
# Download from: https://visualstudio.microsoft.com/downloads/
# Install Opacus SDK
npm install -g @opacus/sdk
Docker Installation
Using Docker Image
# Pull official image
docker pull opacus/opacus-sdk:latest
# Run container
docker run -it --rm \
-e OPACUS_RPC_URL=https://evmrpc-testnet.0g.ai \
-e OPACUS_PRIVATE_KEY=your_key \
opacus/opacus-sdk:latest
Build from Dockerfile
# Dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]
# Build and run
docker build -t my-opacus-app .
docker run -it my-opacus-app
IDE Setup
VS Code Extensions
- Solidity - Smart contract development
- rust-analyzer - Rust language support
- ESLint - JavaScript/TypeScript linting
- Prettier - Code formatting
- Hardhat - Contract tools
VS Code Settings
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
}
}
Verification Steps
1. Check Node.js
node --version # Should be v18.0.0 or higher
npm --version # Should be 9.0.0 or higher
2. Check Rust
rustc --version # Should be 1.70.0 or higher
cargo --version # Should be 1.70.0 or higher
3. Test TypeScript SDK
node -e "console.log(require('@opacus/sdk'))"
# Should output SDK object
4. Test Rust SDK
cargo run --example client
# Should compile and run without errors
✅ Installation Complete!
Your development environment is now ready. Proceed to Getting Started to build your first application.
Troubleshooting
Common Issues
npm install fails
# Clear npm cache
npm cache clean --force
# Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
# Reinstall
npm install
Rust build fails
# Update Rust
rustup update
# Clean build artifacts
cargo clean
# Rebuild
cargo build
Permission errors on Linux/macOS
# Install packages globally without sudo
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATH
# Add to ~/.bashrc or ~/.zshrc for persistence
For more help, visit Troubleshooting Guide or check our GitHub Issues.