One of the core principles of Web3 is composability: the idea that you can take code from other projects and build off them to create something new. That code snippets were like lego bricks and could be combined and rearranged into new forms.
That sounds great as an idea, but finding helpful snippets of code in a smart contact 1,000 lines long isn’t easy. And there’s often no clear signal that a given contract has the code you’re looking for anyway.
Finding helpful snippets of code in a smart contact 1,000 lines long isn’t easy.
It would be much easier to make code composable if there was a helpful library of code snippets available to you. One that enables you to find the specific code you need, and one in which the snippets are annotated in ways that make them easy to understand.
That’s what we shipped today.
Meet the Hiro Cookbook
We’ve rolled out a brand new section in Hiro documentation called the Hiro Cookbook that is home to over a dozen “recipes”. Each recipe is a code snippet that handles some specific function, and each recipe has written annotations, so you know exactly how the code in that snippet works, and what parameters you can customize.
For this week’s launch, we’ve published 22 recipes across a wide range of use cases, ranging from generating a random number in Clarity to creating a sponsored transaction using Stacks.js.
Copy the code for any recipe and insert it directly into your application.
We spend a lot of time listening to and answering “how do I do <code-rich-text>x<code-rich-text>?” questions from our developer community. These individual recipes are solutions to some of the most common questions we field from devs, and they span a range of use cases across our tooling and Clarity.
These snippets are a free commodity built by us at Hiro. You can copy the code and insert it directly into your application, customizing it as needed to meet your needs.
In the coming weeks and months, we will be adding new recipes to the cookbook. If there’s specific functions or capabilities you’d love to see added to Hiro docs, reach out to us in the #hiro-documentation channel under Hiro Developer Tools on Discord.