2.1.2 • Published 19 days ago

dg-world-marketplace-sdk v2.1.2

Weekly downloads
-
License
-
Repository
github
Last release
19 days ago

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:

    import {
      DgWorldMarketplace,
      MarketplaceOptions,
    } from "dg-world-marketplace-sdk";
  3. Install the SDK on your Decentraland scene by running the following command:

    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:

    import {
      DgWorldMarketplace,
      MarketplaceOptions,
    } from "dg-world-marketplace-sdk";
  3. Then while initializing the DgWorldMarketplace Class you have all of the following parameters:

    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.

    const opts: MarketplaceOptions = {
      // other options
      canvas: yourCanvasInstance,
    };
  5. After instantiating the class, we can listen to the different events that we want.

    // 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);
    });
2.1.2

19 days ago

2.1.1

19 days ago

2.1.0

19 days ago

2.0.1

3 months ago

2.0.0

3 months ago

1.0.46

10 months ago

1.0.44

11 months ago

1.0.45

11 months ago

1.0.43

12 months ago

1.0.42

12 months ago

1.0.41

12 months ago

1.0.37

12 months ago

1.0.36

12 months ago

1.0.35

12 months ago

1.0.39

12 months ago

1.0.38

12 months ago

1.0.40

12 months ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.34

1 year ago

1.0.29

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago