Get Status

Embark 3.2 - Much More Than A Moonshot

Embark 3.2 - Much More Than A Moonshot

Keeping up with Embark after the team joined Status has become an impossible mission. Near-lightspeed development means we can bring you so many new features that they genuinely do not fit into one post.

As a technical writer, though, it’s the best kind of problem you can have. To help us navigate it all, here’s an index of the next iteration of developer tools for #buidling truly distributed applications:

  1. Ethereum Name Sevice (ENS)
  2. Templates
  3. Webpack (pure magic pipelines)
  4. Embark Console (REPL support)
  5. EIP 1102 (opt-in web3 providers)
  6. Vyper
  7. Swarm
  8. Contract configuration Improvements
  9. Parallel Deployment
  10. Compile Options
  11. Custom Genesis Block Comes Back
  12. Testing - Gas Costs, Code Coverage & speed Improvements
  13. Docker
  14. Miscellaneous Fixes

What's In A Name?

Embark 3.2 comes with ENS support right out the box, no matter which chain you’re working on. The Ethereum Name Service (an alternative to DNS) requires quite a few contracts and libraries in order to function correctly, and setting these up yourself - especially in your local environment - can be a real pain.

However, the joy of open source frameworks is that we get to stand on each others’ shoulders, so now you can use Embark to set up ENS for you locally, on your private chain or use the existing on Ropsten, Rinkeby or Mainnet, with one simple command.

You can even pre-register domain names in your development chain with:

