A truffle box for svelte
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



SvelteJS Truffle Box

A Truffle box using SvelteJS and ParcelJS.

This box contains everything you need to start building a smart-contract app.

Project Goal

To provide the simplest, cleanest seed for building an Ethereum dapp using Truffle, with the minimum possible dependencies, meaning that beginners and pros a like have the most transparent possible method for developing Ethereum contracts.

Truffle Box

A truffle box is a seed project for building a truffle dapp.

Why Svelte?

Svelte was chosen as it is a rich, state-model based, ES6, component framework with very few dependencies, which is nothing more than html, javascript, and css. Once compiled via svelte, there are no clientside dependencies at all - simply vanilla JS.

Svelte is basically a simple DSL (domain specific language) for building a reactive, stateful, dependency-free web-application in pure javascript.

Additionally, the Svelte API is so simple and well-designed, you can learn the whole thing from scratch in less than an hour!

Why Parcel?

ParcelJS is the convention-over-configuration packager, compiler, and bundler for javascript. Rather than reams of configuration and endless plugin modules, it requires no configuration, and is blazing fast.

Setting up

  1. Install truffle and an ethereum client. For local development, try Ethereum TestRPC.

    npm install -g truffle // Version 3.0.5+ required.
    npm install -g ganache-cli // Or the ganache GUI will work too.
  2. Download box.

    truffle unbox antony/svelte-box
  3. Run an Ethereum RPC. For simplicity and development we will be using Ethereum TestRPC.

  4. Compile and migrate the contracts after authenticating your account on the blockchain (i.e. restoring from seed in MetaMask).

    truffle compile
    truffle migrate

You're ready to go!


Components are in src/components/*.html. Everything else is in the usual place according to the docs

Run the testrpc so that you have a blockchain to work with, and deploy your contracts:

truffle deploy

Log in to metamask by importing the HD Wallet that testrpc gave you, and do the same for one of the accounts by entering its private key. Then, run the watch task to have the code updated in realtime as you develop:

truffle compile
npm run watch


To produce your production dApp, run the build task:

npm run build

This will publish your completed dApp to the folder ./dist


Testing works much the same way as it does in any web-application, with an additional truffle test command for testing smart contracts.

Be sure you've compiled your contracts before running the tests, or you'll get file not found errors.

npm run test:unit // for dApp tests
npm run test:contract // for contract tests


To build the application for production, use the build command. A production build will be in the ./dist folder.

npm run build


  • Why is there both a truffle.js file and a truffle-config.js file?

    Truffle requires the truffle.js file be named truffle-config on Windows machines. Feel free to delete the file that doesn't correspond to your platform.