npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

layerg-gamehub-js

v1.0.4

Published

## Description

Readme

LayerG Gamehub SDK

Description

LayerG Gamehub SDK is a library that provides a convenient interface for interacting with the LayerG Gamehub API. This library contains a set of methods that can be used to interact with the API, such as creating, updating, and deleting assets and collections.

Installation

npm

npm install layerg-gamehub-js

yarn

yarn add layerg-gamehub-js

pnpm

pnpm add layerg-gamehub-js

Client Initialization & Authentication

Example:

import { LayerGGamehubClient, Mode } from 'layerg-gamehub-js';

const client = new LayerGGamehubClient({
  apiKey: 'apiKey',
  apiKeyId: 'apiKeyId',
  mode: Mode.Sandbox, // mode: Defaults to Mode.Production. Choose between Mode.Sandbox (for development/testing) and Mode.Production (live environment).
  clientOptions: {
    retry: 3,
    timeout: 10000,
  },
});

const { isSuccess, error, data } = await client.authenticate();

if (!isSuccess) {
  console.error('Failed to authenticate:', error?.message);
  return;
}

// continue to call asset/collection methods here

Asset

getByTokenId

getByTokenId(input: GetByTokenIdInput): Promise<Result<Asset>>

Fetches an asset by token id within a collection.

Parameters:

  • input: GetByTokenIdInput

Example:

const input: GetByTokenIdInput = {
  collectionId: 'COLLECTION_ID',
  tokenId: 'TOKEN_ID',
};

const { data, isSuccess, error } = await client.asset.getByTokenId(input);

if (isSuccess) {
  console.log('Asset: ', data);
}

create

create(input: CreateAssetInput): Promise<Result<Asset>>

Creates a new asset.

Parameters:

  • input: CreateAssetInput

Example:

const input: CreateAssetInput = {
  name: 'test',
  description: 'test',
  tokenId: 'TOKEN_ID',
  collectionId: 'COLLECTION_ID',
  quantity: '1',
  media: {
    S3Url: '',
  },
  metadata: {
    metadata: {
      attributes: [],
    },
  },
};

const { data, isSuccess, error } = await client.asset.create(input);

if (isSuccess) {
  console.log('Created Asset: ', data);
}

update

update(input: UpdateAssetInput): Promise<Result<Asset>>

Updates an existing asset.

Parameters:

  • input: UpdateAssetInput

Example:

const input: UpdateAssetInput = {
  data: {
    name: 'test',
    description: 'test',
    tokenId: 'TOKEN_ID',
    quantity: '1',
    media: {
      S3Url: '',
    },
    metadata: {
      metadata: {
        attributes: [],
      },
    },
  },
  where: {
    collectionId: 'COLLECTION_ID',
    assetId: 'ASSET_ID',
  },
};

const { data, isSuccess, error } = await client.asset.update(input);

if (isSuccess) {
  console.log('Updated Asset: ', data);
}

delete

delete(input: DeleteAssetInput): Promise<Result<DeleteAssetSuccessResponse>>

Delete an existing asset.

Parameters:

  • input: DeleteAssetInput

Example:

const input: DeleteAssetInput = {
  collectionId: 'COLLECTION_ID',
  tokenId: 'TOKEN_ID',
};

const { data, isSuccess, error } = await client.asset.delete(input);

if (isSuccess) {
  console.log('Asset deleted!');
}

Collection

get

getById(collectionId: string): Promise<Result<Collection>>

Fetches a collection by ID.

Parameters:

  • collectionId: string

Example:

const { data, isSuccess, error } = await client.collection.getById(
  'collectionId',
);

if (isSuccess) {
  console.log('Collection: ', data);
}

create

create(input: CreateCollectionInput): Promise<Result<Collection>>

Creates a new collection.

Parameters:

  • input: CreateCollectionInput

Example:

const input: CreateCollectionInput = {
  name: 'test',
  description: 'test',
  avatarUrl: 'https://example.com/avatar.png',
  projectId: 'PROJECT_ID',
  smc: {
    contractAddress: '0x1234567890abcdef',
    contractType: 'ERC721',
    networkID: 1,
    tokenSymbol: 'TEST',
    totalSupply: 10000,
  },
};

const { data, isSuccess, error } = await client.collection.create(input);

if (isSuccess) {
  console.log('Created Collection: ', data);
}

update

update(input: UpdateCollectionInput): Promise<Result<Collection>>

Updates an existing collection.

Parameters:

  • input: UpdateCollectionInput

Example:

const input: UpdateCollectionInput = {
  data: {
    name: 'test',
    description: 'test',
    avatarUrl: 'https://example.com/avatar.png',
    projectId: 'PROJECT_ID',
    smc: {
      contractAddress: '0x1234567890abcdef',
      contractType: 'ERC721',
      networkID: 1,
      tokenSymbol: 'TEST',
      totalSupply: 10000,
    },
  },
  where: {
    collectionId: 'COLLECTION_ID',
  },
};

const { data, isSuccess, error } = await client.collection.update(input);

if (isSuccess) {
  console.log('Updated Collection: ', data);
}

public

public(collectionId: string): Promise<Result<Collection>>

Public a collection to the marketplace.

Parameters:

  • collectionId: string — The collection ID.

Example:

const { data, isSuccess, error } = await client.collection.public(
  'collectionId',
);
if (isSuccess) {
  console.log('Collection public: ', data);
}

Error Handling

All methods return { data, isSuccess, error }. If isSuccess === false, check error to get the error's cause:

const { data, isSuccess, error } = await client.asset.get(
  'assetId',
  'collectionId',
);

if (!isSuccess) {
  console.error('Fetched asset error: ', error?.cause);
  return;
}

console.log('Fetched asset successfully: ', data?.id);