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

@patronumlabs/nick-method

v1.1.0

Published

NPM package that facilitates generating EVM transactions adhering to Nick-Method

Downloads

14

Readme

Nick MethodSmaller

@patronumlabs/nick-method

This package provides utilities for generating transactions according to the Nick Method, supporting both normal execution transactions and deployment transactions.

Rationale

The Nick Method allows for creating contracts on different chains at the same address without centralized control of a private key, and minimizes trust in execution. These transactions are useful for:

  • Deploying contracts to the same address across multiple chains
  • Executing transactions without direct control of private keys
  • Minimizing trust requirements in transaction execution

For a full explanation, please refer to the article: Nick Method - Ethereum Keyless execution

Installation

npm install @patronumlabs/nick-method

Usage

Here's an example of how to use the package to generate and broadcast transactions:

import { ethers } from 'ethers'; // ethers@v6
import { genRawDeployment, genRawTransaction } from '@patronumlabs/nick-method';

// Example provider
const provider = new ethers.JsonRpcProvider('https://mainnet.infura.io/v3/YOUR-PROJECT-ID');

// Step 1: Generate a raw deployment transaction

// Generate a raw deployment transaction
const deploymentConfig = {
    gasLimit: 1000000,
    gasPrice: 100000000000,
    bytecode: '0x60806040',
    value: 0,
};

const deploymentResult = genRawDeployment(deploymentConfig);
console.log('Deployment Result:', deploymentResult);

// Step 2: Fund the deployment transaction

// // ------------------------------------------------------------
// // Funding should be sent to deploymentResult.deployerAddress
// // The funds to be sent equal to deploymentResult.upfrontCost
// // The contract will be created at deploymentResult.contractAddress
// // ------------------------------------------------------------

// Step 3: Broadcast the deployment transaction

// Broadcast the deployment transaction
provider.broadcastTransaction(deploymentResult.rawTx).then((tx) => {
    console.log('Deployment Transaction Hash:', tx.hash);
});

/* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */

// Step 1: Generate a raw execution transaction

// Generate a raw execution transaction
const transactionConfig = {
    gasLimit: 21000,
    gasPrice: 20000000000,
    to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
    data: '0x',
    value: ethers.parseEther('0.1'),
};

const transactionResult = genRawTransaction(transactionConfig);
console.log('Transaction Result:', transactionResult);

// Step 2: Fund the execution transaction

// ------------------------------------------------------------
// Funding should be sent to transactionResult.senderAddress
// The funds to be sent equal to transactionResult.upfrontCost
// ------------------------------------------------------------

// Step 3: Broadcast the execution transaction

// Broadcast the execution transaction
provider.broadcastTransaction(transactionResult.rawTx).then((tx) => {
    console.log('Execution Transaction Hash:', tx.hash);
});

This example demonstrates how to generate both deployment and execution transactions using the Nick Method, and how to broadcast them to the network using ethers.js.

API Reference

genRawDeployment(config: DeploymentConfig): DeploymentResult

Generates a raw deployment transaction.

genRawTransaction(config: TransactionConfig): TransactionResult

Generates a raw execution transaction.

recoverRawTransaction(rawTransaction: string): RecoveredTransactionResult

Recovers transaction details from a raw transaction string.

  • rawTransaction: The raw transaction data as a hexadecimal string.
  • Returns: An object containing the recovered transaction details.

For detailed type definitions of DeploymentConfig, DeploymentResult, TransactionConfig, TransactionResult, and RecoveredTransactionResult, please refer to the source code or TypeScript definitions.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License