<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://rajeshmullippa-collab.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://rajeshmullippa-collab.github.io/" rel="alternate" type="text/html" /><updated>2026-11-03T00:43:40+00:00</updated><id>https://rajeshmullippa-collab.github.io/feed.xml</id><title type="html">Rajesh Mullippa</title><subtitle>Notes on Web3, privacy and building</subtitle><entry><title type="html">Your first Ootle template, line by line: components, vaults, access rules, tests, and what a publish costs</title><link href="https://rajeshmullippa-collab.github.io/2026/11/03/first-ootle-template-line-by-line.html" rel="alternate" type="text/html" title="Your first Ootle template, line by line: components, vaults, access rules, tests, and what a publish costs" /><published>2026-11-03T00:00:00+00:00</published><updated>2026-11-03T00:00:00+00:00</updated><id>https://rajeshmullippa-collab.github.io/2026/11/03/first-ootle-template-line-by-line</id><content type="html" xml:base="https://rajeshmullippa-collab.github.io/2026/11/03/first-ootle-template-line-by-line.html"><![CDATA[<p><strong>TL;DR:</strong> An Ootle template is a Rust crate compiled to WASM. The first <code class="language-plaintext highlighter-rouge">pub struct</code> in a <code class="language-plaintext highlighter-rouge">#[template]</code> module becomes your component, its fields are on-chain state, and a panic rolls back the whole transaction. Resources (tokens and NFTs) are native objects that sit in vaults, and by default only the creator can call your methods. Publishing a ~72 KiB binary costs about 0.61 TARI, and a 1 MiB one about 89 TARI, so binary size matters more than you’d expect. Here’s the official guessing-game walkthrough, condensed, with the numbers.</p>

<h2 id="scaffold-it">Scaffold it</h2>

<p>The docs recommend <code class="language-plaintext highlighter-rouge">cargo-generate</code> over a bare <code class="language-plaintext highlighter-rouge">cargo new</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cargo install cargo-generate
cargo generate https://github.com/tari-project/wasm-template wasm_templates/empty -din_cargo_workspace=false --name guessing_game
</code></pre></div></div>

<p>That gives you <code class="language-plaintext highlighter-rouge">Cargo.toml</code>, <code class="language-plaintext highlighter-rouge">src/lib.rs</code> for the template and <code class="language-plaintext highlighter-rouge">tests/test.rs</code>. Running <code class="language-plaintext highlighter-rouge">cargo test</code> straight away compiles the empty template to WASM and runs it through the real engine.</p>

<h2 id="the-shape-of-a-template">The shape of a template</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>use tari_template_lib::prelude::*;

#[template]
mod template {
    use super::*;

    pub struct GuessingGame {
        prize_vault: Vault,
        guesses: HashMap&lt;RistrettoPublicKeyBytes, Guess&gt;,
        round_number: u32,
    }

    impl GuessingGame {
        pub fn new() -&gt; Component&lt;Self&gt; { /* ... */ }
        pub fn guess(&amp;mut self, guess: u8, payout_to: ComponentAddress) { /* ... */ }
    }
}
</code></pre></div></div>

<p>The rules that matter:</p>

<ul>
  <li><strong>The first <code class="language-plaintext highlighter-rouge">pub struct</code> (or enum) is the component</strong>, and it names the template. Any other structs in the module are plain data types.</li>
  <li><strong>Fields are persisted state.</strong> They have to be CBOR-encodable. The macro derives <code class="language-plaintext highlighter-rouge">minicbor</code> encoding for everything declared inside the module, so you don’t need serde.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">&amp;mut self</code> = method, no <code class="language-plaintext highlighter-rouge">self</code> = function.</strong> Transactions call methods with <code class="language-plaintext highlighter-rouge">CallMethod</code> and functions with <code class="language-plaintext highlighter-rouge">CallFunction</code>. Private <code class="language-plaintext highlighter-rouge">fn</code>s stay internal.</li>
  <li><strong>Any function that returns <code class="language-plaintext highlighter-rouge">Self</code> is a constructor.</strong> Calling it creates a new component on-chain. One template can back many components, each with its own state.</li>
  <li><strong>Errors are panics.</strong> <code class="language-plaintext highlighter-rouge">assert!</code> or <code class="language-plaintext highlighter-rouge">panic!</code> fails the transaction, and nothing it touched gets committed.</li>
  <li><strong>No state at all?</strong> <code class="language-plaintext highlighter-rouge">#[template(stateless)]</code> gives you a pure function library. The compiler rejects <code class="language-plaintext highlighter-rouge">&amp;self</code> methods and <code class="language-plaintext highlighter-rouge">-&gt; Self</code> constructors in that mode.</li>
