Four Scribble features to make testing your smart contract easier

Just like with any language, when we learn new words, we become more expressive and can articulate with more clarity and meaning. These four features of Scribble have done precisely this: made the specification language more expressive so you can test your smart contract code with deeper efficiency and precision.

Scribble is a specification language and runtime verification tool that translates high-level specifications into Solidity code. Using Scribble you can annotate smart contracts with properties directly, instead of writing in a separate file. Scribble takes traditional annotation a step further by transforming it into concrete assertions that verify specifications.

Once properties are written, developers can use Fuzzing to automatically test smart contracts to ensure their code is battle-tested and ready for whatever mainnet has in store.

Let’s take a closer look at these four features to understand how each makes Scribble a more expressive and efficient tool for your blockchain security needs.

1. Sums

Have you ever wanted to write a unit test that checked that the sum of all the balances was equal to the total supply?

Using only Solidity you can’t do it, but with the Sums feature Scribble can.


2. If_updated

Have you ever written several properties or unit tests to check that each function updates a storage variable correctly?

The If_updated feature enables properties to be checked at any point where a variable is updated. With if_updated you can write simple and concise properties about variables.

Here is an example with an authorization check:


3. Macros

The Macros feature makes getting Scribble pilled easier than ever!

Take the ERC20 macro for example. It will automatically add properties that ensure your token follows the ERC20 specification:

My token

Using Scribble and the Macros feature, property-based testing has never been more straightforward!

4. Hints

Sometimes you want to guide fuzzing or verification to assume or try things about the input. Using the hints feature, you can provide “hints” with annotations. Use require specs to constrain and try specs to suggest optional inputs:

My contract

Keep Scribbling! Keep testing.

We hope these five features make testing your smart contracts with Scribble and Fuzzing much easier. Check out our documentation for more information on each of these Scribble features and more: Get started building using our Scribble repo on Github.

All posts chevronRight icon