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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@opengem/contracts

v1.1.4

Published

[![NPM Package](https://img.shields.io/npm/v/@opengem/contracts.svg)](https://www.npmjs.org/package/@opengem/contracts)

Downloads

8

Readme

OpenGem | contracts

NPM Package

The standard for secure NFT offering sovereignty for creators and the best level of ownership for owners. Feel free to visit our products on OpenGem.

Overview

OpenGem contracts help you to enforce ownership for your owners. To make your work easier, all our contracts are extensions to the ERCs provided by OpenZeppelin.

Installation

npm install @opengem/contracts

Once installed, you can use the contracts in the library by importing them like in this example:

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@opengem/contracts/token/ERC721/extensions/ERC721PermanentURIs.sol";

ERC721PermanentURIs

ERC721PermanentURIs.sol is an implementation of ERC721 with a permanent storage based token URI management. It comes with _addPermanentBaseURI(), _addPermanentTokenURI()() and _addPermanentGlobalURIs. These functions let you add permanent URIs in the contract. By using this implementation, no one can alter or delete these URIs.

_addPermanentBaseURI

Set your base URIs for all the tokens. _addPermanentBaseURI() takes two arguments :

  • prefixURI (string)
  • suffixURI (string)

As output, it concatenates prefixURI + tokenID + suffixURI.

Usage

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@opengem/contracts/token/ERC721/extensions/ERC721PermanentURIs.sol";

contract Example is ERC721, ERC721PermanentURIs {
    constructor()
        ERC721("ExampleToken", "ETK") {
            _addPermanentBaseURI('ipfs://QmXXX/', '.json');
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721PermanentURIs) {
        super._burn(tokenId);
    }
}

In this example, we set an IPFS CID that is common for all the tokens. We just added ".json" as suffix that comes after the tokenID in the naming files. Each minted token will be attached to its specific link ("ipfs://QmXXX/1.json", "ipfs://QmXXX/2.json", etc.). If there is no suffix in your implementation, just put an empty string. You can add as many CID/hash as you want if you need to multiply permanent storage providers. These URIs are publicly accessible.

Notice: as you see above, you need to override the native _burn() function as the extension is using it.

_addPermanentTokenURI

You can set individual URIs for each minted tokens if you need to. _addPermanentTokenURI() takes two arguments :

  • tokenId (uint256)
  • uri (string)

Usage

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@opengem/contracts/token/ERC721/extensions/ERC721PermanentURIs.sol";

contract Example is ERC721, ERC721PermanentURIs {
    constructor()
        ERC721("ExampleToken", "ETK") {
            _addPermanentBaseURI('ipfs://QmXXX/', '.json');
    }

    function safeMint(address to, uint256 tokenId) public {
        _safeMint(to, tokenId);
        _addPermanentTokenURI(tokenId, 'arweave.net/Xxxx');
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721PermanentURIs) {
        super._burn(tokenId);
    }
}

In this example, we set a specific Arweave hash for the minted token asset. You can add as many token URIs as you want if you need to multiply permanent storage providers for a token. These URIs are publicly accessible.

_addPermanentGlobalURIs

In case all the tokens share the same metadata, you may need to set global URIs. _addPermanentGlobalURIs() takes one argument :

  • uri (string)

Usage

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@opengem/contracts/token/ERC721/extensions/ERC721PermanentURIs.sol";

contract Example is ERC721, ERC721PermanentURIs {
    constructor()
        ERC721("ExampleToken", "ETK") {
            _addPermanentGlobalURIs('arweave.net/Yyyy');
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721PermanentURIs) {
        super._burn(tokenId);
    }
}

In this example, we set an Arweave hash that is attached to all the minted tokens. You can add as many token URIs as you want if you need to multiply permanent storage providers. These URIs are publicly accessible.

Outputs

ERC721PermanentURIs will render a publicly accessible read function:

  • tokenURIsPermanent(uint256 tokenID)

As output it gives an array of URIs attached to the token. According to the above example, from Etherscan we get :