</ul>

<h2 id="resources-and-vaults">Resources and vaults</h2>

<p>Assets on Ootle aren’t balances in a contract’s mapping. They’re native resources that can be minted and moved but not copied or accidentally destroyed. There are three kinds:</p>

<ul>
  <li><strong>Public fungible:</strong> like ERC-20, with visible amounts.</li>
  <li><strong>Non-fungible:</strong> like ERC-721, with visible metadata and owner.</li>
  <li><strong>Stealth fungible:</strong> blinded UTXOs that hide both amount and owner.</li>
</ul>

<p>The game’s constructor makes an NFT resource and an empty vault to hold the prize:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>let prize_resource = ResourceBuilder::non_fungible()
    .metadata("name", "Guessing Game Prize")
    .with_token_symbol("🎲")
    .build();                       // returns a ResourceAddress
let prize_vault = Vault::new_empty(prize_resource);
</code></pre></div></div>

<p>Things that will bite you:</p>

<ul>
  <li><strong>A vault holds exactly one resource.</strong> If you deposit anything else, the transaction fails.</li>
  <li><strong>A new vault must end up in a component’s state before the function returns</strong>, or the transaction fails.</li>
  <li><strong>Only the resource owner can mint by default.</strong> You can widen that with <code class="language-plaintext highlighter-rouge">.mintable(rule![...], UpdateRule)</code>.</li>
</ul>

<p>To pay a winner, the method withdraws from the vault into a <code class="language-plaintext highlighter-rouge">Bucket</code> and calls <code class="language-plaintext highlighter-rouge">deposit</code> on the player’s account:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>guess.payout_to.invoke("deposit", args![prize]);
</code></pre></div></div>

<p>If nobody wins, <code class="language-plaintext highlighter-rouge">prize.burn()</code> destroys it.</p>

<h2 id="access-rules">Access rules</h2>

<p>By default, only the component’s creator can call its methods. To let anyone play, the game opens up one method:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>let access_rules = ComponentAccessRules::new()
    .method("guess", rule![allow_all]);
Component::new(Self { /* ... */ })
    .with_access_rules(access_rules)
    .create()
</code></pre></div></div>

<p>Two defaults are worth knowing: <code class="language-plaintext highlighter-rouge">OwnerRule::OwnedBySigner</code>, and <code class="language-plaintext highlighter-rouge">UpdateRule::Locked</code>, which means the component’s template can never be swapped.</p>

<p>For identity, use <code class="language-plaintext highlighter-rouge">CallerContext::transaction_signer_public_key()</code>. The docs say outright that you should <strong>never take the player’s key as a method argument</strong>, because anyone can spoof it.</p>

<h2 id="randomness-is-deterministic">Randomness is deterministic</h2>

<p><code class="language-plaintext highlighter-rouge">tari_template_lib::rand::random_bytes</code> gets its entropy from the transaction plus an internal counter. That’s hard to game but not impossible, so the docs say not to use it where you need cryptographic security. The <code class="language-plaintext highlighter-rouge">rand</code> crate can’t work inside a template at all, because every validator has to get the same result. Requests are capped at 1 KiB.</p>

<h2 id="testing-against-the-real-engine">Testing against the real engine</h2>

<p><code class="language-plaintext highlighter-rouge">tari_template_test_tooling</code> (dev-dependency, <code class="language-plaintext highlighter-rouge">0.39</code> in the docs) compiles your crate and runs transactions through the same engine the network uses:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>let mut test = TemplateTest::my_crate();
let (player, _proof, player_key) = test.create_funded_account();
let reason = test.execute_expect_failure(
    test.transaction()
        .call_method(game, "guess", args![100u8, player])
        .build_and_seal(&amp;player_key),
    vec![],
);
assert_reject_reason(reason, "Template error: Guess must be from 0 to 10");
</code></pre></div></div>

<p>Useful details:</p>

