🔹Use in Node.js
Use in Node.js
Using Glacier SDK in Node.js is very easy and only requires a few steps:
Install the SDK
Execute commands in your Node.js project
pnpm add @glacier-network/client
Import SDK
To use SDK, you only need to import the GlacierClient class in @glacier-network/client and then create an instance, for example:
import { GlacierClient } from '@glacier-network/client';
const arweaveEndpoint = 'https://p0.onebitdev.com/glacier-gateway';
// const filEndpoint = ''https://web3storage.onebitdev.com/glacier-gateway';
// const greenFieldEndpoint = 'https://greenfield.onebitdev.com/glacier-gateway';
const client = new GlacierClient(arweaveEndpoint);
The first parameter of the instantiation is the address of the Glacier node to be connected.
After the instantiation is completed, the read-only query of the Glacier data can be executed through the client. If you want to write or modify the data, you need to specify your own Ethereum wallet private key when creating the instance:
import { GlacierClient } from '@glacier-network/client';
const privateKey = `0xf7311f908890f7aeaf46d0185cf4234ae926cf896b2c50590d6735a37c827045`;
const client = new GlacierClient('https://p0.onebitdev.com/glacier-gateway', {
privateKey,
});
Now you can read and write data, a complete sample project as below:
https://github.com/Glacier-Labs/js-glacier/tree/main/apps/sdk-example
Supported Endpoint
| DA Chain | Endpoint | Status |
|---|---|---|
| Arweare | https://p0.onebitdev.com/glacier-gateway | Mainnet |
| BNB Greenfield | https://greenfield.onebitdev.com/glacier-gateway | Mainnet |
| Filecoin | https://web3storage.onebitdev.com/glacier-gateway | Testnet |
| BNB Greenfield Vector | https://greenfield.onebitdev.com/glacier-gateway | Testnet |
Now We supported Arweave/Filecoin/BNB Greenfield As Glacier DA Layer. Current Version these DA Layers are isolated, we will make them configurable and dynamic in the future.