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

@lacchain/truffle-gas-model-provider

v1.0.0

Published

Truffle Gas Model for LACChain Networks

Downloads

16

Readme

@lacchain/gas-model-provider

Truffle Provider. Use it to sign transactions using the LACChain Gas Model.

Install

$ npm install @lacchain/truffle-gas-model-provider

Requirements

Node >= 12 
Web3 ^1.2.0

General Usage

You can use this provider wherever a Web3 provider is needed, not just in Truffle. For Truffle-specific usage, see next section.

By default, the GasModelProvider will use the address of the first address that's generated from the mnemonic. If you pass in a specific index, it'll use that address instead.

Instantiation

You can instantiate gas-model-provider with options passed in an object with named keys. You can specify the following options in your object:

Parameters:

| Parameter | Type | Default | Required | Description | |---------------------| ---- | ------- | ----------- | -- | | mnemonic | object\|string | null | [ ] | Object containing phrase and password (optional) properties. phrase is a 12 word mnemonic string which addresses are created from. Alternately the value for mnemonic can be a string with your mnemonic phrase. | | privateKeys | string[] | null | [ ] | Array containing 1 or more private keys. | | providerOrUrl | string\|object | null | [x] | URI or Ethereum client to send all other non-transaction-related Web3 requests | | nodeAddress | string | null | [ ] | Node Address. | | expiration | number | null | [ ] | Expiration. | | addressIndex | number | 0 | [ ] | If specified, will tell the provider to manage the address at the index specified | | numberOfAddresses | number | 1 | [ ] | If specified, will create numberOfAddresses addresses when instantiated | | shareNonce | boolean | true | [ ] | If false, a new WalletProvider will track its own nonce-state | | derivationPath | string | "m/44'/60'/0'/0/" | [ ] | If specified, will tell the wallet engine what derivation path should use to derive addresses. | | pollingInterval | number | 4000 | [ ] | If specified, will tell the wallet engine to use a custom interval when polling to track blocks. Specified in milliseconds. | | chainId | number\|string | undefined | [ ] | Specify to enable signed transactions that are EIP-155 compliant for major chains. |

To include in your truffle-config.js

networks: {
    network_name: {
        provider: () => new GasModelProvider( PRIVATE_KEY, NODE_RPC, NODE_ADDRESS, EXPIRATION ),
        network_id: "*",
        gas: 115500000,
        gasPrice: 0,
        from: ADDRESS
    }
}

Where: - PRIVATE_KEY: is the Private Key of the ADDRESS - ADDRESS: is the Ethereum address of the tx sender - NODE_ADDRESS: is the Node Address in the Gas Model - EXPIRATION: is the expiration time in the Gas Model - RPC: is the RPC url of the writer node

Some other examples can be found below:

const HDWalletProvider = require("@lacchain/truffle-gas-model-provider");
const Web3 = require("web3");
const mnemonicPhrase = "mountains supernatural bird..."; // 12 word mnemonic
let provider = new GasModelProvider({
  mnemonic: {
    phrase: mnemonicPhrase
  },
  providerOrUrl: "http://localhost:8545",
  nodeAddress: '0xd00e6624a73f88b39f82ab34e8bf2b4d226fd768',
  expiration: 1736394529
});

// Or, alternatively pass in a zero-based address index.
provider = new GasModelProvider({
  mnemonic: mnemonicPhrase,
  providerOrUrl: "http://localhost:8545",
  addressIndex: 5,
  nodeAddress: '0xd00e6624a73f88b39f82ab34e8bf2b4d226fd768',
  expiration: 1736394529
});

// Or, use your own hierarchical derivation path
provider = new GasModelProvider({
  mnemonic: mnemonicPhrase,
  providerOrUrl: "http://localhost:8545",
  numberOfAddresses: 1,
  shareNonce: true,
  derivationPath: "m/44'/137'/0'/0/",
  nodeAddress: '0xd00e6624a73f88b39f82ab34e8bf2b4d226fd768',
  expiration: 1736394529
});

// To make HDWallet less "chatty" over JSON-RPC,
// configure a higher value for the polling interval.
provider = new GasModelProvider({
  mnemonic: {
    phrase: mnemonicPhrase
  },
  providerOrUrl: "http://localhost:8545",
  pollingInterval: 8000,
  nodeAddress: '0xd00e6624a73f88b39f82ab34e8bf2b4d226fd768',
  expiration: 1736394529
});

// HDWalletProvider is compatible with Web3. Use it at Web3 constructor, just like any other Web3 Provider
const web3 = new Web3(provider);

// Or, if web3 is alreay initialized, you can call the 'setProvider' on web3, web3.eth, web3.shh and/or web3.bzz
web3.setProvider(provider)

// ...
// Write your code here.
// ...

// At termination, `provider.engine.stop()' should be called to finish the process elegantly.
provider.engine.stop();

Note: If both mnemonic and private keys are provided, the mnemonic is used.

Copyright 2022 LACChain

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.