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

@0xver/solver

v10.2.2

Published

Basic building blocks for smart contract development

Downloads

4

Readme

Solver

License: AGPL v3

Basic building blocks for smart contract development

Module Directory

auth
│  ├─ extensions
│  │  ├─ Operator — "Operator extension for the ERC173 implementation"
├─ ERC173 — "Implementation of the ERC173 standard"
interface
│  ├─ errors
│  │  ├─ extensions
│  │  │  ├─ IOperatorErrors — "ERC173 operator extension errors interface"
│  │  ├─ IERC173Errors — "ERC173 errors interface"
│  │  ├─ IERC721Errors — "ERC721 errors interface"
│  ├─ extensions
│  │  ├─ IOperator — "ERC173 operator extension interface"
│  ├─ metadata
│  │  ├─ IERC20Metadata — "ERC20Metadata standard interface"
│  │  ├─ IERC721Metadata — "ERC721Metadata standard interface"
│  ├─ receiver
│  │  ├─ IERC721Receiver — "ERC721Receiver standard interface"
├─ IERC20 — "ERC20 standard interface"
├─ IERC165 — "ERC165 standard interface"
├─ IERC173 — "ERC173 standard interface"
├─ IERC721 — "ERC721 standard interface"
library
├─ Encode — "Encoding operations"
├─ Log — "Log operations"
├─ Merkle — "Merkle proof"
supports
├─ ERC165 — "Implementation of the ERC165 standard"
token
├─ metadata
│  ├─ ERC20Metadata — "Implementation of the ERC20Metadata standard"
│  ├─ ERC721Metadata — "Implementation of the ERC721Metadata standard"
├─ ERC20 — "Implementation of the ERC20 standard"
├─ ERC721 — "Implementation of the ERC721 standard"

NFT Smart Contract Example

// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity ^0.8.4;

import "@0xver/solver/supports/ERC165.sol";
import "@0xver/solver/auth/extensions/Operator.sol";
import "@0xver/solver/token/metadata/ERC721Metadata.sol";

contract NFT is ERC165, Operator, ERC721Metadata {
	error QuantityLimit(
		uint256 quantity,
		uint256 txnLimit,
		uint256 totalSupplyLimit
	);

	uint256 userTxnLimit = 10;
	uint256 authTxnLimit = 100;
	uint256 totalSupplyLimit = 10000;

	constructor()
		ERC721Metadata("Non-fungible Token", "NFT")
		Operator(msg.sender)
	{}

	function mint(uint256 _quantity) public {
		_eoaOnly();
		if (
			_quantity + totalSupply() > totalSupplyLimit ||
			_quantity > userTxnLimit
		) {
			revert QuantityLimit(_quantity, userTxnLimit, totalSupplyLimit);
		}
		_mint(msg.sender, _quantity);
	}

	function airdrop(address _to, uint256 _quantity) public operatorship {
		if (
			_quantity + totalSupply() > totalSupplyLimit ||
			_quantity > authTxnLimit
		) {
			revert QuantityLimit(_quantity, authTxnLimit, totalSupplyLimit);
		}
		_mint(_to, _quantity);
	}

	function supportsInterface(
		bytes4 interfaceId
	) public pure virtual override(ERC165) returns (bool) {
		return
			interfaceId == type(IERC173).interfaceId ||
			interfaceId == type(IERC721).interfaceId ||
			interfaceId == type(IERC721Receiver).interfaceId ||
			interfaceId == type(IERC721Metadata).interfaceId ||
			super.supportsInterface(interfaceId);
	}
}

Safety

It is important to consider all security risks when coding a smart contract, such as reentrancy attacks. The ERC721 and ERC20 implementations come with built-in externally owned account (EOA) only checks called _eoaOnly(), which should be used in most cases for public mint functions. Here is an example using an ERC721 implementation:

function mint() public {
	_eoaOnly();

	/// Mint logic

	_safeMint(msg.sender);
}

Major improvements for this software begin at version 10.0.0. Only use version 10.0.0 or later for production. ALWAYS review contracts before using as they are not audited.

This is experimental software and is provided on an "as is" and "as available" basis.

We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.

Installation

Install Solver:

npm install --save-dev @0xver/solver

Install Hardhat:

npm install --save-dev hardhat

Acknowledgements

These contracts were inspired by or directly modified from many sources, primarily: