@jigglyjams/juice-sdk-v3
v3.2.2-alpha
Published
🧃 A JavaScript SDK for the [Juicebox V2 protocol](https://github.com/jbx-protocol/juice-contracts-v2).
Downloads
9
Readme
juice-sdk
🧃 A JavaScript SDK for the Juicebox V2 protocol.
⚠️ This library is experimental and we provide no guarantees. Use at your own risk.
Overview
juice-sdk
helps you interact with the Juicebox V2 contracts using JavaScript.
Supports your favorite dev environment:
- ✅ Node.js
- ✅ Typescript
- ✅ Webpack (supports tree-shaking)
- ✅ Rollup (supports tree-shaking)
- ✅ Vite (supports tree-shaking)
Check out the examples to get started 🚀.
Installation
npm install juice-sdk
Usage
Import the factory function for a Juicebox contract.
import { getJBDirectory } from 'juice-sdk';
Create a JsonRpcProvider. The example below uses the ethers library.
import { JsonRpcProvider } from '@ethersproject/providers'; // ...); const provider = new JsonRpcProvider(YOUR_GATEWAY_HOST_URL);
Call the factory function to get an instance of the ethers.js
Contract
.const JBDirectory = getJBDirectory(provider);
Start interacting with the contract.
const const terminals = await JBDirectory.terminalsOf(projectId);
Usage on Rinkeby
Juicebox is deployed on Ethererum mainnet and the Rinkeby testnet. To use the
Rinkeby contract addresses, set the network
argument to rinkeby
when loading
the given contract:
const JBDirectory = getJBDirectory(provider, { network: 'rinkeby' });
Examples
Inspect the examples/
directory to learn how to use juice-sdk
for your
project.
| Environment | Example | | ------------------------------ | ---------------------------------------------------------------------------------------------------------------- | | node.js | ./examples/node | | node.js with Typescript | ./examples/typescript-node | | create-react-app (webpack) | ./examples/create-react-app | | Vue | ./examples/vue | | Svelte | ./examples/svelte | | Vanilla JavaScript (with Vite) | juice-tools/embed/project/balance |