SMART BEAVER

Are you tired of using OpenBrush? Are you frustrated with their custom library, lack of updates, and limited features?

Do you dream of having a wizard that can easily configure and deploy contracts written in clean ink!?

Welcome to Smart Beaver! We specialize in building contracts as sturdy as dams.

Inspiration

This time, our goal was to work on a project related to architecture and tools. When we talked to the Aleph Zero team, we got inspired. We asked them if there was a tool to easily set up popular smart contract standards for Polkadot, like the one from OpenZeppelin. They mentioned OpenBrush, but it relies on their library. We all agreed that creating a simple wizard to make smart contracts in clean Ink! would be a great idea with lots of potential.

What it does

Smart Beaver is a smart contract wizard that enables users to select a standard, configure its properties, inspect the source code, compile it, and deploy it. The smart contracts are written in pure Ink! without any additional libraries.

For example, you can choose the PSP22 standard, then select the extensions you want it to have, and our application will generate the source code for you.

How we built it

We have written a smart contract in pure Ink! with all the available extensions and modifiers. We've annotated the source code with Rust macros and our own comments, which enable us to configure the source code based on the user's needs.

The workflow is as follows: A user configures their smart contract using our wizard, selecting the desired extensions and adjusting settings. The frontend then calls our backend, which runs our custom preprocessor. Based on the configuration, the preprocessor hides unused extensions. The preprocessed result is displayed to the user on our frontend.

If the user is satisfied with the result, they can compile the source code. This, once again, invokes our API, which compiles the template using Rust features to configure the code. Subsequently, we return the WASM code to the frontend application, prompting the user to sign a deployment transaction with their wallet.

Challenges we ran into

Our main challenge was coming up with an idea for allowing users to configure the contract with different extensions in clean Ink! while ensuring they can view and understand the generated code.

We decided against following the OpenBrush approach, as it wouldn't bring any added value to the ecosystem. Instead, we opted to write a single comprehensive contract in clean Ink! and then employ Rust macros to enable or disable extensions based on the users' preferences.

Our next step was to run the preprocessor and present the generated source code to the user. However, we encountered an issue where it expanded all the traits and macros, including those not declared by us. This resulted in the source code being less readable and comprehensible. To address this problem, we resolved to create our own parser, allowing us to hide and display the smart contract extensions in the source code, providing users with a more understandable representation.

Accomplishments that we're proud of

We have successfully created a configurable PSP22 contract with all the extensions in pure Ink!. We achieved this by using Rust macros (features) and our custom-built preprocessor. Additionally, we developed an attractive and useful frontend, which we integrated with our API and the Talisman wallet.

What we learned

We've gained a lot of knowledge about Ink! and Rust macros, and we also have a better understanding of how to write contracts that adhere to the PSP. Overall, it was a valuable experience.

What's next for Smart Beaver

First, we need to clean the contract code, perhaps reconsider the design, and write tests to achieve comprehensive test coverage. Afterward, we can incorporate support for additional standards, such as PSP34.

The ultimate objective is to create a wizard that will prove useful for both experienced Polkadot developers and non-technical individuals seeking a straightforward way to configure and deploy standard contracts.

Bounties

ETHWarsaw Foundation

Aleph Zero - Tooling/Infrastructure - Create Developer/Infrastructure Tooling for the Aleph Zero Ecosystem

Built With

Share this project:

Updates