<ul>
  <li><strong>Fees are off by default.</strong> Call <code class="language-plaintext highlighter-rouge">test.enable_fees()</code> when fees are part of what you’re testing.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">extract_component_value(game, "$.2")</code> reads state by field index, not name.</strong> If you reorder struct fields, your test paths change.</li>
  <li><strong>Signer badges only reach the top-level call.</strong> A lent proof reaches one hop. A method that passes when called directly can be denied when it’s reached through another template.</li>
  <li><strong>Speed up tests.</strong> Setting <code class="language-plaintext highlighter-rouge">opt-level = 2</code> for the wasmer and cranelift packages in your dev profile makes tests about 10x faster.</li>
</ul>

<h2 id="publishing-and-why-size-is-money">Publishing, and why size is money</h2>

<p>Build with <code class="language-plaintext highlighter-rouge">cargo build --target wasm32-unknown-unknown --release</code>, then publish the <code class="language-plaintext highlighter-rouge">.wasm</code> from the wallet web UI (“Publish Template”, then Estimate Fee) or with <code class="language-plaintext highlighter-rouge">tari publish</code>. The wallet daemon runs <code class="language-plaintext highlighter-rouge">wasm-opt</code> for you.</p>

<p>From the docs’ fee table:</p>

<table>
  <thead>
    <tr>
      <th>Binary</th>
      <th>Publish charge</th>
      <th><code class="language-plaintext highlighter-rouge">TemplateLoad</code> per caller</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>72 KiB</td>
      <td>~0.61 TARI</td>
      <td>240 µT</td>
    </tr>
    <tr>
      <td>128 KiB</td>
      <td>~0.87 TARI</td>
      <td>430 µT</td>
    </tr>
    <tr>
      <td>256 KiB</td>
      <td>~3.6 TARI</td>
      <td>870 µT</td>
    </tr>
    <tr>
      <td>1 MiB (hard cap)</td>
      <td>~89 TARI</td>
      <td>3,500 µT</td>
    </tr>
  </tbody>
</table>

<p>The storage charge grows quadratically past a 96 KiB allowance (100 µT × KiB² beyond it). Every caller also pays <code class="language-plaintext highlighter-rouge">TemplateLoad</code>, 10 µT per 3 KB, each time a transaction loads your template.</p>

<p>The docs’ recommended release profile is <code class="language-plaintext highlighter-rouge">opt-level='s'</code>, <code class="language-plaintext highlighter-rouge">lto=true</code>, <code class="language-plaintext highlighter-rouge">codegen-units=1</code>, <code class="language-plaintext highlighter-rouge">panic='abort'</code>, <code class="language-plaintext highlighter-rouge">strip=true</code>. It took their test template from 95 KiB to 78 KiB after wasm-opt. Adding <code class="language-plaintext highlighter-rouge">no_std</code> plus immediate-abort panics got it to 55 KiB, 42% smaller. Keep <code class="language-plaintext highlighter-rouge">strip=true</code> too: the engine rejects binaries with any custom section other than <code class="language-plaintext highlighter-rouge">tari_tdef</code>, and the toolchain emits three by default.</p>

<h2 id="what-this-means-if-youre-building">What this means if you’re building</h2>

<ul>
  <li><strong>Start from <code class="language-plaintext highlighter-rouge">cargo generate</code>, not a blank crate.</strong> You get the test harness wired in from day one.</li>
  <li><strong>Design around vaults, not mappings.</strong> Every asset your component holds lives in a vault field, one vault per resource.</li>
  <li><strong>Lock down by default, open up per method.</strong> Creator-only is already the default, so add <code class="language-plaintext highlighter-rouge">allow_all</code> only where you mean it.</li>
  <li><strong>Assert on the reject message, not just the failure.</strong> A test that fails for the wrong reason (wrong key, no funds) is a false green.</li>
  <li><strong>Watch the 96 KiB line in CI.</strong> Below it you pay ordinary storage. Above it the premium grows quadratically, and your users pay a per-call load fee for as long as the template is used.</li>
  <li><strong>Share logic by calling other templates.</strong> Calling a published library with <code class="language-plaintext highlighter-rouge">TemplateManager::get(address).call(...)</code> means you pay the publish premium once, not once per template.</li>
</ul>