In the above setup, resolving your DApp with the name ‘status.eth’ will point to “0x1a2f3b98e434c02363f3dac3174af93c1d690914”
The javascript required to call this example is just one line: let address = await EmbarkJS.Names.resolve('domain.eth’).

Oh, and embark demo has also been updated to include a “Naming (ENS)” tab to quickly showcase how to use ENS.

Everyone Gets A Template

The embark new command now has a --template option.  With this option you can either specify a known template name, or a URI containing the template.

For example:
embark new MyApp —template typescript will create a new dapp ready to use with typescript.

If you wish to create a new dapp, based on the dappcon workshop app, you can begin like this:

embark new MyDTwitter —template status-im/dappcon-workshop-dapp#start-here

This cmd will create a new DApp based on the one found here. There are also basic examples of what a more distributed Twitter, or Reddit might look like, with full support for React components that should help you get up and running really fast.

The --template option supports several URL styles and shortcuts for GitHub repositories:

  • git@github.com/ghuser/repo_name
  • https://github.com/ghuser/repo_name
  • github.com/ghuser/repo_name
  • ghuser/repo_name

You can create your own custom template. The website also has a list of available templates. Please see our list of officially supported templates.

Put That In Your Pipe

Embark 3.2 comes with a completely re-written build pipeline with full support for webpack.

By default, Embark will have its own config with many plugins pre-configured, including:

  • ES6 module import and export syntax
  • Importing CSS, SCSS, PNG, SVG & Fonts in JS
  • Support for React & JSX
  • Sourcemaps (when in development mode)
  • Optmization: minification and tree shaking (when in production mode)

However, if you want to customize the webpack configuration to your needs, you can run the command embark eject-webpack. This command outputs a webpack file named webpack.config.js to the root directory of your DApp. You can then customize it to suit your specific needs.

There are, in fact, now two different pipeline modes, production and development. Development modes creates source maps, and generally will be much faster, but also outputs bigger js files. Production is slower, but creates MUCH smaller JS files (4x-20x).

embark run uses development mode by default, while embark build uses production you can specify the mode by using the parameter -—pipeline [mode].

Raise Your Standards

Embark Console

Embark has now a full fledged REPL (Read Evaluate Print Loop) with embark console. If embark run is already running then embark console will simply connect to the same instance, otherwise it will first compile & deploy the contracts and build your dapp then make the REPL available.

The dashboard and console repo support the await keyword.

EIP 1102

Embark now supports EIP 1102, which has to do with opt-in web3 access, rather than automatic injection (with all the privacy concerns that comes with). DApps generated with Embark should be fully compatible with both existing and future versions of Status, Metamask and other DApp browsers.

We achieve this by gracefully detecting a lack of connection to any given DApp. The callback of EmbarkJS.onReady will now have an err variable. If defined, the developer can assume that no connection could be made (i.e the user is not in an Ethereum-enabled browser) and can react accordingly e.g.:

Note: Existing dapp projects should put "$WEB3" last in the priority list of the dappConnection field when in the development environment otherwise EmbarkJS will wait for the connection before moving on and connecting to your node. Ignore this if you use Metamask or Mist in development. New DApps generated by Embark 3.2 will have this change already

Updated Vyper Support

Embark now supports the latest Vyper compiler v0.1.0-beta.2.

Compilation errors are also better displayed, because better errors and safer, more expressive languages are something we all need real bad!

Better Swarm support

We are proud to present swarm-api a Javascript Library fully compatible with the latest swarm release! This library will come by default with Embark but is also available as a standalone.

Better Configuration

This graceful error detection comes along with a whole bunch of new contract configuration options that give you more granular control over what you're doing and when it happens:

deployIf - Can be used to determine whether a contract should be configured or not depending on a response from another contract.

accounts - The account index can be passed as a parameter to a contract, so if you want the first account to be passed as a param:

Password protected files - Can be used for deployment:

Parallel Deployment

Embark will now do contract deployment in parallel which massively speeds up the deployment.

As always embark will recognize if contracts are inter-dependent and make sure they are deployed in the right order.

Compile Options

The exact solidity compiler options can now be specified in embark.json in the “options” field:

Custom Genesis Block and autominer

The custom genesis block feature is back! For development or private networks you can again specify a custom genesis file. To enable this feature will need to set mineWhenNeeded: true and isDev: false. The blockchain started by embark with embark run or embark blockchain will then run a normal PoW miner but will mine only to establish a certain minimum balance & new transactions come in.

Test Yo'Self

Know your gas

Your tests will now display the gas costs for each run as well the total gas cost per test suite. This functionality will even work with a custom node...

You can also pass the --gasDetails to display the gas cost of each contract deployed individually.

Cover Me!

Embark now supports code coverage for Solidity smart contracts.

embark test --coverage will run the tests and output the coverage to the coverage/ directory.

Currently, Istanbul is supported, support for other formats will be coming soon (Coveralls, codecov).

Speedy Gonzalez

The test functionality will now detect if an embark instance is re-running and re-use the solc compiler, this results in MUCH faster tests.
It’s also possible to specify a node to connect to, if embark is specified then it will use the node already started by embark as well resulting in even faster tests.

That is:

embark test —node embark

Will connect to an Embark instance and use whatever Ethereum node that Embark instance is connected to for the tests. In some cases this results in a speedup of 10x running tests.

Alternatively, you can specify a particular node to connect to directly:

embark test --node="ws://localhost:8556"

In case all of this isn't enough for those really crazy test-driven developers out there, contract deployment also includes gas used, price and estimated cost:

Docker image

In case all the new templates and ENS support wasn't enough for you, there's also an official docker image for Embark now available here:
https://github.com/embark-framework/embark-docker

Miscellaneous:

  • Fixed race condition when embark run starts its own blockchain node
  • Fixed issue in which the templates .gitignore file was not being copied
  • Embark will now detect changes to the web server config and start/stop & change the webserver accordingly
  • Fixed contract profiler to use fuzzer average, so it stops showing ‘infinite’ in some methods
  • Fix issue in which the whisper service would be red if the web server was not configured as localhost:8000
  • Fix issue with embark graph in which not specifying any —skip option would draw connections between the contracts
  • Fixed issue in which if different test files would connect to different nodes, it could potentially cause conflicts
  • Fix issue in which embark upload would sometimes crash if embark-solc plugin was installed
  • Fix issue with embark build —contracts that would cause it to still write into the pipeline
  • Fix issue in which contracts with the same name as javascript keywords would result in a crash or unpredictable behaviour
  • Fix issue with ens non-graceful error when attempting to access an invalid resolver
  • Fix issue which console logs would damage the dashboard when connecting to another node and the node went down
  • Fixed unwanted errors when dapp couldn’t find a valid connection
  • Fix template generator in windows
  • Fix issue in which simulator wouldn’t start in very particular cases
  • If another embark node is already running, the new instance will tolerate this better and adapt
  • Removed need for ‘p-iteration’ library
  • Fix issue in which killing an external node with embark run running, could cause a dashboard damaging error log
  • Fix issue in which config like the ‘simple’ template would still attempt to start services like IPFS
  • Fix issue with whisper in which the check would show red if the dev would run the web server with something else than localhost:8000
  • Added message warning that embark uses web3.js 1.0 and linking to the documentation
  • Fix default custom account balance when using the simulator
  • Fix syncmode parameter in the geth config
  • Fix issue in which geth would sometimes cause a crash in some systems due to an unwanted log in stderr
  • Fix account initialization in the blockchain config
  • Gracefully deal with error in which a reverse lookup for a ens query doesn’t exist
  • Warn about metamask only when in dev mode
  • The log ‘writing file’ will be displayed while the file is being written rather than afterwards
  • Improve message warning about metamask being in a different chain
  • Fix handling of when no valid connection could be made
  • Embark reset cmd will also clear the webpack hard source cache
  • Fix setting default balance with simulator
  • Fix error message in regards to proxy errors
  • Fix issue on dapp js code generation when blockchain component was disabled
  • Log errors when pipeline process dies
  • Fix lack of error reporting when a sub process would crash
  • Add default balance to accounts in tests, when balance is not specified
  • Fix issue in handling port and host cmd line params when running embark run
  • Fix crash with profile cmd when nothing was specified
  • Fix issue with contract logger which in some edge cases the first transaction wouldn’t be displayed.
  • Simplified default configs by putting more options in the default
  • Update dependencies listed by npm 6
  • Upgrade default web3.js version

Download Status

Get Status