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

@mantleio/contracts

v0.3.0

Published

[Mantle] L1 and L2 smart contracts for Mantle

Downloads

1,069

Readme

Optimism Smart Contracts

codecov

@eth-optimism/contracts contains the various Solidity smart contracts used within the Optimism system. Some of these contracts are meant to be deployed to Ethereum ("Layer 1"), while others are meant to be deployed to Optimism ("Layer 2"). Within each contract file you'll find the network upon which the contract is meant to be deloyed, listed as either EVM (for Ethereum) or OVM (for Optimism). If neither EVM nor OVM are listed, the contract is likely intended to be used on either network.

Usage (npm)

You can import @eth-optimism/contracts to use the Optimism contracts within your own codebase. Install via npm or yarn:

npm install @eth-optimism/contracts

Within your contracts:

import { SomeContract } from "@eth-optimism/contracts/path/to/SomeContract.sol";

Note that the /path/to/SomeContract.sol is the path to the target contract within the contracts folder inside of this package. For example, the L1CrossDomainMessenger contract is located at packages/contracts/contracts/L1/messaging/L1CrossDomainMessenger.sol, relative to this README. You would therefore import the contract as:

import { L1CrossDomainMessenger } from "@eth-optimism/contracts/L1/messaging/L1CrossDomainMessenger.sol";

Guide for Developers

Setup

Install the following:

Clone the repo:

git clone https://github.com/ethereum-optimism/contracts.git
cd contracts

Install npm packages:

yarn install

Running Tests

Tests are executed via yarn:

yarn test

Run specific tests by giving a path to the file you want to run:

yarn test ./test/path/to/my/test.spec.ts

Measuring test coverage:

yarn test:coverage

The output is most easily viewable by opening the html file in your browser:

open ./coverage/index.html

Compiling and Building

Compile and build the various required with the build command:

yarn build

Deploying the Contracts

Required environment variables

You must set several required environment variables before you can execute a deployment. Duplicate the file .env.example and rename your duplicate to .env. Fill out each of the environment variables before continuing.

Creating a deployment configuration

Before you can carry out a deployment, you must create a deployment configuration file inside of the deploy-config folder. Deployment configuration files are TypeScript files that export an object that conforms to the DeployConfig type. See mainnet.ts for an example deployment configuration. We recommend duplicating an existing deployment config and modifying it to satisfy your requirements.

Executing a deployment

Once you've created your deploy config, you can execute a deployment with the following command:

npx hardhat deploy --network <my network name>

Note that this only applies to fresh deployments. If you want to upgrade an existing system (instead of deploying a new system from scratch), you must use the following command instead:

npx hardhat deploy --network <my network name> --tags upgrade

During the deployment process, you will be asked to transfer ownership of several contracts to a special contract address. You will also be asked to verify various configuration values. This is a safety mechanism to make sure that actions within an upgrade are performed atomically. Ownership of these addresses will be automatically returned to the original owner address once the upgrade is complete. The original owner can always recover ownership from the upgrade contract in an emergency. Please read these instructions carefully, verify each of the presented configuration values, and carefully confirm that the contract you are giving ownership to has not been compromised (e.g., check the code on Etherscan).

After your deployment is complete, your new contracts will be written to an artifacts directory in ./deployments/<my network name>.

Verifying contract source code

Contracts will be automatically verified via both Etherscan and Sourcify during the deployment process. If there was an issue with verification during the deployment, you can manually verify your contracts with the command:

npx hardhat etherscan-verify --network <my network name>

Creating a genesis file

Optimism expects that certain contracts (called "predeploys") be deployed to the L2 network at pre-determined addresses. We guarantee this by creating a genesis file in which certain contracts are already within the L2 state at the genesis block. To create the genesis file for your network, you must first deploy the L1 contracts using the appropriate commands from above. Once you've deployed your contracts, run the following command:

npx hardhat take-dump --network <my network name>

A genesis file will be created for you at /genesis/<my network name>.json. You can then ingest this file via geth init.

Hardhat tasks

Whitelisting

Optimism has removed the whitelist from the Optimism mainnet. However, if you are running your own network and still wish to use the whitelist, you can manage the whitelist with the whitelist task. Run the following to get help text for the whitelist command:

npx hardhat whitelist --help

Withdrawing fees

Any wallet can trigger a withdrawal of fees within the SequencerFeeWallet contract on L2 back to L1 as long as a threshold balance has been reached. Fees within the wallet will return to a fixed address on L1. Run the following to get help text for the withdraw-fees command:

npx hardhat withdraw-fees --help

Security

Please refer to our Security Policy for information about how to disclose security issues with this code. We also maintain a bug bounty program via Immunefi with a maximum payout of $2,000,042 for critical bug reports.