diff --git a/.env.example b/.env.example index 1e67ef6..db68c86 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,17 @@ -# EVM private key, which can be used by ethers.Wallet +# EVM private key, used by ethers.Wallet PRIVATE_KEY= -# ask the admin for the project id + +# Particle Network project credentials — get these from https://dashboard.particle.network/ PROJECT_ID= -# polymarket +PROJECT_CLIENT_KEY= +PROJECT_APP_UUID= + +# RPC URLs for specific chains — required by EIP-7702 examples +# Add entries for each chain you need, e.g. EVM_RPC_56 for BSC, EVM_RPC_137 for Polygon EVM_RPC_137=https://polygon-rpc.com/ -# user assets wss (optional, defaults to wss://universal-app-ws-proxy.particle.network) -# UNIVERSALX_WSS_URL= + +# Override the SDK smart account version (optional, defaults to the SDK constant) +# UNIVERSAL_ACCOUNT_VERSION= + +# Override the WebSocket endpoint (optional) +# UNIVERSALX_WSS_URL=wss://universal-app-ws-proxy.particle.network diff --git a/README.md b/README.md index 5b4ba39..034ff7d 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,39 @@ # Universal Account Example -Code examples for the [Particle Network Universal Account SDK](https://developers.particle.network/). +Runnable TypeScript examples for the [@particle-network/universal-account-sdk](https://developers.particle.network/) (v1.1.1+). Universal Account abstracts cross-chain complexity into a single unified balance and address — you can buy, sell, transfer, and swap tokens across EVM chains and Solana without managing bridges or per-chain gas tokens. + +## Prerequisites + +- Node.js >= 18 +- yarn (or npm — `tsx` is included as a dev dependency) +- A [Particle Network](https://dashboard.particle.network/) project with a `projectId`, `projectClientKey`, and `projectAppUuid` ## Quick Start 1. `yarn` -2. Copy `.env.example` to `.env` and fill in your own values +2. Copy `.env.example` to `.env` and fill in your credentials (see [Environment Variables](#environment-variables)) 3. Run any example: ```bash npx tsx examples/buy-solana.ts ``` +After sending a transaction, examples print a link to `https://universalx.app/activity/details?id=` where you can track its status. + +## Environment Variables + +| Variable | Required | Description | +| --- | --- | --- | +| `PRIVATE_KEY` | Yes | EVM private key used by `ethers.Wallet` | +| `PROJECT_ID` | Yes | Particle Network project ID | +| `PROJECT_CLIENT_KEY` | Yes | Particle Network project client key | +| `PROJECT_APP_UUID` | Yes | Particle Network project app UUID | +| `EVM_RPC_` | Situational | RPC URL for a specific chain (e.g. `EVM_RPC_56` for BSC, `EVM_RPC_137` for Polygon). Required by EIP-7702 examples. | +| `UNIVERSAL_ACCOUNT_VERSION` | No | Override the SDK smart account version (defaults to the SDK constant) | +| `UNIVERSALX_WSS_URL` | No | Override the WebSocket endpoint (defaults to `wss://universal-app-ws-proxy.particle.network`) | + +Get your project credentials from the [Particle Network Dashboard](https://dashboard.particle.network/). + ## Examples ### Buy / Sell @@ -126,9 +148,9 @@ See [user-assets-wss.ts](examples/user-assets-wss.ts) for a complete example tha | Example | Description | | --- | --- | -| [warmup.ts](examples/warmup.ts) | Initialization / warmup | -| [polymarket.ts](examples/polymarket.ts) | Polymarket integration | -| [test-svm-balance.ts](examples/test-svm-balance.ts) | Solana balance test suite | +| [warmup.ts](examples/warmup.ts) | Initialize the SDK, resolve smart account addresses, and pre-fetch a token pair without sending a transaction | +| [polymarket.ts](examples/polymarket.ts) | Place a Polymarket prediction market trade via Universal Account | +| [test-svm-balance.ts](examples/test-svm-balance.ts) | Solana token balance helpers used for integration testing | ## Benchmark diff --git a/package.json b/package.json index 7ef98cf..033893c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@ethersproject/wallet": "^5.8.0", - "@particle-network/universal-account-sdk": "^1.1.0", + "@particle-network/universal-account-sdk": "^1.1.1", "@polymarket/clob-client": "^5.2.1", "@solana/spl-token": "^0.4.14", "dotenv": "^16.4.7",