Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bosonprotocol/core-sdk

Package Overview
Dependencies
Maintainers
10
Versions
609
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bosonprotocol/core-sdk

> TODO: description

  • 1.1.1-alpha.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
increased by69.43%
Maintainers
10
Weekly downloads
 
Created
Source

@bosonprotocol/core-sdk

JS lib that facilitates interaction with the Boson Protocol contracts, subgraph and metadata storage.

Install

The core-sdk is intended to be used in combination with implementations of the Web3LibAdapter and MetadataStorage interfaces.

If you, for example, want to use the core-sdk in combination with ethers and IPFS as the metadata storage, then run

npm i @bosonprotocol/core-sdk @bosonprotocol/ethers-sdk @bosonprotocol/ipfs-storage ethers

# OR

yarn add @bosonprotocol/core-sdk @bosonprotocol/ethers-sdk @bosonprotocol/ipfs-storage ethers

We currently support the following

Usage

The following assumes the usage of the core-sdk with ethers and IPFS as the metadata storage.

Initialize

Explicit

The core-sdk can be initialized by explicitly passing in the required arguments

import { CoreSDK } from "@bosonprotocol/core-sdk";
import { EthersAdapter } from "@bosonprotocol/ethers-sdk";
import { IpfsMetadata } from "@bosonprotocol/ipfs-storage";
import { ethers } from "ethers";

// injected web3 provider
const web3Provider = new ethers.providers.Web3Provider(window.ethereum);

// initialize explicitly
const coreSDK = new CoreSDK({
  web3Lib: new EthersAdapter(web3Provider),
  subgraphUrl: "https://api.thegraph.com/subgraphs/name/bosonprotocol/cc",
  protocolDiamond: "0x5E3f5127e320aD0C38a21970E327eefEf12561E5",
  // optional
  metadataStorage: new IpfsMetadata({
    url: "https://ipfs.infura.io:5001"
  }),
  // optional
  theGraphStorage: new IpfsMetadata({
    url: "https://api.thegraph.com/ipfs/api/v0"
  })
});
Default configuration

It is also possible to use the default configuration provided through the @bosonprotocol/common package.

import { CoreSDK } from "@bosonprotocol/core-sdk";
import { EthersAdapter } from "@bosonprotocol/ethers-sdk";
import { IpfsMetadata } from "@bosonprotocol/ipfs-storage";
import { ethers } from "ethers";

// injected web3 provider
const web3Provider = new ethers.providers.Web3Provider(window.ethereum);

// initialize via default config of chainId = 3
const coreSDK = CoreSDK.fromDefaultConfig({
  web3Lib: new EthersAdapter(web3Provider),
  chainId: 3
  // ...other args
});

Metadata

For handling metadata through the core-sdk, make sure to pass an instance as a constructor argument

import { CoreSDK } from "@bosonprotocol/core-sdk";
import { IpfsMetadata } from "@bosonprotocol/ipfs-storage";

const ipfsMetadata = new IpfsMetadata({ url: "https://ipfs.infura.io:5001" });
const coreSDK = CoreSDK.fromDefaultConfig({
  // ...other args
  metadataStorage: ipfsMetadata
});

// store metadata
const cid = await coreSDK.storeMetadata(offerMetadata);

// get metadata
await coreSDK.getMetadata(cid);

Offers

TODO

Exchange token

TODO

FAQs

Package last updated on 25 Apr 2022

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