It is hard for developers who are unfamiliar with Ethereum and Hyperledger Besu to get started with developing an end-to-end application that uses smart contracts. They would need to learn the intricacies of setting up each component in their development environment, look through endless tutorials, sample projects and documentation that focus on individual components instead of all of the technologies together, and struggle with trial end error to get a basic end-to-end scenario working.
We aim to improve this experience by providing generators using different technologies to create sample projects that encompass and provide the entire development stack.
What it does
This project contains two generators that make it easy for developers to start developing apps on Hyperledger Besu.
Maven archetype for generating a sample project.
Run a single command to generate a project that has everything fully configured and ready to run.
Appsody stacks for generating sample projects while keeping the entire runtime on a container.
Run a single command to generate a project that has everything fully configured.
Run a different command to start your development runtime in Docker, so that you don't even need Maven or Java installed.
How we built it
We created a sample project that installs Hyperledger Besu as part of the build, configures it for local development, compiles Solidity contracts using web3j-maven-plugin, builds the project through Maven, and runs the application that connects to the Hyperledger Besu node through web3j. The application deploys a basic smart contract through Besu and calls a function.
We then converted it into a Maven archetype using the maven-archetype-plugin.
We used the sample project created from our Maven archetype above, and added it as a template in a new Appsody stack by following the the steps in the Appsody stacks doc. In addition, we created Dockerfiles that define how the stack and project are built and how local directories are mapped into the container, so that the entire development runtime (Besu, Java, Maven) reside within the container.
Challenges we ran into
The Hyperledger Besu documentation was very in depth and detailed, however the setup was very complicated for our team to figure out. The required steps for a development type environment are scatted throughout different pages and sections, and the client requires many non-default options to enable a development type scenario. Thus we needed to use trial-and-error and look around the docs and command line help output for solutions at each stage of our progress.
We could not find any sample projects that make use of web3j and Hyperledger Besu together, even though this seems like a reasonable scenario for Java developers working with Ethereum. Various tutorials and even the Besu docs refer to Truffle, web3.js, and/or solc, which while all are useful tools for development, should not be a requirement in a native Java environment.
Accomplishments that we're proud of
We are proud to have been able to develop generators and create a sample project that uses web3j and Hyperledger Besu in a complete end-to-end scenario, so that Java developers can easily get started with development on Ethereum.
What we learned
How to create a Java project that includes Solidity contracts, how to build them using native Java tools, how to configure Hyperledger Besu for development, how to use web3j to deploy contracts on Besu without wallet management, how to create Maven archetypes, how to create an Appsody stack, and how to configure Dockerfiles.
What's next for Hyperledger Besu Generators
- Providing different sample projects and/or stacks more focused on enterprise scenarios, such as with microservices and a server runtime.
- Improving the Appsody stack to allow for iterative development with automatic redeployment of an updated project to the container.
- Enable deploying the created app to Kubernetes.