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

@openzeppelin/platform-sdk-deploy-client

v0.4.0

Published

Client library for managing Platform Deployments

Downloads

8

Readme

Platform Deployment Client

Platform Deployment Client allows you to deploy contracts through the OpenZeppelin Platform, manage deployment configuration and manage block explorer api keys.

Usage

Start by creating a new Team API Key in Platform, and granting it the capability to manage deployments. Use the newly created API key to initialize an instance of the Platform client.

const { PlatformClient } = require('@openzeppelin/platform-sdk');
const client = PlatformClient({ apiKey: API_KEY, apiSecret: API_SECRET });

Deployment

To deploy a contract you need to provide these required fields:

  • network
  • contractName
  • contractPath - The path of your contract in your hardhat project

Additionally you must provide your compilation artifact from hardhat. The compilation artifact can be found in your hardhat project folder at artifacts/build-info/{build-id}.json. Either one of these fields are required:

  • artifactPayload - JSON stringified version of the file
  • artifactUri - URI to the hosted artifact file

There are a number of optional fields depending on what you are deploying, these include:

  • constructorInputs - The inputs to your contract constructor,
  • value - ETH to be sent with the deployment.
  • salt - deployments are done using the CREATE2 opcode, you can provide a salt or we can generate one for you if none is supplied.
  • licenseType - This will be displayed on Etherscan e.g MIT.
  • libraries - If you contract uses any external libraries they will need to be added here in the format { [LibraryName]: LibraryAddress }.
  • relayerId - This property will override the default relayer assigned to the approval process for deployments. You may define this property if you wish to use a different relayer than the one assigned to the approval process in the deploy environment.

Below is an example of a contract deployment request which responds with a DeploymentResponse

await client.deploy.deployContract({
  contract: {
    contractName: 'Greeter',
    contractPath: 'contracts/Greeter.sol',
    network: 'sepolia',
    artifactPayload: JSON.stringify(artifactFile),
    licenseType: 'MIT',
    constructorInputs: ['Hello World!'],
  },
});

You can also list your deployments, which will return a DeploymentResponse[] object

await client.deploy.listDeployments();

As well as fetching a deployment via it's ID

const deploymentId = '8181d9e0-88ce-4db0-802a-2b56e2e6a7b1';
await client.deploy.getDeployedContract({ deploymentId });

You can also retrieve the deploy approval process for a given network, which will return a ApprovalProcessResponse object

await client.deploy.getDeployApprovalProcess({ network: 'sepolia' });

Upgrade

To upgrade a contract you need to provide these required fields:

  • proxyAddress
  • newImplementationAddress
  • network

There are a number of optional fields, these include:

  • proxyAdminAddress - The Proxy Admin address in case you are upgrading with a transparent proxy.
  • newImplementationABI - The ABI of the new implementation address. This will be required if the implementation contract does not exist in the OpenZeppelin Platform.
  • approvalProcessId - The approval process ID in case you wish to override the default global approval process.
  • senderAddress - The address you wish to create the Gnosis proposal with. When creating an upgrade proposal, we provide you with an external link to the Gnosis Safe UI. This will lead you to a proposal ready to be signed. This proposal will contain information about what upgrade to execute, as well as who initiated the proposal. The senderAddress property lets you customise define which address this is.

Below is an example of a contract upgrade request which responds with a UpgradeContractResponse

await client.deploy.upgradeContract({
  upgradeParams: {
    proxyAddress: '0xABC1234...',
    proxyAdminAddress: '0xDEF1234...',
    newImplementationABI: JSON.stringify(boxABIFile),
    newImplementationAddress: '0xABCDEF1....',
    network: 'sepolia',
  },
});

You can also retrieve the upgrade approval process for a given network, which will return a ApprovalProcessResponse object

await client.Upgrade.getDeployApprovalProcess({ network: 'sepolia' });

Block Explorer Verification

In order to have your contract source code verified on Etherscan you must provide your Etherscan Api Keys along with the network those keys will belong to. If you want to use the same Api Key for 2 different networks, e.g Ethereum Mainnet and Sepolia Testnet, you must add the Api Key for both networks individually.

await client.deploy.createBlockExplorerApiKey({
  key: 'RKI7QAFIZJYAEF45GDSTA9EAEKZFW591D',
  network: 'sepolia',
});

You can list your Api Keys, which will return a BlockExplorerApiKeyResponse[] object

await client.deploy.listBlockExplorerApiKeys();

As well as fetching a your Api Key via it's ID

const apiKeyId = '8181d9e0-88ce-4db0-802a-2b56e2e6a7b1';
await client.deploy.getBlockExplorerApiKey({ apiKeyId });

And updating the Api Key for a given network

const apiKeyId = '8181d9e0-88ce-4db0-802a-2b56e2e6a7b1';
await client.deploy.updateBlockExplorerApiKey({
  apiKeyId,
  { key: 'LDNWOWFNEJ2WEL4WLKNWEF8F2MNWKEF' },
});