Truffle University - Plugin Creation Workshop
This repository contains the example code for the plugin creation workshop as part of Truffle University. The repository contains a simple Express server that connects with a local MongoDB instance and exposes an API to store artifacts and count the numebr of stored artifacts. Additionally the repository contains a simple truffle project that integrates
master branch merely contains boilerplate for this plugin, whereas the
reference branch contains an implementation for it.
To complete this workshop, you need Node.js, Truffle, and MongoDB installed locally.
Running the server
Make sure MongoDB is running locally, either as a service or as a standalone process through
cd artifact-storage-server npm install npm start
Keep the server running during the rest of the workshop.
Compile the contracts in the
simplestorage/ directory and run the plugin's store function.
cd simplestorage npm install truffle compile truffle run store SimpleStorage
In case of the boilerplate code, this will simply output
hello to the console.
To actually add utility to the plugin, we can implement the requirements.
- A contract name is passed as a positional argument (
truffle run store SimpleStorage).
- The build artifact of the specified contract is sent as a body parameter with name
artifactto the storage server.
- An optional
urlparameter can be passed in, while the default is
- The stored artifact count is retrieved from the storage server at
- The results are meaningfully logged to the console.
Since the boilerplate code is set up to integrate
simplestorage already, there are no extra steps, and only the
store.js file needs to be changed.