# dg-world-marketplace-sdk

> BAG Marketplace SDK Library

Latest version **2.1.6** (published 2024-06-14) · 0 weekly downloads

## Install

```sh
npm install dg-world-marketplace-sdk
pnpm add dg-world-marketplace-sdk
yarn add dg-world-marketplace-sdk
bun add dg-world-marketplace-sdk
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.6 |
| Published | 2024-06-14 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 3 |
| Unpacked size | 675.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | pvtallulah |
| Maintainers | mnahara |
| Keywords | dcl, decentraland, sdk, library |

## Links

- npm: https://www.npmjs.com/package/dg-world-marketplace-sdk
- Repository: https://github.com/pvtallulah/dg-world-marketplace-sdk
- Homepage: https://github.com/pvtallulah/dg-world-marketplace-sdk#readme
- Issues: https://github.com/pvtallulah/dg-world-marketplace-sdk/issues
- npm.io page: https://npm.io/package/dg-world-marketplace-sdk

## Dependencies (3)

- [eth-connect](https://npm.io/package/eth-connect.md) ^6.0.3
- [@dcl/ui-scene-utils](https://npm.io/package/@dcl/ui-scene-utils.md) ^1.8.4
- [@dcl/ecs-scene-utils](https://npm.io/package/@dcl/ecs-scene-utils.md) ^1.7.5

## Recent versions

- 2.1.6 (latest) — 2024-06-14
- 1.0.47-20230703183146.commit-4079b33 (next) — 2023-07-03
- 2.1.5 — 2024-05-14
- 2.1.4 — 2024-05-14
- 2.1.2 — 2024-04-17
- 2.1.1 — 2024-04-17
- 2.1.0 — 2024-04-17
- 2.0.1 — 2024-02-14
- 2.0.0 — 2024-02-14
- 1.0.46 — 2023-07-03
- 1.0.46-20230613195142.commit-2ee9ce5 — 2023-06-13
- 1.0.45 — 2023-06-13
- 1.0.45-20230613154329.commit-4a28545 — 2023-06-13
- 1.0.44 — 2023-06-13
- 1.0.43 — 2023-05-18
- … 73 more at https://npm.io/package/dg-world-marketplace-sdk/versions

## README

# Basic Usage

To get started with the Metaverse SDK, follow these steps:

1. Install the SDK on your Decentraland scene by running the following command:

   ```
   npm i -B dg-world-marketplace-sdk@latest
   ```

2. Add this line at the start of your game.ts file, or any other TypeScript files that require it:

   ```ts
   import {
     DgWorldMarketplace,
     MarketplaceOptions,
   } from "dg-world-marketplace-sdk";
   ```

3. Install the SDK on your Decentraland scene by running the following command:

   ```ts
   new DgWorldMarketplace({
     previewEnv: "prod" as any,
     network: "MATIC" as any,
     engine,
     zoneId: YOUR_ZONE_ID,
   });
   ```

# Advanced Usage

For more complex projects, the Metaverse SDK offers additional features and customization options to help developers achieve their desired outcomes. Some advanced usage scenarios include:

1. Install the SDK on your Decentraland scene by running the following command:

   ```
   npm i -B dg-world-marketplace-sdk@latest
   ```

2. Add this line at the start of your game.ts file, or any other TypeScript files that require it:

   ```ts
   import {
     DgWorldMarketplace,
     MarketplaceOptions,
   } from "dg-world-marketplace-sdk";
   ```

3. Then while initializing the DgWorldMarketplace Class you have all of the following parameters:

   ```ts
   const opts: MarketplaceOptions = {
     previewEnv: "prod" as any,
     network: "MATIC" as any,
     engine,
     zoneId: YOUR_ZONE_ID,
     debug: true,
     lang: {
       noFundsTitle: "No Funds",
       noFundsDesc: "Sorry, you do not have enough BAG",
       noFundsButton: "No Funds",
       approveIceTitle: "Approve BAG",
       approveIceDesc:
         "Authorize the Store contract to operate BAG on your behalf",
       approveIceWait: "Please wait. The transaction is being processed",
       approveIceRejected:
         "You need to authorize the Store contract to be able to buy this item",
       buyFor: "Buy for:",
       authorize: "Authorize",
       reject: "Reject",
       transactionProccessing:
         "Please wait. The transaction is being processed",
       purchaseSucceed:
         "Purchased succeed! You will need to refresh the page to see the wearable in your backpack.",
       purchaseFailed: "Purchased failed. Please try again.",
       wait: "Wait",
       buy: "Buy",
       openPaymentLink: "Open Payment Link",
       nftNotAvailable: "NFT not available",
     },
   };
   const dgMarketplace = new DgWorldMarketplace(opts);
   ```

4. Keep in mind that the Decentraland SDK only supports one canvas. Therefore, if you want to use your own canvas instead of the one generated by the Marketplace SDK, you need to pass that canvas as a parameter when instantiating the Marketplace SDK.

   ```ts
   const opts: MarketplaceOptions = {
     // other options
     canvas: yourCanvasInstance,
   };
   ```

5. After instantiating the class, we can listen to the different events that we want.

   ```ts
   // emited when the sdk is ready to connect to the blockchain
   dgMarketplace.on("web3Ready", () => {
     log("web3Ready");
   });

   // emited after the sdk connect to the websocket
   dgMarketplace.on("websocketsReady", () => {
     log("websocketsReady");
   });

   // emited after the sdk fetch the variables
   dgMarketplace.on("variablesReady", () => {
     log("variablesReady");
     log(dgMarketplace.getVariables());
   });

   // emited last, when all the sdk is ready
   dgMarketplace.on("ready", () => {
     log("ready");
   });

   // emited when any error happens, notice that err could be null or undefined, depending on the error
   dgMarketplace.on("error", (err) => {
     log(err);
   });
   ```

---
_Source: https://npm.io/package/dg-world-marketplace-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
