Daiagrams & Formulas

Created by Tony Romanelli, Modified on Tue, 25 Feb at 11:49 AM by Tony Romanelli

Cantina Code supports diagramming libraries such as Mermaid.js and MathJax for mathematical formula rendering. Paired with a well written finding or comment, these tools allow you to visually and efficiently communicate your point to the reader.

Mermaid Diagram

The following code block

sequenceDiagram
    participant Bank
    participant Attacker

    Attacker->>+Bank: Request withdrawal
    Bank->>+Attacker: Transfer funds
    Attacker->>+Bank: Request withdrawal (reentry)
    Bank->>+Attacker: Transfer funds (reentry)
    Bank-->>-Attacker: Insufficient balance

when introduced as a comment will display as illustrated in the image below.

Sequence diagram shows smart contract reentrancy attack.
Rendered mermaid diagram

MathJax Formulas

Cantina Comments also render MathJax formulas. The following code block

$$
H_{f} = \frac {\sum Collateral_{i}\;in\;ETH  \times  Liquidation\;Threshold}{Total\;Collateral\;in\;ETH} $$

when introduced inside a comment will render as such

ssue in Cantina Code with a mathematical formula using Mathjax, highlighting a potential error in implementation for Web3 security audits.
Rendered Mathjax formula

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article