<p>Open question for other Ootle builders: has anyone gone fully <code class="language-plaintext highlighter-rouge">no_std</code> + <code class="language-plaintext highlighter-rouge">talc</code> on a real template yet, and was the size saving worth the extra friction while you were still iterating?</p>

<p><em>Sources: ootle.tari.com (Guides: Templates Overview, Building a Guessing Game, Testing Your Template, Publishing Templates; Reference: Limits, Reducing Template Size), github.com/tari-project/wasm-template.</em></p>]]></content><author><name></name></author><category term="tari" /><category term="ootle" /><category term="rust" /><category term="wasm" /><category term="smart-contracts" /><summary type="html"><![CDATA[TL;DR: An Ootle template is a Rust crate compiled to WASM. The first pub struct in a #[template] module becomes your component, its fields are on-chain state, and a panic rolls back the whole transaction. Resources (tokens and NFTs) are native objects that sit in vaults, and by default only the creator can call your methods. Publishing a ~72 KiB binary costs about 0.61 TARI, and a 1 MiB one about 89 TARI, so binary size matters more than you’d expect. Here’s the official guessing-game walkthrough, condensed, with the numbers.]]></summary></entry><entry><title type="html">Confidential vs Stealth on Tari Ootle: What Is Actually Hidden, and What Still Leaks</title><link href="https://rajeshmullippa-collab.github.io/2026/10/30/tari-ootle-confidential-vs-stealth.html" rel="alternate" type="text/html" title="Confidential vs Stealth on Tari Ootle: What Is Actually Hidden, and What Still Leaks" /><published>2026-10-30T05:30:00+00:00</published><updated>2026-10-30T05:30:00+00:00</updated><id>https://rajeshmullippa-collab.github.io/2026/10/30/tari-ootle-confidential-vs-stealth</id><content type="html" xml:base="https://rajeshmullippa-collab.github.io/2026/10/30/tari-ootle-confidential-vs-stealth.html"><![CDATA[<p>“Private by default” is the kind of phrase every chain likes to use. Tari’s Ootle layer 2 is more honest about it. Ootle doesn’t use one privacy switch. It has two separate privacy layers that stack, and its own docs list exactly what each one hides and what still leaks. This piece walks through that model in plain language.</p>

<h2 id="ootle-in-one-paragraph">Ootle in one paragraph</h2>

<p>Ootle is Tari’s smart contract layer. It settles against the Minotari proof-of-work base layer, which acts as its registrar and clock, but it runs its own consensus, networking and execution. Validator nodes are organised into committees, each covering a slice of the state, and they reach HotStuff-based BFT consensus. Smart contracts are called templates. They compile to WebAssembly, and a running instance of a template is a component.</p>

<h2 id="the-four-resource-types">The four resource types</h2>

<p>Every asset on Ootle is a resource, and its type is the single most important privacy decision a builder makes. There are exactly four:</p>

<ul>
  <li>Public Fungible: interchangeable tokens. Balances and owners are visible, and funds live in vaults.</li>
  <li>Public Non-Fungible: NFTs. Each item is visible, and funds live in vaults.</li>
  <li>Confidential: amounts are hidden, but the vault holding them (and its component) is visible.</li>
  <li>Stealth: amounts and owners are both hidden. Funds live as individual UTXOs, not in vaults.</li>
</ul>

<p>The native token, TARI, is a stealth resource.</p>

<h2 id="layer-one-confidential-which-hides-the-number">Layer one: Confidential, which hides the number</h2>

<p>A confidential balance is stored as a Pedersen commitment: <code class="language-plaintext highlighter-rouge">C = mask·G + v·H</code>. In plain terms, the value v is locked behind a random blinding factor (the “mask”). An observer can see that a vault holds something, but can’t tell a commitment to 5 from a commitment to 5,000.</p>

<p>Commitments can also be added together. That’s what lets the network check that inputs equal outputs without opening any of them. To stop someone faking that check with a negative number, every output carries a Bulletproofs+ range proof, which shows the hidden value is valid without revealing it. Ootle batches these proofs, so a many-output transfer stays cheap to verify.</p>

<p>The limit: a confidential balance still sits at a known address. The vault can be watched, even if its contents can’t be read.</p>

<h2 id="layer-two-stealth-which-hides-the-place-too">Layer two: Stealth, which hides the place too</h2>

<p>Stealth transfers remove that address entirely. For each output, the sender does a Diffie-Hellman exchange with the recipient’s public key and derives a one-time address. Only the recipient, using their private key and a nonce published with the output, can recompute the shared secret, recognise the output as theirs and spend it. An outside observer sees the one-time key and the nonce, and can’t link either back to the recipient.</p>

<p>Each stealth output also carries an encrypted payload (XChaCha20-Poly1305) holding the value, the mask the recipient needs to spend it later, and an optional memo of up to 255 bytes.</p>

<p>The result: an observer can see that outputs exist, but not how much they hold or who owns them. With a confidential balance there’s an address to watch. With stealth, there’s nothing to watch in the first place.</p>

<h2 id="privacy-with-an-audit-door">Privacy with an audit door</h2>

<p>Sometimes someone needs to see amounts, such as an auditor or an asset issuer. Ootle supports this with view keys. A resource can attach an ElGamal-encrypted balance to each output, and the view-key holder can read the value while everyone else sees only that a valid value exists. Crucially, a view key can’t spend. Disclosure is a choice, not a weakening of the cryptography.</p>

<h2 id="the-honest-part-what-still-leaks">The honest part: what still leaks</h2>

<p>This is the section most chains skip. Ootle’s own threat model says privacy is a property of how a transaction is built, not a blanket guarantee.</p>

<p><strong>Hidden:</strong></p>

<ul>
  <li>Confidential and stealth amounts</li>
  <li>Stealth ownership</li>
</ul>

<p><strong>Revealed by design:</strong></p>

<ul>
  <li>Transaction fees, which must be paid in a known amount</li>
  <li>Any input or output a transaction chooses to reveal</li>
</ul>

<p><strong>Leaks you can cause yourself:</strong></p>

<ul>
  <li>Signing with a public key. Calling a component method that checks your identity links the transaction to you.</li>
  <li>Amount correlation. Withdrawing exactly the amount you then send as a revealed input makes the two linkable.</li>
  <li>Graph analysis. Which inputs were spent and which outputs were created is still public.</li>
  <li>Script-path spends, which publish the condition they use, and that might name a key or a deadline.</li>
</ul>

<p>The guidance that follows: spend stealth inputs where you can, keep revealed amounts to the fee, and avoid identity-checked calls when privacy matters.</p>

<h2 id="why-this-matters-for-builders">Why this matters for builders</h2>

<p>On most smart contract chains, privacy is bolted on later, through mixers or separate shielded pools. On Ootle, it’s part of the asset definition. A builder choosing between <code class="language-plaintext highlighter-rouge">ResourceBuilder::confidential()</code> and <code class="language-plaintext highlighter-rouge">ResourceBuilder::stealth()</code> is choosing what the world can learn about their users. Confidential suits apps where a public vault is fine but balances shouldn’t be, like a payroll or treasury component. Stealth suits money that should move like cash.</p>

<h2 id="where-xtm-and-tari-fit">Where XTM and TARI fit</h2>

<p>Tari has two tokens. XTM is mined on the base layer. The only way to create TARI on Ootle is to burn XTM 1:1, a one-way path with no peg-out. Part of Ootle’s transaction fees is burned, which Tari calls the Turbine model, and it’s designed to keep overall supply in balance.</p>

<h2 id="the-takeaway">The takeaway</h2>

<p>Ootle’s privacy is real cryptography, not marketing: Pedersen commitments, Bulletproofs+ range proofs, one-time stealth addresses and optional view keys. Just as useful is that the docs tell you plainly where the edges are. If you’re building on Ootle, pick your resource type deliberately and build transactions with the leak list in mind.</p>

<p>Sources: Tari Ootle docs (ootle.tari.com: Privacy; Templates and Assets; State and Execution), the Tari RFC library (rfc.tari.com/ootle), and Tari Tokenomics (tari.com/tokenomics).</p>]]></content><author><name></name></author><category term="tari" /><category term="ootle" /><category term="privacy" /><category term="cryptography" /><summary type="html"><![CDATA[“Private by default” is the kind of phrase every chain likes to use. Tari’s Ootle layer 2 is more honest about it. Ootle doesn’t use one privacy switch. It has two separate privacy layers that stack, and its own docs list exactly what each one hides and what still leaks. This piece walks through that model in plain language.]]></summary></entry></feed>