SvelteJS Truffle Box
This box contains everything you need to start building a smart-contract app.
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.
A truffle box is a seed project for building a truffle dapp.
Additionally, the Svelte API is so simple and well-designed, you can learn the whole thing from scratch in less than an hour!
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.
truffle unbox antony/svelte-box
Run an Ethereum RPC. For simplicity and development we will be using Ethereum TestRPC.
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:
testrpc 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
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.
To build the application for production, use the build command. A production build will be in the
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.