<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Solidity Patterns on Bitsy Services Wiki</title>
    <link>https://wiki.bitsy.services/wiki/defi/solidity/</link>
    <description>Recent content in Solidity Patterns on Bitsy Services Wiki</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="https://wiki.bitsy.services/wiki/defi/solidity/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Clones with Immutable Args</title>
      <link>https://wiki.bitsy.services/wiki/defi/solidity/clones-with-immutable-args/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/defi/solidity/clones-with-immutable-args/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;a class=&#34;anchor&#34; href=&#34;#overview&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://eips.ethereum.org/EIPS/eip-1167&#34;&gt;Minimal proxies&lt;/a&gt; (EIP-1167 clones) are the cheapest way to deploy many instances of the same contract. Each clone delegates every call to a shared &lt;strong&gt;implementation&lt;/strong&gt; contract, so you only pay for ~45 bytes of creation code instead of re-deploying the full bytecode.&lt;/p&gt;&#xA;&lt;p&gt;The limitation is that clones share the implementation&amp;rsquo;s storage layout, so each instance still needs its own initialiser call to set instance-specific state — and that initialiser writes to storage, which is expensive.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Foundry</title>
      <link>https://wiki.bitsy.services/wiki/defi/solidity/foundry/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/defi/solidity/foundry/</guid>
      <description>&lt;p&gt;Foundry is a fast &lt;a href=&#34;https://wiki.bitsy.services/wiki/defi/solidity&#34;&gt;Solidity&lt;/a&gt; development toolkit written in Rust. It includes &lt;code&gt;forge&lt;/code&gt; (build, test, deploy), &lt;code&gt;cast&lt;/code&gt; (CLI for interacting with contracts), &lt;code&gt;anvil&lt;/code&gt; (local testnet node), and &lt;code&gt;chisel&lt;/code&gt; (Solidity REPL).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://book.getfoundry.sh/&#34;&gt;Foundry Book&lt;/a&gt; — official documentation&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://github.com/foundry-rs/foundry&#34;&gt;GitHub repository&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://github.com/foundry-rs/forge-std&#34;&gt;forge-std&lt;/a&gt; — standard library for tests and scripts&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/defi/solidity/foundry-broadcast&#34;&gt;Foundry Broadcast&lt;/a&gt; — how &lt;code&gt;startBroadcast&lt;/code&gt;/&lt;code&gt;stopBroadcast&lt;/code&gt; works in deploy scripts&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Foundry Broadcast</title>
      <link>https://wiki.bitsy.services/wiki/defi/solidity/foundry-broadcast/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://wiki.bitsy.services/wiki/defi/solidity/foundry-broadcast/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://wiki.bitsy.services/wiki/defi/solidity/foundry&#34;&gt;Foundry&lt;/a&gt; scripts use &lt;code&gt;vm.startBroadcast()&lt;/code&gt; and &lt;code&gt;vm.stopBroadcast()&lt;/code&gt; to mark which parts of a Solidity script should produce real on-chain transactions. A common misconception is that everything between the two calls executes as a single atomic transaction. It does not — each state-changing statement becomes its own transaction.&lt;/p&gt;&#xA;&lt;h2 id=&#34;how-broadcast-works&#34;&gt;How broadcast works&lt;a class=&#34;anchor&#34; href=&#34;#how-broadcast-works&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;A broadcast block looks like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;1&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;2&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;3&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;4&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;5&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;6&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-solidity&#34; data-lang=&#34;solidity&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm.startBroadcast(deployerPrivateKey);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;MyToken token &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; MyToken();          &lt;span style=&#34;color:#75715e&#34;&gt;// tx 1: deploy&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;token.initialize(owner, supply);        &lt;span style=&#34;color:#75715e&#34;&gt;// tx 2: external call&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm.stopBroadcast();&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;Foundry processes this in two phases:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
