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

@newos/cli

v0.1.7

Published

Command-line interface for the NewOS

Downloads

14

Readme

NewOS Command-Line Interface (@newos/cli)

Command-line interface for NewOS.

NewOS is a platform to develop, deploy and operate smart contract projects on NewChain and every other EVM and eWASM-powered blockchain.

Install

First, install Node.js and npm. Then, install the NewOS running:

npm install --global @newos/cli

Usage

To start, create a directory for the project and access it:

mkdir my-project
cd my-project

Use npm to create a package.json file:

npm init

And initialize the NewOS project:

newos init my-project

Create file Counter.sol in directory contracts:

// contracts/Counter.sol
pragma solidity ^0.5.0;

contract Counter {
	uint256 public value;

    function increase() public {
       value++;
     }
 }

Uncomment the testnet section in networks.js and fill your mnemonic on newchain testnet:

const HDWalletProvider = require("newtruffle-hdwallet-provider");

module.exports = {
  networks: {
  	...
    testnet: {
      provider: function() { 
        return new HDWalletProvider("[Your mnemonic]", 'https://rpc1.newchain.newtonproject.org', "testnet") 
      },
      network_id: "1007"
    },
    ...

Deloy upgradeable contract to testnet:

$ newos deploy
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
? Choose the kind of deployment upgradeable
? Pick a network testnet
? Pick a contract to deploy Counter
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
✓ Contract CounterUpgradeable deployed
All implementations have been deployed
✓ Setting everything up to create contract instances
✓ Instance created at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4
To upgrade this instance run 'newos upgrade'
0x63Be78c0174A87Eadd50BffFD765889C07a38EA4

Execute the contract method:

$ newos send-tx
? Pick a network testnet
? Pick an instance Counter at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4
? Select which function increase()
✓ Transaction successful. Transaction hash: 0x7c4bbb1580f810017d0d2d158034ba3b38ae1cd053913bc3cec269c01b9e378c

Retrieve the variable value:

$ newos call
? Pick a network testnet
? Pick an instance Counter at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4
? Select which function value()
✓ Method 'value()' returned: 1
1

Change the contract Counter.sol to:

// contracts/Counter.sol
pragma solidity ^0.5.0;

contract Counter {
  uint256 public value;

  function increase(uint256 amount) public {
    value += amount;
  }
}

Upgrade the Counter contract:

$ newos upgrade
? Pick a network testnet
? Which instances would you like to upgrade? Choose by name
? Pick an instance to upgrade Counter
? Call a function on the instance after upgrading it? No
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
✓ Contract CounterUpgradeable deployed
All implementations have been deployed
✓ Instance upgraded at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4. Transaction receipt: 0x7af93f8388bf1d08b36be915116d4f2aa8ff751ec0af6fce0363eba83ebf22f2
✓ Instance at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4 upgraded

Execute the new method of upgraded contract:

$ newos send-tx
? Pick a network testnet
? Pick an instance Counter at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4
? Select which function increase(amount: uint256)
? amount: uint256: 10
⠋ Calling: 'increase' with:
✓ Transaction successful. Transaction hash: 0x50179c575116ddd64fa56733818587d38cc6a892aa54cf8ca1a6507f6d128939

Retrieve the same variable value and verify whether the upgrade is success:

$ newos call
? Pick a network testnet
? Pick an instance Counter at 0x63Be78c0174A87Eadd50BffFD765889C07a38EA4
? Select which function value()
✓ Method 'value()' returned: 11
11

License

GPLv3