<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sword</title>
    <description>The latest articles on Forem by Sword (@sword).</description>
    <link>https://forem.com/sword</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F552079%2F75297936-a97f-477a-911f-5ce71571e606.png</url>
      <title>Forem: Sword</title>
      <link>https://forem.com/sword</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sword"/>
    <language>en</language>
    <item>
      <title>Announcing the Sword compiler</title>
      <dc:creator>Sword</dc:creator>
      <pubDate>Sat, 02 Jan 2021 23:24:42 +0000</pubDate>
      <link>https://forem.com/sword/announcing-the-sword-compiler-1453</link>
      <guid>https://forem.com/sword/announcing-the-sword-compiler-1453</guid>
      <description>&lt;p&gt;In celebration of &lt;a href="https://www.blockchain.com/btc/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"&gt;Bitcoin's 12th birthday&lt;/a&gt; on January 3rd at 19:15, we release &lt;a href="https://github.com/Sword-Smith/Sword"&gt;the Sword compiler&lt;/a&gt; as open source. Sword is a declarative language for expressing fully-collateralized financial contracts on the blockchain. Sword makes timed, conditional transfers of tokenized assets easy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Sword-Smith/Sword"&gt;Check us out on GitHub!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sword is highly domain-specific. Its language design solves problems we have not seen solved elsewhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Negative balances not allowed!&lt;/strong&gt; To activate a derivative contract, full collateral for the assets being settled must be provided. When an asset's quantity depends on some condition that is not known during deployment, a bound is provided. This means that a derivative contract can always pay out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This constraint makes derivatives practically executable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Holding a position has been tokenized!&lt;/strong&gt; When a derivative contract gets deployed, a number of &lt;em&gt;party tokens&lt;/em&gt; are created for each possible payout. Those party tokens can be traded while the derivative contract finalizes, and they can be converted to the underlying, settled asset when the position matures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This feature provides a clear path towards market adoption.&lt;/p&gt;

&lt;p&gt;Sword is very small. It features a functioning Ethereum back-end, but can be extended to most newer blockchains. Sword is also quite efficient. It compiles directly to EVM and features optimizations that are not available in a language like Solidity.&lt;/p&gt;

&lt;h2&gt;
  
  
  A quick example
&lt;/h2&gt;

&lt;p&gt;Using an &lt;code&gt;if-within&lt;/code&gt; control structure and a &lt;a href="https://ethereum.org/en/developers/docs/oracles/"&gt;price oracle&lt;/a&gt;, we can formulate a contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if obs(bool, BTCUSD_EXCEEDS, 40000) within days(7) then
    transfer(DAI, 1)
else
    transfer(DAI, 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;... which means: If the USD price of one Bitcoin exceeds $40,000 within one week of contract activation, transfer 1 DAI to party #1, otherwise transfer 1 DAI to party #2. To activate this contract, 1 DAI must be provided. After at most one week, holders of either party token #1 or #2 can cash out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Something about then and now
&lt;/h2&gt;

&lt;p&gt;Sword saw some big highlights in 2020:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Safe arithmetic derived from OpenZeppelin, but hand-coded in EVM.&lt;/li&gt;
&lt;li&gt;Positions as tokens was first implemented using external ERC20 token contracts.&lt;/li&gt;
&lt;li&gt;We then hand-coded an &lt;a href="https://docs.openzeppelin.com/contracts/3.x/erc1155"&gt;ERC1155&lt;/a&gt; multi-party token interface in EVM instead.&lt;/li&gt;
&lt;li&gt;A &lt;em&gt;party token #0&lt;/em&gt; was devised to ensure that assets don't get stuck.&lt;/li&gt;
&lt;li&gt;Integration test coverage improved significantly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Several of these improvements were made as &lt;a href="https://github.com/Sword-Smith/Sword/graphs/contributors"&gt;contributions by students&lt;/a&gt; who subsequently took their first Haskell course. We are proud to say that the barrier to entry is low enough to welcome people with limited experience in Haskell, compilers and blockchain.&lt;/p&gt;

&lt;p&gt;In 2021 we'd like to keep this momentum:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Target another blockchain; which one?&lt;/li&gt;
&lt;li&gt;More &lt;strong&gt;safety&lt;/strong&gt; in the translation; higher test coverage, more sophisticated testing techniques.&lt;/li&gt;
&lt;li&gt;More &lt;strong&gt;efficiency&lt;/strong&gt;; some low-hanging fruit was taken, we've had fun hand-optimizing EVM code, but there are many more opportunities. Writing a compiler for the blockchain is truly a use-case that justifies efficient code.&lt;/li&gt;
&lt;li&gt;Improve the &lt;strong&gt;language design&lt;/strong&gt; and &lt;strong&gt;tooling&lt;/strong&gt;; some choices lead to edge cases, others lead to elegance. There are still ways to make the language both simpler and easier to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that Sword is open source, &lt;strong&gt;you're invited!&lt;/strong&gt; The issue tracker is going through a transition period to become more readable to newcomers, but we have 99 problems and we're happy to share them!&lt;/p&gt;

</description>
      <category>haskell</category>
      <category>ethereum</category>
      <category>blockchain</category>
      <category>defi</category>
    </item>
  </channel>
</rss>
