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

@rocketh/diamond

v0.19.26

Published

Deploy and upgrade EIP-2535 Diamond proxies, for rocketh and hardhat-deploy.

Readme

@rocketh/diamond

EIP-2535 Diamond deployments for rocketh. You declare the set of facets the diamond should have; rocketh compares that against what is on chain and performs the diamondCut that closes the gap, adding, replacing and removing function selectors as needed.

Where @rocketh/proxy swaps one implementation wholesale, a diamond is upgraded facet by facet, and is not bound by the contract size limit.

Installation

# Using pnpm
pnpm add @rocketh/diamond

# Using npm
npm install @rocketh/diamond

# Using yarn
yarn add @rocketh/diamond

Wiring it up

@rocketh/diamond is an extension: spread its namespace into extensions in rocketh/config.ts.

// rocketh/config.ts
import * as deployExtension from '@rocketh/deploy';
import * as diamondExtension from '@rocketh/diamond';

const extensions = {
	...deployExtension,
	...diamondExtension,
};
export {extensions};

Usage

// deploy/deploy_Kingdom.ts
import {deployScript, artifacts} from '../rocketh/deploy.js';

export default deployScript(
	async ({diamond, namedAccounts}) => {
		const {deployer, admin} = namedAccounts;

		await diamond(
			'Kingdom',
			{account: deployer},
			{
				owner: admin,
				facets: [
					{artifact: artifacts.CastleFacet},
					{artifact: artifacts.ArmyFacet},
					{artifact: artifacts.TreasuryFacet, args: [treasuryAddress]},
				],
			},
		);
	},
	{tags: ['Kingdom', 'Kingdom_deploy']},
);

env.get('Kingdom') returns the diamond address with the merged ABI of every facet, so callers and frontends see one contract. The underlying proxy is also saved as Kingdom_DiamondProxy.

Note that the deployment arguments take no artifact and no args: the diamond base contract is this package's bundled one, and the facets carry their own artifacts. (Constructor arguments for the base go in diamondContractArgs.)

The facet set is declarative

facets is the desired end state, not a list of changes. Add an entry and its selectors are added; change a facet's code and its selectors are replaced; remove an entry and its selectors are removed from the diamond. That last one is the one to read carefully before running against a live deployment: deleting a line from facets deletes functionality on chain.

type FacetOptions = {
	name?: string; // defaults to the artifact's contract name
	artifact: Artifact;
	args?: any[]; // facet constructor arguments
	linkedData?: LinkedDataProvided;
	libraries?: Libraries;
	deterministic?: boolean | `0x${string}`;
};

Facets are deployed deterministically by default, so an unchanged facet keeps its address across chains and runs. Set deterministic on a facet to override that.

Use excludeSelectors when a facet exposes a function the diamond should not route:

{
	excludeSelectors: {
		TreasuryFacet: ['0x12345678'];
	}
}

Options

facets is required. The rest:

| Option | Description | | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | owner | Address that may cut the diamond. Defaults to the deployer. | | execute | Initialization call attached to a cut. See the caveat below. | | defaultCutFacet | Include the built-in DiamondCutFacet (on by default). Turning it off makes the diamond permanently un-cuttable. | | defaultOwnershipFacet | Include the built-in OwnershipFacet (on by default). | | diamondContractArgs | Constructor arguments for the diamond base contract. | | excludeSelectors | Per-facet selectors to leave out of the cut. | | facetsArgs | Default constructor arguments for every facet. A facet's own args overrides them. (linkedData and libraries work the same way: set once for all facets, overridden per facet.) | | deterministicSalt | Deploy the diamond deterministically with this salt. | | alwaysOverride / strictBytecodeMatch | Mutually exclusive re-deployment controls, as in @rocketh/deploy. |

execute rides a cut, it is not a call you schedule

execute is EIP-2535's _init / _calldata pair: a delegatecall made in the diamond's storage context as part of diamondCut.

A run that produces no facet change performs no cut, so execute does not run. This is deliberate, and it matches how @rocketh/proxy gates its own execute: deploy scripts are re-run, and an initializer that fired on every re-run would not be idempotent.

The consequence to plan around: execute is the flat form of that option, so it runs on the fresh deploy and on every later cut, with the same arguments. A migration that must run exactly once, or only on upgrades, is not expressible yet; that is the {init, onUpgrade} split @rocketh/proxy has.

Reading the cut before it happens

A diamond upgrade can remove functions, and a removal is not always obvious from a diff of your facets array. rocketh reports the cut it intends to perform; read it, and pay particular attention to the removals, before letting it run against a production diamond.

Types

enum FacetCutAction {
	Add,
	Replace,
	Remove,
}

type Facet = {facetAddress: `0x${string}`; functionSelectors: readonly `0x${string}`[]};
type FacetCut = Facet & {action: FacetCutAction};

Bundled facet and diamond artifacts are available under the ./artifacts/* and ./solc_0_8/* subpath exports.

Related packages

For full documentation, visit rocketh.dev.

For hardhat-deploy documentation, see rocketh.dev/hardhat-deploy/.