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

@nori-dot-com/contracts

v1.6.5

Published

## 🏗️ Integrations

Downloads

14

Readme

Nori marketplace smart contracts

🏗️ Integrations

JavaScript/TypeScript

This package can be used in your project by installing it the package:

yarn add -D @nori-dot-com/contracts

Then, in your solidity code, you can import the contracts you need:

import "@nori-dot-com/contracts/contracts/Market.sol";

Solidity

Foundry

forge install nori-dot-eco/contracts

Note You may also need to configure path remapping if you are using foundry.

Hardhat/Truffle

yarn add -D @nori-dot-com/contracts @openzeppelin/[email protected] [email protected]

Then, in your solidity code, you can import the contracts you need:

import "@nori-dot-com/contracts/contracts/Market.sol";

:notebook_with_decorative_cover: Documentation

Refer to the contracts README for detailed documentation about how each smart contract works.

:woman_technologist: Development

Setup

Make sure to initialize submodules

git submodule update --init --recursive

Then install dependencies

yarn install && foundryup

Finally, make sure you set the necessary environment variables (refer to the default dotenv file for a list of supported variables)

Deploying contracts locally

You can run the following command to start a hardhat node:

hardhat node

This command will do the following:

  1. Start a local node with a new instance of a locally running chain.
  2. Seed test wallets with funds.
  3. Run the deployment scripts which seed the test contracts.

Deploying the market contracts on a live network

Note that you will need to have SOLC_PROFILE environment variable configured as production or the deployment will be prevented. The following command will deploy new implementations and upgrade the existing proxies if they exist.

hardhat deploy --network [networkName] --tags market

TODO: documentation around how to deploy and force the deployment of fresh proxies as well.

Testing

To serially run the hardhat test suite followed by the forge test suite, run the following:

yarn test

Hardhat

To run just the typescript test suite using hardhat, run the following command:

yarn test:hardhat

Forge

To run just the solidity test suite using forge, run the following command:

yarn test:forge

Gas reports

To generate gas reports, run the following command:

yarn snapshot

The resulting snapshot file should be checked-in with every PR.

You can also run yarn snapshot:production to generate a snapshot using production compiler settings or yarn snapshot:test to use the fastest compiler settings.

:construction_worker: Hardhat Tasks

Interact with contracts

Custom hardhat tasks have been implemented that allow for calling functions on deployed contracts.

hardhat [contract name] --func [function name] [arguments] --network [network name]
hardhat NORI \
  --func mint \
  "0x321af43416f670ce8b4ba214dfb87c4199e2a77f" \
  1000000000000000000 \
  "0x" \
  "0x" \
  --network goerli
hardhat BridgedPolygonNORI \
  --func deposit \
  0x6dc772f80495f47d8000530a59ee975b67b7c646 \
  "0x0000000000000000000000000000000000000000000000056bc75e2d63100000" \
  --network mumbai

:information_source: Note that the final argument (0x0000000000000000000000000000000000000000000000056bc75e2d63100000) is a uint256 bytes-encoded representation of 100 bpNORI.

Generate contract documentation

Generate documentation for contracts using the following command:

yarn docgen # runs hardhat docgen

Running this command will re-generate the contract documentation in the docs folder. Note that the template used to generate the documentation is located in the sub-folder called templates.

Accounts

Print the named accounts used for development and testing

hardhat accounts

:ninja: Tips and tricks

Connecting to your local node from MetaMask

You can connect to your local node from MetaMask by adding giving it a custom RPC configuration. For example, if you are using the default hardhat network configuration (e.g., if your node was started via hardhat node), then you can connect to it by adding a custom RPC configuration with the following values:

| RPC URL | Chain ID | | ----------------------- | -------- | | http://localhost:8545 | 9001 |

For more, refer to the official MetaMask documentation on this topic.

Ethernal

Ethernal is an etherscan-style interface for your local hardhat node. Sign up for a free account and run your local node with the following extra variables to have contract ABIs and transactions synced there for viewing / interacting with.

ETHERNAL=true \
ETHERNAL_EMAIL="[email protected]" \
ETHERNAL_PASSWORD="xxxxxx_yyyyyyyy" \
hardhat node

For more, refer to the official hardhat-ethernal documentation.

Foundry

Forge

Solidity Scripting

Foundry offers the ability to write scripts in solidity that foundry can then run (via forge script) to create and send real transactions to a specified network.

For an overview, checkout the official tutorial here.

For these scripts to work, the following environment variables must be set in your environment:

MUMBAI_RPC_URL # The RPC URL for the mumbai network
MNEMONIC # The mnemonic you want to use to sign your transaction with

:information_source: The first index of the $MNEMONIC HD path needs to be funded with MATIC, have the correct permissions to make the contract calls, etc.

:information_source: Our on-chain market on mumbai was deployed with a fireblocks signer, so we have been using the fireblocks signer from the command line with hardhat tasks to grant necessary permissions to other addresses that we may want to use.

Here is the hardhat command for granting the CONSIGNOR_ROLE to an address (hardhat is currently required to use a fireblocks signer):

hardhat \
  --network mumbai \
  Removal \
  --func grantRole \
  `cast call 0xa051E9EeaC803d2fCA1DbF415b78AD9BfEB723b0 "CONSIGNOR_ROLE()" --rpc-url mumbai` `# The bytes32 representation of the CONSIGNOR_ROLE` \
  0x465d5a3fFeA4CD109043499Fa576c3E16f918463

See forge script --help for many more command line options to the scripting.

A description of how to run some example scripts can be found in the examples below this section.

forge script \
  script/MintAndListRemovals.s.sol:MintAndListRemovals \
  --rpc-url mumbai \
  --mnemonics=$MNEMONIC \
  --broadcast \
  -vvvvv

:information_source: Transactions for minting removals have at times seemed really slow on mumbai (taking almost 15 minutes to get included).

forge script \
  script/MintBPNori.s.sol:MintBPNori.sol \
  --rpc-url mumbai \
  --mnemonics=$MNEMONIC \
  --broadcast \
  -vvvv

Cast

Sending transactions

You can use cast send to send transactions and interact with deployed contracts.

The following deposits 100 bpNORI to $TO_ADDRESS on mumbai (the first account of the $MNEMONIC must have the DEPOSITOR_ROLE role).

cast send \
  --mnemonic=$MNEMONIC
  --rpc-url mumbai \
  $TO_ADDRESS \
  "deposit(address,bytes)" \
  $BP_NORI_ADDRESS \
  `cast --to-uint256 100000000000000000000`

Autocomplete

To set up autocomplete for the foundry CLI tools, follow the instructions here.

Hardhat

Autocomplete

To set up autocomplete for hardhat follow the instructions in the docs.

Autocomplete

  1. For ZSH (omz), add the following to your zsh config file (requires zsh-completions)
# https://github.com/zsh-users/zsh-completions
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src \
autoload -U compinit && compinit