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

embark-vyper

v6.0.0

Published

Embark wrapper for the Vyper compiler

Downloads

69

Readme

embark-vyper

Embark wrapper for the Vyper compiler

Step 1. Install the Embark Vyper plugin

Installing the Embark Vyper plugin in our ÐApp is extremely simple:

  1. Add the embark-vyper package to your ÐApp:
yarn add embark-vyper
# OR
npm i embark-vyper
  1. Add the embark-vyper plugin to embark.json:
// embark.json

// ...
"plugins": {
  "embark-ipfs": {},
  "embark-swarm": {},
  "embark-whisper-geth": {},
  "embark-geth": {},
  "embark-parity": {},
  "embark-profiler": {},
  "embark-graph": {},
  "embark-vyper": {} // <====== add this!
},
// ...

Step 2. Add a Vyper contract to your ÐApp

For the purposes of this guide, let's delete the existing SimpleStorage Solidity contract that comes with the Embark Demo by default if it exists:

rm -rf contracts/simple_storage.sol

Next, let's create a Vyper contract in the contracts folder of our ÐApp, ie contract/SimpleStorage.vy (case is important):

# contracts/SimpleStorage.vy

storedData: public(int128)

@public
def __init__(_x: int128):
  self.storedData = _x

@public
def set(_x: int128):
  self.storedData = _x

The function of this contract is simple: upon creation (deployment), it will store the value we initially give it during deployment. We also have access to a set() that will allow to set the value stored in the contract.

Changing the contract filename

Because Vyper's constructor is called __init__, Embark must take the contract class name from the file name. If you'd prefer to change the name of your contract file to something else like contracts/simple_storage.vy, you'll need to update config/contract.js to allow Embark to match a contract configuration to a contract file:

// config/contracts.js

module.exports = {
  default: {
    // ...
    deploy: {
      simple_storage: {
        fromIndex: 0,
        args: [100]
      }
    }
    // ...
  }
}

Please see the Embark smart contract configuration documentation for more information on how to configure contracts in Embark.

Step 3. Run Embark

Now that we have installed and configured everything, let's run Embark and watch the magic!

embark run --nodashboard --nobrowser

Assuming we kept the file name SimpleStorage.vy from step 4, we should see the following output in the console:

compiling Vyper contracts...
deploying contracts
Deploying SimpleStorage with 144379 gas at the price of 2000000000 Wei. Estimated cost: 288758000000000 Wei  (txHash: 0x370a864b12b1785b17180b2a10ec2f941a15638eeffadfecf5bbe68755a06f14)
SimpleStorage deployed at 0x5Baf4D88bC454537C51CEC7568a1E23400483abc using 135456 gas (txHash: 0x370a864b12b1785b17180b2a10ec2f941a15638eeffadfecf5bbe68755a06f14)

Troubleshooting

There are a few common issues you may experience when Embark attempts to compile and deploy your Vyper contracts.

Vyper is not installed on your machine

Vyper is not installed on your machine
You can install it by visiting: https://vyper.readthedocs.io/en/latest/installing-vyper.html

This means that the binary vyper cannot be found on your machine. If you're running *nix, you can verify this by running:

which vyper
# expected output: path/to/virtual-env/bin/vyper
# actual output: vyper not found

If vyper was installed in a virtual environment, you may have forgotten to active the environment, ie:

source path/to/vyper-env/bin/activate

If vyper was not installed in a virual environment, it means either your PATH environment variable needs to be updated to point to the directory where the vyper binary is installed. You can inspect your PATH environment variable by:

echo $PATH

And update it with the path to the directory containing the vyper binary using:

export PATH=/path/to/vyper/dir:$PATH

Error deploying contract

SimpleStorage has no code associated
did you mean "simple_storage"?
deploying contracts
Error deploying contract simple_storage
[simple_storage]: Invalid number of parameters for "constructor". Got 0 expected 1!
Error deploying contracts. Please fix errors to continue.

This means that the contract simple_storage is a file in contracts/ and expected to be deployed by Embark, but is not configured for deploy in the contracts configuration. This could be the result of changing the filename of the Vyper contract to simple_storage.vy, but not updating the contracts configuration, as outlined in step 2.

Visit framework.embarklabs.io to get started with Embark.