New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@recallnet/sdk

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@recallnet/sdk

Core SDK for building with Recall EVM contracts

  • 0.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@recallnet/sdk

Official JavaScript/TypeScript SDK for the Recall Network.

Table of Contents

  • Background
  • Usage
  • Development
  • Contributing
  • License

Background

This package is a JS/TS SDK for the Recall Network. It is built on top of viem interfaces with Recall subnets for various operations, including managing:

  • Buckets: create buckets, add objects, get objects, delete objects, etc.
  • Credit: buy credit, approve credit usage, get credit balance, etc.
  • Accounts: get token balance, deposit funds, withdraw funds, etc.
  • Blobs: create blob manager, add blob manager, delete blob manager, etc. (note: experimental)

Usage

First, install the package:

# Note: this package is not published to NPM yet, so you need to install it from the source
pnpm add @recallnet/sdk

Recall client & wallet setup

Create a wallet client from a private key:

import { createWalletClient } from "viem";
import { privateKeyToAccount } from "viem/accounts";

import { RecallClient, testnet } from "@recallnet/sdk";

// Create a wallet client from a private key
const privateKey =
  "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6";
const walletClient = createWalletClient({
  account: privateKeyToAccount(privateKey),
  chain: testnet,
  transport: http(),
});

// Create a client from the wallet client
const recall = new RecallClient({ walletClient });

Bucket operations

// Create a bucket
const bucketManager = client.bucketManager();
const {
  result: { bucket },
} = await bucketManager.create();
console.log("Bucket created:", bucket); // 0xff00...9d

// List buckets
const { result: buckets } = await bucketManager.list();
console.log("Buckets:", buckets);

// Add an object to a bucket
const key = "hello/world";
const path = fs.readFileSync("path/to/file.txt");
const { meta } = await bucketManager.add(bucket, key, path);
console.log("Object added at:", meta?.tx?.transactionHash);

// Get an object from a bucket
const { result: object } = await bucketManager.get(bucket, key);
const contents = new TextDecoder().decode(object);
console.log("Object:", contents);

Credit operations

// Set up credit manager
const creditManager = client.creditManager();

// Buy credit
const { meta } = await creditManager.buy(parseEther("1"));
console.log("Credit bought:", meta?.tx?.transactionHash);

// Approve credit usage
const to = "0x15d34aaf54267db7d7c367839aaf71a00a2c6a65";
const { meta: approveMeta } = await creditManager.approve(to);
console.log("Credit approved:", approveMeta?.tx?.transactionHash);

// Revoke credit approval
const { meta: revokeMeta } = await creditManager.revoke(to);
console.log("Credit revoked:", revokeMeta?.tx?.transactionHash);

// Set account sponsor
const sponsor = "0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc";
const { meta: sponsorMeta } = await creditManager.setAccountSponsor(sponsor);
console.log("Account sponsor set:", sponsorMeta?.tx?.transactionHash);

// Get account details
const { result: account } = await creditManager.getAccount();
console.log("Account details:", account);

// Get credit approvals
const { result: approvals } = await creditManager.getCreditApprovals();
console.log("Credit approvals:", approvals);

// Get credit balance
const { result: balance } = await creditManager.getBalance();
console.log("Credit balance:", balance);

// Get credit stats
const { result: stats } = await creditManager.getCreditStats();
console.log("Credit stats:", stats);

Account operations

// Set up account manager
const accountManager = client.accountManager();

// Get account balance for token amount
const { result: balance } = await accountManager.balance();
console.log("Account balance:", balance);

// Get account info
const { result: info } = await accountManager.info();
console.log("Account info:", info);

// Deposit funds
const { meta } = await accountManager.deposit(parseEther("1"));
console.log("Funds deposited:", meta?.tx?.transactionHash);

// Withdraw funds
const { meta: withdrawMeta } = await accountManager.withdraw(parseEther("1"));
console.log("Funds withdrawn:", withdrawMeta?.tx?.transactionHash);

Blob operations

// Set up blob manager
const blobManager = client.blobManager();

// Get storage stats
const { result: storageStats } = await blobManager.getStorageStats();
console.log("Storage stats:", storageStats);

// Get storage usage
const { result: storageUsage } = await blobManager.getStorageUsage();
console.log("Storage usage:", storageUsage);

// Get subnet stats
const { result: subnetStats } = await blobManager.getSubnetStats();
console.log("Subnet stats:", subnetStats);

// Get blob status
const subscriber = "0x90f79bf6eb2c4f870365e785982e1f101e93b906";
const blobHash = "rzghyg4z3p6vbz5jkgc75lk64fci7kieul65o6hk6xznx7lctkmq";
const subscriptionId = "foobar";
const { result: blobStatus } = await blobManager.getBlobStatus(
  subscriber,
  blobHash,
  subscriptionId,
);
console.log("Blob status:", blobStatus);

Note: although there are other blob-specific operations (like adding or deleting blobs), they are experimental. The bucket manager is the best way to interact with blobs on the network.

Development

Install dependencies:

pnpm install

Run the tests:

pnpm run test

Build the package:

pnpm run build

Contributing

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT OR Apache-2.0, © 2024 Recall Network Corporation

FAQs

Package last updated on 17 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc