<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Emily Pillmore on Medium]]></title>
        <description><![CDATA[Stories by Emily Pillmore on Medium]]></description>
        <link>https://medium.com/@emilypi?source=rss-21a77a0712aa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*z3EZviB9G5Hsas6Zq6g7PQ.jpeg</url>
            <title>Stories by Emily Pillmore on Medium</title>
            <link>https://medium.com/@emilypi?source=rss-21a77a0712aa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 01:08:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emilypi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pact 4.6 is In (pre)Flight]]></title>
            <link>https://medium.com/kadena-io/pact-4-6-is-in-pre-flight-76e940927f45?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/76e940927f45</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[kadena]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Wed, 22 Feb 2023 14:59:41 GMT</pubDate>
            <atom:updated>2023-02-22T15:36:50.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BkKdH9y8UNpl4U5agsOesg.png" /><figcaption>Announcing the release of new smart contract features with Pact 4.6!</figcaption></figure><p>Kadena is hard at work offering new and improved visions of the blockchain industry and its tooling. In particular, the Pact team is happy to announce improvements to the Kadena public blockchain Pact API in conjunction with developments and new additions to the language itself. As Kadena matures, we are bringing a new focus to the User Experience/Developer Experience of the platform and its tools, which includes envisioning future L2 solutions in the ecosystem. To initiate these efforts, Kadena presents the following new features:</p><h3><strong>Zero Knowledge Primitives</strong></h3><p>As a result of the new collaboration between Kadena and Electron Labs, Pact has included several new built-in functions that allow users to build zero-knowledge solutions.</p><ul><li>pairing-check: performs the pairing and final exponentiation points in BN254 curve pairs.</li><li>point-add: adds two points together that lie on the curve BN254. Point addition is either in F_q or in F_q^2.</li><li>scalar-mult: multiplies a point that lies on the curve BN254 by a scalar integer value.</li></ul><p>Together, these natives provide the basis for Zero-Knowledge proof construction and verification. While proof generation is still something the user would need to supply in the meantime, this allows at least the point calculation and proof verification to exist on-chain, providing a strong cryptographic witness to ZK proofs in a decentralized execution environment.</p><h3><strong>Improvements to Formal Verification</strong></h3><p>The Pact team recently welcomed Robert Soeldner to the team as a Haskell developer and as the point person on Pact’s built-in formal verification engine. Within a relatively short period of time, Pact has ended up with many upgrades to outstanding bugs in the FV system, as well as a wealth of UX advancements to the surrounding instrumentation. Among the fixes are enhancements to the typechecker and various outstanding warnings for known issues with certain built-ins like select, in addition to the ability for users to study SMTLib output on a per-module basis using the verify debug flag overload.</p><h3>Bringing Errors Back to the Blockchain</h3><p>One of the sorely missed features that went away in the most current iteration of the Kadena public blockchain was error output from the /send endpoint. This created a lapse in error coverage, where the /local endpoint, Kadena’s node-local transaction simulation endpoint, was not robust enough to provide accurate error messages./send, the previous means by which transaction errors were generated, now failed to do so. Hence, we decided to improve the /localendpoint to the point where it would all but subsume transaction simulation using /send. While we at Kadena understand that this was a rather difficult period for users, we are offering a two part solution in two separate installments:</p><ol><li>/local now features a pre-flight simulation api, which brings /local transaction simulations as close to /send as possible: all transaction metadata is validated as it would be in /send, transaction execution covers the full breadth of gas costs from transaction size to the cost of gas purchase in addition to the cost of running the function, and the new API is <em>fully backwards compatible with existing </em><em>/local-based workflows! </em>Read more about it here:<em> </em><a href="https://github.com/kadena-io/chainweb-node/pull/1585">https://github.com/kadena-io/chainweb-node/pull/1585</a></li><li>/send in future node upgrades, will default to an error code API that will allow users to query for transaction errors on chain using our Chainweb Data offering. This offers two benefits that are important to consider for the scalability of the system as more and more users pour in: we don’t have to store brittle error messages on-chain, and error codes are much less prone to exploits that lock in error formats as they currently exist in Pact, allowing us to change internal representations in Pact without affecting on-chain semantics.</li></ol><p>We want to hear from you as we improve the UX/DX surrounding errors in Pact and its APIs. User feedback is taken into consideration at all steps of the improvement process.</p><p>Please make your voice heard on our issues!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5aPOgbndA0IadxYyN23ew.png" /></figure><h3>A warning system for Deprecations</h3><p>As Pact gears up for its eventual Pact Core migration, some features are being deprecated in the lead-up to the release. In order to make these deprecations known, rather than writing an article for each deprecation in the cycle, Pact now features a system that provides a warning when certain constructs that are going to be deprecated are in use. Additionally, when one goes to use the /localpreflight simulator, the endpoint delivers any relevant warnings in the transaction execution workflow as a message returned along with the result of execution.</p><h3>Conclusion</h3><p>Kadena continues to improve the existing Pact story for both users and developers while Pact shapes up for its migration to Pact Core. As we charge forward with new improvements at our current blistering pace, we also can’t forget how incredible it is to see community involvement in both the design process (in issues, on pull requests), and actually submitting content to the language. In particular, we’d like to thank new contributors @qooboodoop and @omahs, who provided great progression to the Pact service defaults and documentation, respectively. We hope to see more from the community as we grow and see more adoption.</p><p>Visit us on GitHub to read the full Pact 4.6 release: <a href="https://github.com/kadena-io/pact/releases/tag/v4.6.0">https://github.com/kadena-io/pact/releases/tag/v4.6.0</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76e940927f45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/pact-4-6-is-in-pre-flight-76e940927f45">Pact 4.6 is In (pre)Flight</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introductory Guide to Kadena Namespaces]]></title>
            <link>https://medium.com/kadena-io/an-introductory-guide-to-kadena-namespaces-c6c34f95b902?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6c34f95b902</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[kadena]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[pact]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Wed, 11 Jan 2023 18:58:59 GMT</pubDate>
            <atom:updated>2023-01-11T19:51:48.823Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FfPIMjWvXsk0NFOP.png" /></figure><p>When interacting with smart contracts on <a href="https://github.com/kadena-io/chainweb-node">Chainweb</a>, one will often see module names or module member expressions prefixed with static names such as <strong>free</strong>, or <strong>util</strong>, or <strong>kaddex</strong> (e.g. <strong>free.radio02.direct-to-send</strong>). We refer to these static prefixes as “namespaces”, and they form an integral part of the <a href="https://kadena.io/">Kadena</a> ecosystem that allows developers and users to write contract and keyset definitions within a private namespace that they govern themselves. What’s interesting about namespaces in the Kadena public blockchain in particular is that the method by which these namespaces are allocated is defined in a smart contract itself within the root (i.e. empty) namespace. This root namespace has special status in the blockchain as one of the few contracts that the <a href="https://www.google.com/search?q=kadena+pact&amp;oq=Kadena+Pact&amp;aqs=chrome.0.69i59i512j0i512j0i22i30l2j0i390j69i60j69i61l2.5353j0j4&amp;sourceid=chrome&amp;ie=UTF-8">Pact</a> application layer is aware of explicitly during transaction execution.</p><p>In the past, the means by which new namespaces were allocated was a centralized process, with the namespace contract owners (the Kadena team) operating in a similar manner to a root name server, writing namespaces to a registry upon request. However, now that development is rapidly taking off in the Kadena ecosystem, the Kadena team is introducing the first in a series of steps to decentralize the registration process and delegate namespace definition to the users, allowing them to create namespace names derived from their chosen means of governance.</p><p>This article serves as an introduction to the concept of namespaces, how they operate within Kadena, and how the new decentralized process works for users. If you’re already familiar with namespaces and how they work, then feel free to skip to the last section.</p><h3>What’s in Name(space)?</h3><p>Kadena’s namespaces are relatively simple in practice. They are used in exactly two scenarios:</p><ol><li>Contract definition, in which a module is published to a namespace, which allows one to access the module and its members by prefixing the namespace and a dot (e.g. if you have a namespace <strong>my-namespace</strong>, then if you define <strong>my-module</strong> within it, you may access its members by issuing <strong>my-namespace.my-module.my-function</strong>.</li><li>Keyset definition, in which a keyset is defined within the namespace, and may be referenced by its name prefixed by the namespace name in which it was defined. This allows for keysets to exist with the same name, allowing the namespace to distinguish which keyset with a common name is being referenced at a particular point in code. This also works for named keyset references.</li></ol><p>There are two builtins needed to define and “enter” a namespace in order to define constructs: <strong>define-namespace</strong>, and <strong>namespace</strong>. Upon defining a namespace, a user and admin governance protocol (a keyset or more generally, a guard) must be supplied in order to define the namespace and who may upload to it. For a more in-depth discussion, see the <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html?highlight=namespace#namespace-declaration">Pact Language ReadTheDocs</a>.</p><p>All in all, the process is fairly simple. To define a namespace one must only issue the following:</p><pre>(define-namespace &quot;my-namespace&quot;<br> (read-keyset &quot;my-admin-keyset&quot;)<br> (read-keyset &quot;my-users-keyset&quot;))</pre><p>And optionally, if one doesn’t want to continually prefix module names by a particular prefix during the definition process, the user should issue:</p><pre>(namespace &quot;my-namespace&quot;)</pre><p>Now you’re off to the races. All definitions will be prefixed with a namespace aside from keysets, which must be defined explicitly with the prefix in mind. The administrative and user guards specifically refer to who “owns” the namespace (who may administrate operators and general code owners), and who has rights to publish definitions within the space (the users/operators).</p><h3>Namespaces in the Blockchain</h3><p>In practice, when interacting with the Kadena public blockchain, the Pact application layer implements the means by which namespace resolution is achieved, so there is a bit of knot-tying that needs to happen in order to resolve properly. At genesis all foundational contracts were uploaded to the root namespace, which was reserved for special definitions. One of these was the namespace contract called <strong>ns</strong>, which provided the resolution logic and registry table for namespaces.</p><p>The transaction execution layer points to a particular function in that contract called “<a href="https://github.com/kadena-io/chainweb-node/blob/5ad28bc939c6fb7a398de67a5fec109a3e9cf989/pact/namespaces/ns.pact#L48">validate</a>” which provides the compile-time direction for resolving namespaces via the namespace registry table. This is where the magic happens. The namespace contract is not “special”, per se, in terms of upgradeability or ownership; the logic by which names are resolved can be changed as demands change within the ecosystem. <strong>This is an extremely overpowered and underlooked feature unlike any blockchain: namespaces and their associated resolution policies are built to scale with the blockchain, and are immediately amenable to decentralized governance.</strong></p><h3>Autonomously generated namespaces</h3><p>As a first step towards decentralized namespace definition, Kadena has decided to offer autonomous namespace definition derived from a keyset, and we’re calling such a definition a “principal” namespace. These namespaces are principal in the sense that they are autonomously reproducible from the administrative keyset, and globally unique as a result. The process is fairly simple, but does require a little knowledge in order to get started.</p><p>Kadena has upgraded its mainnet namespace contract (<strong>ns</strong>) to add a function which the user may call in order to generate a principal namespace name they can use without registering with the <strong>ns </strong>registry, as well as a change to the way namespace validation is done in order to allow users to begin using their principal namespaces with no further work. As a caveat, such principal namespace definitions are only available for single and multisignature keysets.</p><p>To create a principal namespace, one only needs the keys they wish to administrate the namespace, and to call the new <strong>create-principal-namespace</strong> function exported from <strong>ns</strong>. In code:</p><pre>(ns.create-principal-namespace (read-keyset &quot;my-admin-keyset&quot;))</pre><p>This creates a string that looks like the following:</p><pre>&quot;n_c1a583206e24450af26de41110042b019695db8c&quot;</pre><p>This is opaque, and analogous to an IP address. The <strong>n_</strong> prefixes a hash of the keyset in order to denote that it’s a namespace, in the sense that <a href="http://`/"><strong>http://</strong></a> prefixes an address using the HTTP protocol. Their use is rather simple — they can be used to define a namespace in the following manner:</p><pre>(define-namespace<br> &quot;n_c1a583206e24450af26de41110042b019695db8c&quot;<br> (read-keyset &quot;my-admin-keyset&quot;)<br> (read-keyset &quot;my-users-keyset&quot;))<br>(namespace &quot;n_c1a583206e24450af26de41110042b019695db8c&quot;)</pre><p>When a user defines a construct within this namespace, they may begin using it immediately with no further effort.</p><h3><strong>What about vanity namespaces?</strong></h3><p>The immediate response to this is obviously going to be: “What an opaque format! Can’t I have something like the cool kids with the .eth domains?” The answer is that the current functionality is a stepping stone on the way to vanity domain names in the same sense that the ENS-style name mappings resolve names to contract addresses. The current iteration at the very least achieves decentralized namespace definition, and is a necessary step to scaling the Kadena blockchain for developers.</p><h3><strong>Conclusion</strong></h3><p>I hope this whirlwind tour of namespaces has been helpful for everyone! We strive to provide as many updates as possible as Kadena continues to innovate. We have a bright, bullish future ahead of us as we continue to unlock the power of decentralization and scalability for our ecosystem developers. Stay tuned for 2023 — there’s far more to come!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6c34f95b902" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/an-introductory-guide-to-kadena-namespaces-c6c34f95b902">An Introductory Guide to Kadena Namespaces</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new in Chainweb 2.17]]></title>
            <link>https://medium.com/kadena-io/whats-new-in-chainweb-2-17-9c513b8ba869?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c513b8ba869</guid>
            <category><![CDATA[layer-1]]></category>
            <category><![CDATA[kadena]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[pact]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Wed, 30 Nov 2022 20:04:59 GMT</pubDate>
            <atom:updated>2022-11-30T20:04:59.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZKcQU0DnPml7EiRCvMoxGg.png" /></figure><p>Kadena is releasing a new version of Chainweb Node, version 2.17 which will have a service date in effect as of <strong>2022–12–01T00:00:00Z</strong>. In addition to various bug fixes and performance optimizations, this release will change the current Pact and Chainweb Node experience for some dApp developers and users. In this article, we will explain the UX/DX-relevant changes in depth, and provide a migration path.</p><h4>Namespaced Keysets</h4><p>As of Pact 4.4, we’ve introduced the concept of Namespaced Keysets, which changed the Pact developer experience in favor of more flexibility and security. As of Chainweb 2.17, Pact 4.4 will become the new node standard. For a more detailed explanation of how this will affect users and developers, we wrote about this in a previous <a href="https://medium.com/kadena-io/whats-new-in-pact-4-4-db31dbcbda0e">post</a>.</p><h4>Removing Error Details from /send endpoint</h4><p>Pact features rich error messages to help builders debug problems and handle failures in production. However, this has caused problems for recording transactions on the Kadena blockchain, which has to preserve bit-for-bit behavior for every block. For example, if a miner builds a binary with a slightly different library version, an unexpected error can result in different hashes for blocks. To resolve this, error details and stack traces will no longer appear in failed transactions sent to the <strong>/send</strong> endpoint, but the error type is still available. This also gives some performance gains by not computing code to assemble the message.</p><p>Full error messages are still available using the <strong>/local</strong> endpoint, and builders are recommended to use <strong>/local</strong> to execute pre-flight simulation, which is the best practice anyway, and can detect errors before submitting to the blockchain and spending gas.</p><h4>Fine Tuning the Gas Model</h4><p>In previous Chainweb node versions, our work centered on fixing various security threat vectors, which affected the gas model. As we work to fine tune the gas model, we’ve actually found a way to make operations such as transferring coins cheaper than ever before. Developers will want to recalibrate the gas limits they use for transactions. You can see how much a gas a particular transaction takes using the <strong>/local</strong> endpoint for pre-flight simulation.</p><h4>Node Performance and Bug Fixes</h4><p>In addition to the above changes, Chainweb 2.17 features the following performance improvements:</p><ul><li>Improved performance during catchup</li><li>Improved P2P protocol performance</li><li>Improved TLS session management</li><li>Faster and safer binary serialization across the board</li></ul><p>Along with the following bug fixes:</p><ul><li>We now protect against possible race conditions in SQLite interface code</li><li>Chainweb 2.17 features a per-tx timeout during creation of new blocks to prevent mining nodes from stalling when block creation takes too long</li></ul><h4>Summary</h4><p>The Kadena public blockchain is constantly evolving to meet the demands of dApp developers and bring innovative technology to the forefront of the crypto industry. We are listening and addressing feedback as it comes to us, and providing bull-market solutions in a bear-market winter. We welcome your feedback, and hope to hear more from builders.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c513b8ba869" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/whats-new-in-chainweb-2-17-9c513b8ba869">What’s new in Chainweb 2.17</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deprecation Notice for Module Guards and Pact Guards]]></title>
            <link>https://medium.com/kadena-io/deprecation-notice-for-module-guards-and-pact-guards-2efbf64f488f?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/2efbf64f488f</guid>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[pact]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[kadena]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Mon, 03 Oct 2022 18:33:17 GMT</pubDate>
            <atom:updated>2022-10-03T18:33:17.167Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8sbZuCncPEgill19IVOSYQ.png" /></figure><p>Kadena aims to continue building and supporting our developer community with a robust, best-in-class experience for Web3 developers. In order to do so, the team at Kadena continues to provide developer updates swiftly to ensure a smooth builder experience.</p><p>This article will inform you on how to migrate away from two guard types in Pact to safe alternatives. These deprecated guards will be removed in a future release.</p><h4>Overview</h4><p>Module and pact guards were designed to allow autonomous code to control funds in an era when all Pact code execution paths were known at compile time. The later introduction of <strong>module references</strong> allowed untrusted third-party code to be executed within module code, rendering module and pact guards unsound. The solution is to migrate your code to <strong>capability user guards.</strong></p><p>While code that does not involve module references can safely use module and pact guards in some cases, capability user guards are still less bug-prone. For this reason <strong>module and pact guards are considered deprecated</strong> and all user code is recommended to exclusively employ capability user guards in cases where module and pact guards would previously have been used.</p><h4>Module &amp; Pact Guards considered harmful</h4><p>The original design of Pact offered autonomous guards largely modeled after the ownership model presented in the Ethereum EVM, where “contract accounts” simply hold ETH alongside code that can use those funds however it sees fit. In Pact, this was generalized into module guards, where the guard would pass as long as the code was being called from the module associated with the guard, and pact guards, which only pass if a specific instance of a <strong>defpact</strong> is executing.</p><p>This, of course, meant that module code invoking the guard-handling code had to be protected by other predicates and capabilities. As such, the code could have bugs as there was no explicit authorization, or scoping of said authorization. Capability-based guards solve these potential issues.</p><p>However, the later introduction of module references now brings third-party code into the mix, with the unfortunate property that <strong>anywhere the owning module calls into module reference code, that third-party code now passes the module guard.</strong> This is also true for defpact guards: while the current Pact ID is validated, invoking modrefs in any way will pass the guard.</p><p>Fortunately, building user guards using require-capability offers a truly secure mitigation. Capabilities now secure and scope guards alongside critical module code. All of the features that make Pact capabilities sound are now extended to guards for robust autonomous resource ownership.</p><h4>Capability User Guards</h4><p>Capability User Guards are a design pattern for safe autonomous guards in Pact. They are composed of three code elements: a <strong>capability,</strong> a <strong>predicate function,</strong> and a <strong>user guard.</strong> The latter can be offered as a “constructor function” resulting in a trio of definitions that defined together clearly present the overall guard structure.</p><h4>Migrating Module Guards to Capability User Guards</h4><p>A typical use of a module guard is to allow a smart contract to control KDA funds. For instance, the following <strong>deprecated</strong> code transfers money into an account owned by a module guard.</p><pre>;; DEPRECATED module guard example. <br>(coin.transfer-create funder BANK_KDA_ACCT (create-module-guard &quot;bank&quot;) amount)</pre><p>The problem with module and pact guards emerges when invoking the guard to do critical operations like withdrawals.</p><p>The core enabling feature of Pact powering this mitigation are capabilities, which already serve to secure critical pact code. Modules using the above bank code might have code that looks like the following:</p><pre>;; typical Pact code for protecting a critical operation.<br>(with-capability (WITHDRAW recipient amount)<br>  (coin.transfer BANK_KDA_ACCT recipient amount))</pre><p>With a module guard, there is potential for the first code block to be unsafe. However, by creating or rotating the BANK_KDA_ACCT with a capability user guard, this same withdraw code can be 100% safe with no changes.</p><h3>A capability user guard definition</h3><pre>;; Capability user guard: capability definition<br>(defcap WITHDRAW (recipient:string amount:decimal)<br>  ... ;; enforcement of WITHDRAW capability<br>)</pre><pre>;; Capability user guard: capability predicate function<br>(defun require-WITHDRAW (recipient:string amount:decimal) <br>  (require-capability (WITHDRAW recipient amount)))</pre><pre>;; Capability user guard: guard constructor<br>(defun create-WITHDRAW-guard (recipient:string amount:decimal)<br>  (create-user-guard (require-WITHDRAW recipient amount)</pre><p>Armed with these definitions, the original funding code can now be migrated to read:</p><pre>;; Migrated module guard example using WITHDRAW capability user guard.<br>(coin.transfer-create funder BANK_KDA_ACCT <br>  (create-WITHDRAW-guard funder amount) amount)</pre><p>… and the withdrawing code above will continue to function with no changes. Migration complete!</p><h3>Employing composition</h3><p>The problem with the above migration is the <em>over-specificity</em> of building the guard around the WITHDRAW capability: for instance, the above code only allows withdrawals of the same amount that was originally funded. If WITHDRAW is invoked with a different amount, the guard will not pass.</p><p>The opposite end of the solution spectrum is a parameter-less capability that serves only to fulfill the conditions of a capability user guard, which is then composed into the WITHDRAW capability.</p><pre>;; Invoking capability definition<br>(defcap WITHDRAW (recipient:string amount:decimal)<br>  ... ;; enforcement of WITHDRAW capability<br>  (compose-capability (BANK_DEBIT))<br>)</pre><pre>;; example of other capability also needing debit<br>(defcap PAYMENT (recipient:string fee:amount)<br>  ...<br>  (compose-capability (BANK_DEBIT))<br>)</pre><pre>;; Capability user guard: capability definition<br>(defcap BANK_DEBIT () true)</pre><pre>;; Capability user guard: capability predicate function<br>(defun require-BANK_DEBIT () <br>  (require-capability (BANK_DEBIT)))</pre><pre>;; Capability user guard: guard constructor<br>(defun create-BANK_DEBIT-guard ()<br>  (create-user-guard (require-BANK_DEBIT)))</pre><p>You would then create the account using the BANK_DEBIT guard:</p><pre>;; Migrated module guard example with BANK_DEBIT capability user guard.<br>(coin.transfer-create funder BANK_KDA_ACCT <br>  (create-BANK_DEBIT-guard) amount)</pre><h3>Best practice: Be as specific as possible</h3><p>While capability user guards require the least boilerplate when using a parameter-less capability, it is best to “de-parameterize” only as much as needed to serve the indicated use cases and no more. For instance, if WITHDRAW was the only bank-debiting operation in the above example module, and was explicitly designed to withdraw exactly what was funded, then the WITHDRAW-based capability guard is actually safer by limiting cases where the guard would fire. Indeed, it suggests a design that supports UTXO-like accounts, with the WITHDRAW capability guard perfectly suited to support multiple accounts that support only a single deposit and withdrawal.</p><p>When migrating, keep an eye out for code that relies on a single resource + module guard which could be improved by decomposing into separate resources. For instance, if user and autonomous monies previously shared the same KDA bank account, using two accounts protected by the distinct capability guards is potentially a safer design.</p><h3>Migrating pact guards</h3><p>Pact guards must be migrated to capabilities <strong>that are explicitly parameterized with the intended pact ID, and enforce equality with the current pact ID.</strong> Beyond that, they are identical to migrations for module guards.</p><pre>;; simplified marmalade-style sale second step capability<br>(defcap BUY (sale-id:string token-id:string buyer:string price:decimal)<br>  ...<br>  (compose-capability (SALE_PACT sale-id))</pre><pre>;; Pact capability user guard: capability definition<br>(defcap SALE_PACT (sale-id:string)<br>  ;; all capabilities for guarding pacts MUST <br>  ;; validate that the current pact ID matches the<br>  ;; parameter value.<br>  (enforce (= (pact-id) sale-id) &quot;invalid sale id&quot;)<br>)</pre><pre>;; Capability user guard: capability predicate function<br>(defun require-SALE_PACT (sale-id:string) <br>  (require-capability (SALE_PACT sale-id))</pre><pre>;; Capability user guard: guard constructor<br>(defun create-SALE_PACT-guard (sale-id:string)<br>  (create-user-guard (require-SALE_PACT sale-id))</pre><p>In a marmalade-style sale, BUY guards the second step. In the first step, instead of using create-pact-guard, you would use the capability user guard with the current pact ID to guard the NFT escrow:</p><pre>(let ((sale-id (pact-id)))<br>  (ledger::transfer-create token-id seller (create-sale-account sale-id)<br>    (create-SALE_PACT-guard sale-id) amount)))</pre><p>Now, you are all set and the pact guards have now been migrated!</p><p>We hope that you found this article to be helpful! Please share your feedback with us on our <a href="http://discord.io/kadena">Discord channel</a> or on our <a href="https://github.com/kadena-io/">GitHub repository</a>! Be sure to follow us on Kadena’s social media accounts for more developer updates and news as Kadena continues to drive innovation on the blockchain!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2efbf64f488f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/deprecation-notice-for-module-guards-and-pact-guards-2efbf64f488f">Deprecation Notice for Module Guards and Pact Guards</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Pact 4.4]]></title>
            <link>https://medium.com/kadena-io/whats-new-in-pact-4-4-db31dbcbda0e?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/db31dbcbda0e</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[builders]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[dapps]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Wed, 31 Aug 2022 02:05:30 GMT</pubDate>
            <atom:updated>2022-08-31T02:12:01.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IW4RipwJLD_0U4n4O6_MlA.png" /><figcaption>Check out the newest changes to Pact 4.4</figcaption></figure><p>Every growing decentralized community needs builders. With the new cohorts of grantees selected by Kadena Eco being announced every week, the Pact engineering team has been hard at work soliciting feedback and developing features for dApp developers to build their projects with more security, robustness, and confidence than ever before. Pact 4.4 brings major improvements in functionality, auditability, and transparency — primitives for building the decentralized economies and marketplaces that continue to dominate crypto.</p><p>Among the changes Pact 4.4 will bring to the ecosystem is a general move towards namespacing and principal account protocols becoming the norm. This is in response to several improvements identified over the course of the Kadena Improvement Process for `k:` account protocols that enable more robust methodologies for working with on-chain governance. Kadena is introducing the following as features for the language and network:</p><h4><strong>Namespaced Keysets</strong></h4><p>Keyset names have historically been un-namespaced, living in a global keyset registry on each chain. Due to the growing network contention for keyset names, as of Pact 4.4, all newly defined keysets will be required to be namespaced going forward. While in most cases, users never interact with keyset names, this will affect dApp developers and builders using Pact who wish to define smart contracts using their own custom governance, defined within their chosen namespace.</p><p>As an example, in code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*M7ORsEza4hJkfG9A" /></figure><p>There are few times when a keyset name is of importance, and are limited to a few use cases:</p><ul><li>enforce-keyset/enforce-guard</li><li>keyset-ref-guard</li><li>define-keyset</li><li>keyset name module governance</li></ul><p>This change applies almost exclusively to builders and power users who are writing their own smart contracts or engaging in more sophisticated governance methods. This should make things less ambiguous for everyone!</p><p>Adding this feature also allows Kadena to lay the foundation for principal-namespaces — a feature that will be introduced to the community in the upcoming weeks.</p><p>Note: legacy keysets *are not required to migrate*. This change only applies to newly defined keysets. That is, legacy keysets will still work, and still be rotatable.</p><h4><strong>Gas adjustments for Format and Try</strong></h4><p>Gas was previously too lenient for both `format` and `try`, and has been adjusted to be more accurate with respect to its actual computational cost. This results in contracts that make use of either function to cost slightly more gas.</p><p><em>Most notably, KDA transfers via </em><strong><em>coin.transfer</em></strong><em>, </em><strong><em>coin.transfer-create</em></strong><em> and </em><strong><em>coin.transfer-crosschain</em></strong><em> will use more gas. Tool and dApp developers (such as wallets and exchanges) should adjust their gas limits appropriately.</em></p><p>These continuous improvements to our gas-model will eventually lead to adjustments in blocksize, but because of large effects that small lowlevel changes can have on network health, prudence dictates a conservative timeline for the rollout of these changes.</p><h4><strong>MUSL-based mathematical primitives</strong></h4><p>All the transcendental math functions in Pact (log, ln, exp, sqrt and pow) now rely on implementations of these functions from the MUSL library (<a href="https://www.musl-libc.org/">https://www.musl-libc.org/</a>). With this change, the implementation of these functions is now in high-precision plain C, allowing more consistent behavior across platforms, compilers, operating systems and processors. Previously, differences in how these functions were realized by the Haskell compiler could lead to scenarios in which values differed ever so slightly — enough to result in hash mismatches causing block validation failures and an inability to advance the chain for some nodes.</p><p>Please share your feedback with us on our <a href="http://discord.io/kadena">Discord channel</a> to help us improve tooling for our builders.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db31dbcbda0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/whats-new-in-pact-4-4-db31dbcbda0e">What’s New in Pact 4.4</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get to know Pact 4!]]></title>
            <link>https://medium.com/kadena-io/get-to-know-pact-4-464f9c5aa60b?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/464f9c5aa60b</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[kadena]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Thu, 17 Jun 2021 21:30:33 GMT</pubDate>
            <atom:updated>2021-06-17T21:30:33.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYmdUAxT3iqFnIlJSQ_YYw.png" /></figure><h4>Learn all the ways Pact 4 accelerates safe smart contract development</h4><p>Smart contracts are all about making things happen — every transaction on the blockchain records assets changing hands, or community members committing to support a project. With Pact 4 the safest and easiest smart contract language gains powerful new features to ensure apps ship with the most security, transparency and kickass functionality possible. With <strong>new community-driven primitive ops, better cross-chain and event support, </strong>and<strong> code coverage, </strong>Pact 4 is the most productive smart contract language ever.</p><h3>What’s new in Pact 4?</h3><p>Pact 4 brings major improvements in <strong>functionality, auditability, and transparency, </strong>things that are more important than even as decentralized economies and marketplaces continue to dominate crypto.</p><h3>Great new community-demanded primitive ops</h3><p>There are more Pact developers than ever before and with that comes positive pressure on the language to grow new powerful features that continue the Pact philosophy of “safer doesn’t mean weaker”: indeed Pact 3.x already ships with more built-in functionality than any smart contract language around. Still, devs will be devs and find new itches to scratch as well as corners where Pact could be even better:</p><p><strong>String abstractions: </strong>while Pact already ships with a full toolset for manipulating strings, some more advanced concepts were hard and gas-expensive to implement, and as Pact devs get more sophisticated they have identified some gaps: namely, the ability to treat a String as an array, or list of characters, as well as more list manipulation tools.</p><p>With the new <strong>str-to-list</strong> builtin, Pact devs can cheaply convert in order to use Pact’s powerful functional list operations like <strong>map, filter </strong>and <strong>fold </strong>on a list of single-character strings. Of course, it would be unsporting to not be able to convert back, which exposed the need for the common <strong>concat </strong>operation — while already easily achieved with <em>(fold (+) “” …)</em>, familiarity with concatenation makes it a good pair for <strong>str-to-list </strong>as a bidirectional transformation — a pair of functions devs can keep in mind when needing to perform advanced operations on strings.</p><p><strong>More list operations: </strong>Pact, as a LISP, is all about lists, and in its full generality allows for every operation imaginable if you can express it, all within a Turing-incomplete language. However, like <strong>concat</strong>, some operations are just better handled as built-ins, which again the community noticed. Things like de-duplicating list entries with <strong>dedupe</strong>, or emitting series of numbers with <strong>enumerate</strong>, offer gas-cheap ways to do these useful things and focus more on business logic.</p><h3>More support for blockchain “Events”</h3><p><strong>More ways to emit events: </strong>Pact already has a great mechanism for <strong>events,</strong> which form crypto-verifiable “facts” that are critical for indexers and for cross-chain operations on Kadena and EVM chains alike. The new <strong>emit-event</strong> built-in makes event firing “free” as opposed to using <strong>with-capability </strong>which invokes the capability even if it’s an empty event. However, <strong>emit-event</strong> also allows managed capabilities to have arbitrary parameter values when used as events. For example, the fungible TRANSFER capability emits the TRANSFER event, but only for valid “balance-conserving” transfers like “Bob gives Alice 10.0 tokens”. With <strong>emit-event</strong>, TRANSFER can also be used for “burns” and “creates” using the empty account (“”), which would never form a valid TRANSFER capability, but follows ERC-20 and related standards for burn and create event emission in a way that indexers and exchanges expect.</p><h3>Cross-chain Improvements</h3><p><strong>Built-in cross-chain events and upgrade back-compatibility: </strong>Pact has the best cross-chain story of any smart contract language thanks to <strong>defpact</strong>s, which automatically handle cross-chain transfers for any asset imaginable with zero developer effort. However, it was hard for indexers to be aware of these occurrences; and worse, if a smart contract was upgraded, it could mean that a cross-chain initiated beforehand could become permanently “orphaned”, as the security check for cross-chain demands that code hashes match on both sides; after an upgrade this would fail.</p><p>In Pact 4, the already existing <strong>bless </strong>mechanism, which allows old versions of smart contract code to continue to support old users, now also supports cross-chain transfers that span an upgrade with the inescapable hash change. Plus, Pact now automatically emits <strong>X_YIELD </strong>and <strong>X_RESUME </strong>events for every cross chain, meaning that devs no longer have to worry about indexers tracking their cross-chain events.</p><h3>KDA coin contract v3!</h3><p><strong>KDA support for more events: </strong>version 3 of the <strong>coin </strong>contract for KDA takes full advantage of new Pact 4 features to emit TRANSFER events for every event on the blockchain, whether that’s miner rewards, gas payments, or cross-chain burns and creates. It blesses the previous hash to ensure that midstream cross-chains succeed that occur during the upgrade. Finally it leverages the X_YIELD and X_RESUME events to be <strong>the most transparent and indexable platform coin ever. </strong>It’s important to remember that unlike any other blockchain, KDA’s economics are implemented by smart contract: so at Kadena, we’re as much Pact <strong>users</strong> as we are its designers. <strong>coin </strong>acts as a great cookbook for new developers to study and v3, with Pact 4, is no exception.</p><h3>Code Coverage</h3><p>With Formal Verification support and excellent support for unit tests and blockchain simulation, Pact is already the best language for correct, bug-free smart contracts. However, as Pact becomes responsible for more and more value, things like auditing code become critical. Pact 4 addresses a major need by providing <strong>code coverage </strong>so that devs can immediately see if their code is being fully exercised by their unit tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*Bvt7cXRlG9P5u75A" /><figcaption>Code-coverage support in Pact 4 with Atom editor support. The red means <strong>read-account-admin</strong> lacks code coverage and needs tests.</figcaption></figure><p>This is of course fully supported in the <strong>pact </strong>tool by simply adding “-c” to the pact call. In the Atom editor, a quick upgrade to version 2.6.4 of <strong>language-pact, </strong>plus adding the <strong>lcov-info </strong>plugin, gives quick access to coverage results. Coverage in Github CI can quickly be enabled with the standard <a href="https://github.com/marketplace/actions/code-coverage-report">code-coverage-report</a> action.</p><h3>Start using Pact 4 today!</h3><p>It’s never been a better time to start learning Pact than now as the Kadena blockchain continues its rapid growth as the “home of DeFi” with every major use-case on its way to production before 2021 is out. Check out <a href="https://pact-language.readthedocs.io/en/latest/">the docs</a>, and upgrade by <a href="https://github.com/kadena-io/pact/releases/tag/v4.0.1">downloading it</a> or using brew upgrade kadena-io/pact/pact.</p><p>Get on the inside track and start writing successful, safe and profitable smart contracts in Pact! Check out our developer quickstart at <a href="https://quickstart.chainweb.com/">https://quickstart.chainweb.com/</a> , join our <a href="http://discord.io/kadena">Discord</a> and get hacking!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=464f9c5aa60b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/get-to-know-pact-4-464f9c5aa60b">Get to know Pact 4!</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Kadenaswap “Bountyswap” Live Beta]]></title>
            <link>https://medium.com/kadena-io/introducing-kadenaswap-bountyswap-live-beta-ecde4cf014dc?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecde4cf014dc</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[dex]]></category>
            <category><![CDATA[decentralized-exchange]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Mon, 01 Feb 2021 23:35:59 GMT</pubDate>
            <atom:updated>2021-02-20T20:45:11.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbYZmw4TE6ZQEIszK0gqkA.png" /></figure><p>UPDATE Feb 20 2021: <a href="https://kadenaswap.chainweb.com/bountyswap"><strong>Bountyswap is live</strong></a> — start swapping today! Watch<a href="https://youtu.be/Dt4DOGA7DeA"> instructions</a> on how to connect your Zelcore wallet to Bountyswap.</p><p>After a successful and productive run in testnet, Kadenaswap is headed to mainnet to start “Bountyswap” — the live beta! It’s a good time to lay out the current plans for Kadenaswap, Bountyswap and the future of multi-protocol, scalable DeFi.</p><h3><strong>What is Kadenaswap?</strong></h3><p>Kadenaswap is a decentralized exchange (DEX) running on the Kadena blockchain, modeled after Uniswap and other “constant product” exchanges. Like those, “automated market makers” (AMMs) <strong><em>provide liquidity</em></strong> for <strong><em>pairs</em></strong> of tokens, so that users may <strong><em>swap</em></strong><em> </em>one token for another at the ratio currently provided by the pair.</p><p>The great thing about this design is how it lives up to the “decentralized” claim: everything from liquidity provision, pricing to swapping is done entirely on-chain, requires no intervention from off chain authorities or oracles, and is fully autonomous with no control by any central on-chain authority either.</p><p><strong>Constant Product Exchanges</strong></p><p>There are two roles in this style of DEX: the AMMs providing liquidity, and “swappers” accessing that liquidity to swap between tokens. For example, let’s look at a hypothetical altcoin ABC in a pair with DAI, MakerDAO’s stablecoin, “wrapped” on the platform. We’ll talk more about “wrapped tokens” below but for this example, we’ll just call it DAI.</p><p><strong>Liquidity provision</strong></p><p>To swap ABC for DAI on a constant-product DEX, there needs to be ABC and DAI already there to service your swap. An AMM facilitates this by <em>adding liquidity </em>to the ABC:DAI pair. If the pair doesn’t exist, the AMM can create it, otherwise they add to what’s there. An AMM must provide <strong>both </strong>ABC and DAI, in a ratio that represents the current “market price” of swapping between DAI and ABC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QUr0ecQzLkeefFJsMLZC5w.png" /><figcaption>Adding liquidity in Kadenaswap</figcaption></figure><p>Thus, if ABC is trading at USD $0.25, since DAI tracks the dollar closely, an AMM could provide 1,000 ABC and 250 DAI to launch the pair. A remarkable principle of constant-product exchanges like Kadenaswap is that arbitrage swapping ensures the price faithfully reflects the off-chain market:</p><ul><li>If the AMM provides too much DAI, that effectively under-prices ABC, making it profitable to swap DAI for ABC, which will bring the pair back inline with the market price.</li><li>Likewise, if there’s too much ABC, it over-prices ABC, making it profitable to swap ABC for DAI.</li></ul><p><strong>Swapping and Fees</strong></p><p>Now that the pair is provisioned, a user can come in with DAI wanting to buy ABC, or with ABC wanting to buy DAI. The rate is determined by the available liquidity, as the smart contract enforces the <em>constant product.</em> With 1000 ABC and 250 DAI, that’s the square root of 1000*250, or 500: whatever remains after the swap must compute to something equal or greater than this amount.</p><p>In addition, the user is charged a fee of 0.3% <em>of the constant product</em>, either by providing more of one token, or getting less of the other. So the swap in fact must result in the constant product <em>with fee</em> increasing or equal. So, if the user wants to buy 10 ABC worth of DAI, instead of getting 2.5 DAI, they will get 2.467895, and the constant product grows to 500.007426. In this way, the holdings of the pair in the underlying tokens grows with each swap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTVSE4vqNgsQGGWB_qpdXg.png" /><figcaption>Swapping tokens in Kadenaswap</figcaption></figure><p><strong>Liquidity Token ownership</strong></p><p>The constant product also faithfully represents AMM positions in the liquidity pool. In the example above, the first provider gets 500 units of the liquidity pool, out of 500 total liquidity. A second AMM coming in with the same amounts also gets 500, but now the total liquidity has risen to 1000. These holdings are stored in the <em>liquidity token </em>for the pair, which in our example is ABC:DAI.</p><p>To access these profits, an AMM <em>removes liquidity</em>. This results in the burning of their liquidity tokens and a redemption of the holdings in the pair tokens in the current ratio. Since this has increased from swaps, the amount of the underlying tokens has grown, and the AMM profits. Note that there is more to this story if the external price has moved, but at least according to the constant product, and trusting that arbitrage has kept the ratio sane, the AMM is strictly richer due to accrued fees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RE5kz-sOGOsea9PgDVA9OQ.png" /><figcaption>Removing Liquidity in Kadenaswap</figcaption></figure><p><strong>Kadenaswap: gas-free, multi-protocol, multi-chain, multi-platform</strong></p><p>Kadenaswap is designed to take the constant product design that has proven so successful with Uniswap and other DEXs and leverage the unique advantages of the Kadena platform.</p><p>First, as an on-chain DEX, Kadenaswap will be <em>multi-protocol </em>from the start, offering any on-chain asset that market-makers want to pool. Unlike many “off-Ethereum’’ DEXes, Kadenaswap pairs are not limited to only super-liquid tokens like BTC and ETH and leading stablecoins, but any fungible asset on-chain, such as protocols that provide unique market access like LUNA and CELO, as well as proven protocols on Ethereum like DAI, and of course all tokens on the Kadena platform.</p><p>Thanks to gas stations, trading on Kadenaswap won’t require a user to hold KDA to trade. Even if they did have to pay gas, gas fees on Kadena are currently microscopic (usually ~0.0000000001 KDA). However, this can change if usage steeply increases. If only running on one chain of the Kadena blockchain, gas prices would inevitably go up for the same reason they do on Ethereum: in the face of congestion, increasing the gas price increases the priority for a miner to include your transaction in the next block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0WoaLF4qrrtlprByThNVg.png" /><figcaption>Kadenaswap Gas Station in action</figcaption></figure><p><strong>Scaling an on-chain DEX</strong></p><p>The real answer to gas prices is <em>scalability</em>. This is where Kadena shines: even the fastest Proof-of-Stake platform has upper limits on throughput, but Kadena’s chainweb protocol uniquely can scale the number of chains to meet any demand. In turn, Dapps on Kadena simply scale out to the number of chains needed to service demand.</p><p>So, just run Kadenaswap on multiple chains, problem solved? Well, not exactly. Chains in Kadena still run independently, and a coin “can’t be in two places at the same time”. Each Kadenaswap smart contract on its own chain will have completely separate pools for a given pair. This can mean prices can get out of sync, but that can be fixed by the same arb-ing described above. The harder problem to solve is <em>liquidity fragmentation, </em>where a pair on one chain has way more inventory (and is therefore a better place to trade) than on another chain.</p><p><strong>Multi-Venue AMM Incentives</strong></p><p>We like to call multi-chain Kadenaswap “multi-venue” to indicate the notion that there is more than one venue where the trade is made. To solve liquidity fragmentation, incentives are needed to reward AMMs for <em>balancing liquidity across venues.</em></p><p>An initial design simply incentivizes AMMs to lock up liquidity in a pair for some period of time, let’s say a week. An AMM can then prove to the same pair on Chain 2 that they are providing equal liquidity on Chain 3 for that same week and receive higher gains accordingly, through either yield incentives, or through a fee structure that rewards cross-chain provisioning higher than single-chain.</p><p>This allows <em>pairs to scale independently</em>: if one pair isn’t overloaded on a single chain, it can enjoy an unfragmented market. Meanwhile, a hard-hit pair can scale to as many chains as demand requires, and market makers will be rewarded for splitting up their positions to service each venue.</p><p>Finally, insofar as pairs are truly isolated, they can simply exist in separate venues. For instance if some altcoin is really only paired with stablecoins, they can all hang out in a single venue, even though other pools with those stablecoins and other coins are scaled over multiple venues.</p><p>If this sounds confusing, worry not: it will be easy to swap and AMM across all chains in Kadenaswap. The hard part is the multi-venue design and incentive structure, which we will be iterating on as we scale. Solving this problem is a first step to building a truly industrial-strength DEX.</p><p><strong>Multi-Platform</strong></p><p>The great thing about Kadena’s multi-chain structure is that it’s truly multi-chain while still being in the Kadena universe: once it’s in motion, the multi-venue design can then scale onto other Pact-supporting platforms like Cosmos, or Polkadot (once the Pact Core/Kadenadot initiatives are ready).</p><p>In this way, Kadenaswap will be the only <strong>multi-venue, multi-protocol, and multi-platform DEX</strong>, leading to a future where users won’t have to even think about platforms and protocols, but just access value wherever it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RV2jy75Q5DPQ-IlObBXBGg.png" /></figure><h3><strong>Bountyswap Live Beta</strong></h3><p>Bountyswap is a “soft”, live-beta launch of Kadenaswap on mainnet, using a “temporary” token that only has value while Bountyswap is in progress. We expect Bountyswap to run for 2–4 weeks, or longer if issues are found. The goal is to use the temporary token to incentivize “white-hat hackers” to try to break the system and steal coins, which is theirs to keep if their hacks are successful.</p><p><strong>“KPenny” temporary Bountyswap token</strong></p><p>We call the Bountyswap temporary token a <em>KPenny</em> which gives a hint of its functionality. KPenny tokens can be reserved for use with Bountyswap at a rate of 1M to 1 KDA token.</p><p>Bountyswap will then launch three pairs on Kadenaswap, using two “test tokens’’ called ABC and XYZ. The three pairs will thus be KPenny:ABC, KPenny:XYZ, and ABC:XYZ. The bountyswap admin marketmaker will provide liquidity in all three pairs. The target quantities will thus represent up to 100,000 KDA, creating a significant “honeypot” to attract hackers to attack.</p><p>At the end of Bountyswap, all KPennys will be returned in the equivalent KDA, and all three tokens will be decommissioned. However, swaps and fees will mean that these values will have changed, and the amount returned will reflect this. This ensures that the “honeypot” will reward the tester if an exploit is found.</p><p>This of course also means that any KPenny token reserved for Bountyswap program is not guaranteed to return to its original owner. Indeed, testers need to be aware that their reservations can be entirely lost due to an exploit or otherwise. But in any case, testers will want to swap out of the test tokens before the program ends. Thus, there will be a “shutdown period” where KPennys will no longer be available for reservation and will only support transfers out of pair accounts. During this time, testers can swap out of XYZ and ABC into KPenny in time for the full shutdown.</p><h3><strong>Get involved with Bountyswap!</strong></h3><p>The <a href="https://kadenaswap.chainweb.com/bountyswap">Bountyswap home page</a> has everything you need to get started. At time of writing, Bountyswap is not live as we’re finishing up KPenny functionality in Testnet. After that, use links there to download/connect your wallet, reserve some KPennys, and get swapping and AMM-ing! Don’t forget to join our communities on <a href="https://t.me/kadena_io">Telegram</a> and <a href="https://discordapp.com/invite/bsUcWmX">Discord</a> to get support, ask questions, and suggest improvements!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecde4cf014dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/introducing-kadenaswap-bountyswap-live-beta-ecde4cf014dc">Introducing Kadenaswap “Bountyswap” Live Beta</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner’s Guide to Kadena: Accounts + Keysets]]></title>
            <link>https://medium.com/kadena-io/beginners-guide-to-kadena-accounts-keysets-fb7f32104291?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb7f32104291</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[innovation]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Tue, 14 Jan 2020 19:48:03 GMT</pubDate>
            <atom:updated>2023-10-13T09:22:47.722Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JfE77s3CWXoDbh4o9F2-gA.png" /></figure><p>When getting started with the <a href="https://www.kadena.io/kadena">Kadena public blockchain</a>, the first thing you’ll want to do is create an account so you can start transacting with other users. This article will break down exactly what keys are, what an account is, the myriad ways to create one, and how to add your account to several existing tools. First, we’ll do an extremely high-level tour of public-key cryptography.</p><h3>What Are Keys?</h3><p>Keys are everywhere in blockchain land. You might at least be aware that to begin transacting in any network, you have to generate a public/private <em>key-pair.</em> Using this pair of keys, you generally share the public one and keep the private one secret, using the private key exclusively for signing transactions. If this is foreign to you, I suggest you take a look at this lovely <a href="https://stackoverflow.com/questions/454048/what-is-the-difference-between-encrypting-and-signing-in-asymmetric-encryption">StackOverflow summary</a> of the metaphor. A key-pair is <a href="https://kadena-community.github.io/kadena-transfer-js/">easy to generate</a>, and looks a little like this:</p><pre>public: 4bf1a0b622650367effca85dd6da35a937bc75fdbbdba04ff7d9338262135e98</pre><pre>secret: 0e809ea42eccb4a90caebeef015dd9ef71a8d1cdfcfabfecb446320dd3bfe7d2</pre><p>Now, the fun part about public/private key-pairs is that a key-pair has the property that the secret key can “prove” you are the owner of the public key through a sophisticated dance (the underlying algorithm), and also has the incredible property that any given key-pair is almost universally guaranteed to be unique. No one will ever be able to produce an exact copy of either key by any reasonable means other than theft. I say “almost,” because there’s still a <a href="https://security.stackexchange.com/questions/2943/what-are-the-chances-to-generate-the-same-ssh-key">probabilistically minute chance</a> that someone may end up generating the same key-pair as you, but the time it would take for that to happen is several trillion years from now, sometime around the <a href="https://en.wikipedia.org/wiki/Heat_death_of_the_universe">Heat Death of the Universe</a> — roughly the same probability as your computer spontaneously catching fire during the generation process.</p><p>In many blockchains, because of the global uniqueness of key-pairs, accounts are modeled as simply public/private key-pairs or a variation on the theme with additional data like a nonce. This is great and makes things simple, but it runs into problems very quickly from a philosophical standpoint. Consider the following question: what do key-pairs represent? Is it an individual? A couple? A throuple? A polycule? A board of directors? If it’s more than one person, what governs usage policy? Certainly, if a married couple decides to open up a joint bank account, it’d be terrible if one could drain the account and leave the other penniless and without recourse. Indeed, joint accounts require multiple-signature signing to release funds. In the same vein, a board of directors would vote, and a majority of votes would determine what to do with the funds of a company. Let’s call this idea <em>governance predicate</em>.</p><p>The metaphor works fantastically well for single-person, single-key-pair accounts, but breaks down in blockchains like Ethereum when a many-to-many relationship and finer-grained multiple-signature governance is needed. Much of the Ethereum ecosystem, for instance, is geared towards finding clever ways to shove the many-to-many idea into a many-to-one box, which ends up being costlier than it needs to be, and frankly, begs a better design. Oddly enough, Bitcoin handles multi-signature accounts just fine.</p><p>This brings us to the notion of Keysets in Kadena.</p><h3>What Is a Keyset?</h3><p>Kadena natively supports multiple keys governing the same account (multi-sig), so <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#keysets-and-authorization">keysets</a> are, to some degree, exactly what they sound like: a set of keys. In addition to a set of keys, every keyset contains something called a ‘predicate function’ that determines which keys are allowed to make choices for the account when it comes to transactions (do all keys need to be present? only one? two? etc.). Summarily, keysets look like the following as JSON data:</p><pre>{ <br>  &quot;keys&quot;: [&quot;pubkey1&quot;, &quot;pubkey2&quot;,...,&quot;pubkeyN&quot;],<br>  &quot;pred&quot;: &quot;some governance function&quot;<br>}</pre><p>When signing a transaction, the list of private keys supplied as signing key pairs will be checked against the keyset and predicate to ensure that not only are all keys that need to be present accounted for but that the predicate is satisfied.</p><p><strong>Predicate Functions</strong></p><p>There are 3 out-of-the-box predicate functions that are available:</p><ul><li>&quot;keys-all&quot;: This predicate will require that all key pairs governing the account are in scope when signing a transaction.</li><li>&quot;keys-any&quot;: This predicate requires that at least one key pair governing the account is in scope when signing a transaction.</li><li>&quot;keys-2&quot;: This predicate requires that at least two key pairs governing the account are in scope when signing a transaction.</li></ul><p>Smart contract authors are free to write their own predicate functions if they need more fine-grained functionality, but that is beyond the scope of this article. Feel free to read up more on predicates in the Pact <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#keysets-and-authorization">readthedocs</a>.</p><p><strong>When Are Two Keysets the Same?</strong></p><p>Two keysets are the same when all of their keysets match, and they have the same predicate function guarding the keys. This means that if you have an account defined in the coin contract as the following data:</p><pre>key: &quot;Emily&quot; -&gt; value: { 0.0, { [&quot;fcca3bc5...&quot;], &quot;keys-all&quot; }}</pre><p>And someone attempts to transfer-create (see: <a href="https://medium.com/kadena-io/kadena-public-blockchain-getting-started-with-transfers-153bf87d6824">getting started with transfers</a>) to your account (which checks the keyset against the one supplied by the sender) with the following data:</p><pre>(transfer-create 1.0 &quot;Emily&quot; { [&quot;fcca3bc5...&quot;], &quot;keys-any&quot; })</pre><p>Then this will fail because the keyset governing the account is wrong, and the blockchain will see the transaction as someone using the wrong keys to try and access an account. If you imagine a board of directors sitting around and all of them have to be present to make a vote, but some bozo comes in trying to say only 1 of them needs to be there and the rest can go home, that person would be laughed out of the room! The same goes for keysets. Make sure the keys match <strong>exactly</strong>.</p><h3>What Is an Account?</h3><p><a href="https://www.kadena.io/">Kadena</a> is unique in the fact that there is no global notion of what an account is. Even the <a href="https://minerstat.com/coin/KDA">KDA token</a> exists as a smart contract in the network! It turns out that in the Kadena blockchain, every smart contract can define their own tables and interact with them in a robust way, defining their own data structures, called <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#defschema"><em>schema</em></a><em>. These schemas</em> are used inside the contract to define the table structure, and therefore the way the contract will store data. It just so happens that this is exactly what the KDA coin contract does — it defines a table called coin-table along with a schema called coin-schema , which defines the general model for interacting with tokens. The schema is rather simple — row keys are account names, and the data it points to are a balance and a set of keys governing the account. Visually, it looks like this:</p><pre>key: Account Name -&gt; value: { Balance, Keyset }</pre><p>In practice, many people are used to the model that blockchains like Ethereum or Bitcoin use, where public keys are considered an “address,” and there is an associated balance. This is very similar to what Kadena has. In fact, if you make your account name your public key, then it looks roughly the same:</p><pre>key: &quot;f1f6f54914f33...&quot; -&gt; value: { 0.0, [&quot;f1f6f54914f33...&quot;] }</pre><p>But if you really want to get fancy, then you can have a custom name as your account name:</p><pre>key: &quot;2Chainz&quot; -&gt; value: { 0.0, [&quot;f1f6f54914f33...&quot;] }</pre><p>It doesn’t really matter — you just have to remember it! Practically, this is why people just go with a public key as their account name — it’s right there in the keys. As more sophisticated technology comes out supporting the Kadena ecosystem, and as wallet technology gets better and better, tracking this sort of thing will be taken care of automatically.</p><h3>Creating Accounts</h3><p>Account creation happens in the blockchain in a few ways:</p><ul><li>When mining to an account and a keyset, when you win a block, the reward will create your account automatically using the keyset and account you specified. By default, if you just submit your public key as the argument to your keyset, then a singleton keyset will be constructed and your predicate will be set to keys-all.</li><li><a href="https://github.com/kadena-io/chainweb-node/blob/c9aaff7719b7a40d0deb900393379c6b8540e4bf/pact/coin-contract/v2/coin.pact#L228">coin.create-account</a> which allows someone to create a zero-balance new account (note that this costs gas, which would have to be paid by a different account, which is possible with Kadena).</li><li>Someone used <a href="https://medium.com/kadena-io/kadena-public-blockchain-getting-started-with-transfers-153bf87d6824">transfer-create</a> or <a href="https://medium.com/kadena-io/kadena-public-blockchain-getting-started-with-transfers-153bf87d6824">transfer-crosschain</a> to transfer coins to an account that did not exist (those functions spontaneously create an account and deposit the transfer amount into it if the account doesn’t exist).</li></ul><p>Just creating a public key pair is not the same as creating an account in the blockchain, but it does guarantee that you have a unique account name. Cryptographically, public keys are almost guaranteed to be uniquely generated, so people often conflate the two.</p><h3>Chainweaver Accounts</h3><p>Along with its blockchain, Kadena released a wallet for Mac, called <a href="https://www.kadena.io/chainweaver">Chainweaver</a>, and this wallet allows you to create accounts easily with the click of a button. We’ve done a full write-up of how to create accounts, keys, and make use of the wallet’s numerous features <a href="https://medium.com/kadena-io/do-anything-on-the-kadena-blockchain-with-a-single-tool-cf22986a81af">here.</a></p><h3><strong>Conclusion</strong></h3><p>There you have it: this has been a tour of accounts! This is one of the more fundamental aspects of interacting with the Kadena blockchain, and I’m glad you took the time to read about it. We’ve made some great improvements to the way people interact with blockchains, supporting native multi-sig and custom smart contract table design, and we are happy to take on board any feedback you can give.</p><p>We also welcome help from the community for documenting these tools and constructing new ones along the way. We are always happy to rep community-blessed tools if they are better than our own. We welcome anyone to contribute to the <a href="https://github.com/kadena-community">Kadena Community projects repository</a> with your own project or add to existing ones. So far, the community projects have yielded both a great terminal wallet with <a href="https://github.com/kadena-community/bag-of-holding">Bag of Holding</a>, and a <a href="https://github.com/kadena-community/bigolchungus">blazing fast GPU miner</a> courtesy of Alex Khonovalov, Edmund Noble, and myriad other insanely smart community members.</p><p>Thanks to everyone who contributed, and please feel free to raise your questions to me in <a href="https://discord.gg/kadena-io">Discord </a>— my handle is one of @topos, <a href="https://twitter.com/pitopos">@pitopos</a>, or <a href="https://github.com/emilypi">@emilypi</a> depending on where I am on the internet. I’m perpetually glued to my screen, so I’ll usually answer if you find me. In the event I’m sleeping, there may be a delay.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb7f32104291" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/beginners-guide-to-kadena-accounts-keysets-fb7f32104291">Beginner’s Guide to Kadena: Accounts + Keysets</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kadena Public Blockchain: Getting Started with Transfers]]></title>
            <link>https://medium.com/kadena-io/kadena-public-blockchain-getting-started-with-transfers-153bf87d6824?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/153bf87d6824</guid>
            <category><![CDATA[kadena]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Thu, 19 Dec 2019 21:18:27 GMT</pubDate>
            <atom:updated>2020-06-25T13:52:52.677Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N20Oo9xivfuJFuug.png" /></figure><p>Kadena began enabling Kadena (KDA) token transfers on December 17. The network has experienced some serious growth as we’ve transitioned from testnet to mainnet, with over <a href="https://explorer.chainweb.com/mainnet">1,000,000 blocks mined</a> by more than 10,000 GPUs (at an average hash rate between 10–15 TH/second) on mainnet. We’ve been heavily relying on the community to help establish best miner practices in the network.</p><p>Now, tokens earned by miners are transferrable to and from other accounts (peer-to-peer). Because transfers are such an integral part of any blockchain ecosystem, we’ve decided to publish this post as an introduction to the Pact smart contract system. We’d like to illustrate the myriad ways to transfer tokens and highlight some of the technologies available to users to do so. We’ll break down this tutorial into three steps of varying levels of sophistication: using Pact to create a smart contract, the standalone transfer portal, and transferring with the Chainweaver Wallet.</p><p>Hopefully, this will get you excited to begin your journey with Kadena. Let’s get started!</p><h4>The Kadena Coin Contract</h4><p>Kadena’s coin contract was made available as a <a href="https://explorer.chainweb.com/mainnet/chain/0/height/0">transaction at genesis</a>, which means the token is a contract in the same way that any other contract exists in the blockchain (though, it is somewhat special with the way each Chainweb node interoperates with it natively). While we don’t yet have a module explorer for people to browse module code (coming soon when smart contracts are turned on), you can browse <a href="https://github.com/kadena-io/chainweb-node/blob/master/pact/coin-contract/v2/coin.pact">the source</a> and the <a href="https://github.com/kadena-io/KIPs/blob/kip-0002-proposal/kip-0002.md">Kadena Improvement Process (KIP-0002) RFC</a> for the fungible asset token (KDA) on which it’s based to get a feel for both the Pact language and the fundamental operations available in the contract. Most notable among these are the specifications for how to transfer KDA to and from accounts on the blockchain. We’ll go through the accounts and the types of transfers available to you in the next few sections, and then move on to a tutorial for how to actually put transfers into practice along with some of the available tools.</p><h4>How are Kadena Accounts Structured?</h4><p>We’ve written up a <a href="https://medium.com/kadena-io/beginners-guide-to-kadena-accounts-keysets-fb7f32104291">Beginner’s Guide to Accounts</a> in the Kadena blockchain, but let’s do a whirlwind tour here just to refresh. The Kadena blockchain is unique in the sense that each chain is a separate blockchain for which a global consensus is maintained, and there is no global notion of “account” or “address.” On each chain, however, there is a keyset registry that makes sure that no keyset gets duplicated. This means that the final decider for what uniquely identifies a user of the blockchain is their keyset on a given chain (<a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#keysets-and-authorization">read here for more on keysets</a>). If you choose to have your keyset only exist on chain 0, that’s your prerogative and perfectly fine. However, users may find it simplifies things if they define their keyset on all chains to avoid confusion, even though there’s a cryptographically nil chance that anyone else might have the same keys on a different chain.</p><p>Every smart contract has the ability to maintain its own ledger (a key-value store) that defines the data structures it works with. In the case of the coin contract, every entry into the coin contract ledger is specified by an account name (any LATIN-1 string between 3 and 256 characters) as a key, with a value of both a decimal balance and a keyset that governs the account. Account names can be anything as long as they conform to that spec. You could be &quot;emily&quot;, &quot;stone cold steve&quot;, or simply the public key associated with your keyset as an account name. Many users find the latter to be the easiest to remember. Since the chance of overlap is negligible, it helps them remember which keys they’re supposed to use for that particular account. I support this, as the two accounts &quot;emily&quot; and &quot;Emily&quot; are distinct and it can be easy to forget which is yours. We call accounts that are not simply the public key string “vanity accounts” (like vanity license plates), to distinguish naming conventions.</p><p>So, to summarize,</p><pre>key: Account name -&gt; value: { Balance, Keys }</pre><p>It’s that simple! Now, let’s talk about the types of transfers available with this token.</p><h4>Types of Available Transfers</h4><p>I’ve shown you how to construct a simple coin transfer, but now let’s talk about the types of transfers available to you, the user. The coin contract has 3 in total to address varying use-cases:</p><ul><li>coin.transfer: This function is for transfers between two existing accounts on the same chain, for some decimal number of tokens. This is the one I showcased above, and is the most basic of the transfers. It works exactly as you might imagine.</li><li>coin.transfer-create: In the case where the recipient of the transfer perhaps does not exist, transfer-create is how you would transfer coins safely to the receiving account. If the recipient already exists, then coin.transfer-create works exactly as coin.transfer would with a single exception. You must know the <a href="https://pactlang.org/beginner/pact-keysets/">keyset</a> of the account you’re transferring to and provide it as a parameter to the function. When the receiving account exists, the keyset you’ve passed along is checked against the keyset on file for the account to make sure they’re the same for executing the transfer as expected. When the account <em>does not exist</em>, however, an account will be constructed using the recipient account and keyset with the balance transferred from the sender account. In general, this function is safer than coin.transfer, but that safety comes at the cost of convenience. I recommend using this one whenever possible.</li><li>coin.transfer-crosschain: This function is especially interesting in that it is the only way to transfer tokens from one chain to another, and is a more involved process that requires you to learn about <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#defcap">defpact continuations</a> in Pact. I plan to cover this in a separate tutorial, where I have the opportunity to explain both defpact and Simple Payment Verification (SPV) in Pact and how cool it is (sorry <a href="https://medium.com/u/fc34cdb2e767">Thanos</a>!). In the meantime, just know that there is a way of transporting tokens across blockchains natively, available in Kadena (and Pact).</li></ul><h3>Smart Contracts with Pact</h3><p><a href="https://www.kadena.io/pact">Pact</a> is the smart contract language running at the heart of the Kadena public blockchain. We’ve produced a <a href="https://pactlang.org/">bunch of tutorials</a> on every aspect of the Pact language ecosystem, but we’ll review a few here to illustrate our use-case. This will be done with Pact 3.3, the currently available version of Pact.</p><h4>Creating an API request</h4><p>Smart contracts are written in Pact. To actually get them into a block on the blockchain, they need to be sent to a blockchain node. This is done by formatting an <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#rest-api">API request</a> and sending the request to the appropriate endpoint. Pact has this functionality built into the language in the form of the pact -a family of commands. To make use of pact -a, one must create an API request template that takes the form of a YAML script pointing at (or containing) Pact code, which is then converted into the appropriate JSON representation. A user may then submit this JSON in a cURL request (or e.g., a Postman request) to the blockchain for processing.</p><p>For example, if I wanted to transfer 1.0 KDA from my vanity account, emily to nick-cage because I’m such a huge fan, I would construct a YAML template request like the following (note: using a burner keypair generated by pact -g for demonstrative purposes):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*SMQl0hcXoW7HIFRn.png" /><figcaption>Nick Cage boutta be stoked</figcaption></figure><p>This looks complicated. Unfortunately, it is, which is why we automate this all in the wallet. All you have to do is toggle the knobs with whatever is appropriate. However, it’s still good to know about what settings you’re able to toggle to achieve an optimal transaction specification. The anatomy of this request can be broken down as follows:</p><ul><li>(<strong>code|codeFile</strong>): This field is either the raw code you wish to execute or a reference to a .pact file containing the smart contract you wish to execute.</li><li><strong>publicMeta</strong>: This field contains all of the blockchain-specific metadata needed to interact with the Kadena public blockchain. It speaks for itself. A user must specify how much gas they’re willing to pay and at what price, where they’re sending it, who the sender is, etc. The creation time and TTL define what period of time your transaction can be submitted to the blockchain. The creation time is the time that your transaction can first be submitted (specified as the number of seconds since 1970 — i.e. since POSIX epoch) and the TTL (time to live) is how many seconds it will be valid for before being removed from the mempool. In practice, you can also go to <a href="http://duckduckgo.com/">duckduckgo.com</a> and search for ‘unix epoch’ to get the current time, but I’ll usually just go into Node.js and run the following:</li></ul><pre>Math.round((new Date).getTime()/1000)-15;</pre><ul><li><strong>networkId</strong>: This field describes the ID of the receiving network. Since Pact is blockchain-agnostic, this may be Tendermint, or Polkadot, or any of the myriad blockchains supported or to be supported in the future. Currently, the network ID for the main Kadena network ismainnet01, but through this tutorial, I’ll be running on testnet04 to make sure no actual transactions go into the main blockchain.</li><li><strong>keyPairs:</strong> The public/private fields are self-explanatory — you have to sign the transaction somehow. The less obvious field is for capabilities allowed in the transaction. Capabilities are an integral part of the Pact security model. If a particular smart contract supports capabilities, then you’re allowed to say exactly what operations you (the signer) allow for use of your keys. In the case of the Kadena coin contract, we’re allowing my keypair to be used for gas payments, as well as a transfer of a specific amount. These operations can be automated and brought into scope by contract control flow, but the coin contract requires your feedback for safety reasons.</li><li><strong>type</strong>: This will only ever be exec for one-off scripts, or cont for escrow continuations. In our case, we’re executing a one-off transaction.</li></ul><p>For a more complete specification of the available options, consult the <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#api-request-formatter">Pact API Request Formatter documentation</a> and the tutorials on <a href="https://pact-lang.org/">pact-lang.org</a>. Here’s a template that can be copied and pasted for your requests:</p><pre>code:<br>data:<br>networkId:<br>publicMeta:<br>  chainId:<br>  sender:<br>  gasLimit:<br>  gasPrice:<br>  ttl:<br>  creationTime:<br>keyPairs:<br>  - public:<br>    secret:<br>    caps: <br>type: exec</pre><p>And here’s the one I used that you can cargo cult for yourself and change all of the bracketed fields:</p><pre>code: |-<br>  (coin.transfer &lt;from&gt; &lt;to&gt; 1.0)<br>publicMeta:<br>  chainId: &quot;0&quot;<br>  sender: &lt;from&gt;<br>  gasLimit: 600<br>  gasPrice: 0.0000001<br>  ttl: 600<br>  creationTime: &lt;regenerate this&gt;<br>networkId: &quot;mainnet01&quot;<br>keyPairs:<br>  - public: &lt;public&gt;<br>    secret: &lt;secret&gt;<br>    caps:<br>      - name: &quot;coin.TRANSFER&quot;<br>        args: [&lt;from&gt;, &lt;to&gt;, 1.0]<br>      - name: &quot;coin.GAS&quot;<br>        args: []<br>type: exec</pre><p>Once I have this YAML file all figured out, I generate the following JSON request using pact -a and passing in the YAML file as a parameter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vAXxFno45PhS68NR.png" /><figcaption>Nick Cage waits impatiently…</figcaption></figure><p>Now, I have a JSON object that I can post to the /send endpoint of the Pact Service API for the Kadena blockchain. In practice, this will be a POST request with the formatted JSON object on a node endpoint which takes the following form: https://&lt;host&gt;:&lt;port&gt;/chainweb/0.0/&lt;network-id&gt;/chain/&lt;chain id&gt;/pact/api/v1/send. Here is an example cURL request that I’m using:</p><pre>curl --location --request POST &#39;<a href="https://us2.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/api/v1/send&#39;">https://us2.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/api/v1/send&#39;</a> \<br>--header &#39;Content-Type: application/json&#39; \<br>--data-raw &#39;{&quot;cmds&quot;:[{&quot;hash&quot;:&quot;F7jzCyUgwcBUWYVe3xEFw66X45NHgheNrqm8LL9gMIU&quot;,&quot;sigs&quot;:[{&quot;sig&quot;:&quot;c0024309593b8b28b356c5edfed957c1dd7e163eecc446a327fa8d4db76faccc111b11786fe9cc6fc200ceab137d53f4df46ab76aa7f268be183289f282db20e&quot;}],&quot;cmd&quot;:&quot;{\&quot;networkId\&quot;:\&quot;testnet04\&quot;,\&quot;payload\&quot;:{\&quot;exec\&quot;:{\&quot;data\&quot;:null,\&quot;code\&quot;:\&quot;(coin.transfer\\n  \\\&quot;emily\\\&quot;\\n  \\\&quot;nick-cage\\\&quot;\\n  1.0)\&quot;}},\&quot;signers\&quot;:[{\&quot;pubKey\&quot;:\&quot;368059ab25bec92f19a4f8ce172030e5d672e4879aaae8d5be8b705dd3dfae7f\&quot;,\&quot;clist\&quot;:[{\&quot;args\&quot;:[\&quot;emily\&quot;,\&quot;nick-cage\&quot;,1],\&quot;name\&quot;:\&quot;coin.TRANSFER\&quot;}]}],\&quot;meta\&quot;:{\&quot;creationTime\&quot;:1576691834,\&quot;ttl\&quot;:600,\&quot;gasLimit\&quot;:100000,\&quot;chainId\&quot;:\&quot;0\&quot;,\&quot;gasPrice\&quot;:1.0e-7,\&quot;sender\&quot;:\&quot;emily\&quot;},\&quot;nonce\&quot;:\&quot;2019-12-18 17:58:40.212918 UTC\&quot;}&quot;}]}&#39;</pre><p>When the blockchain has accepted your request, you’ll get a request key back — the unique key associated with your request as it’s processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/0*r-_QKJ7NrIUQF1w3.png" /><figcaption>Nick Cage is on the edge of his seat</figcaption></figure><p>To see the outputs of your transaction, POST that request key JSON object to the /poll or /listen endpoints. When the transaction has been mined and exists in some block, you’ll get a response back. Note that it may take a few block heights (i.e. 30–90 seconds) to see your transaction, and you will not receive outputs during that time. Here’s an example of a /poll cURL request and the response:</p><pre>curl --location --request POST &#39;<a href="https://us2.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/api/v1/poll&#39;">https://us2.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/api/v1/poll&#39;</a> \<br>--header &#39;Content-Type: application/json&#39; \<br>--data-raw &#39;{<br>    &quot;requestKeys&quot;: [<br>        &quot;BYHjcdTqqMTROLasn82ka-DpYhE9Q1K3nFxt5vcXxGQ&quot;<br>    ]<br>}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/0*HrFtsdIQXHeLhNAG.png" /><figcaption>Nick Cage just got paid!</figcaption></figure><p>Success!</p><p>We realize that this is a low-level technically intensive process, but like every API on the web, there exist tools that automate this experience and provide varying levels of sophisticated UI to help make the process seamless. We’ll get into these tools below, but first, let’s talk about dry-running transactions to make sure that they succeed.</p><h4>Using /Local to Dry-Run Transactions</h4><p>The Kadena blockchain follows the example that Ethereum set by charging the gas limit specified in a transaction in the case that the transaction fails. This takes place for a few very important reasons:</p><ul><li>It incentivizes users to only submit transactions they know will succeed, or get penalized. This closes a serious DOS vector for node operators.</li><li>Miners are compensated for computational costs of failing transactions, which may fail for a variety of nondeterministic reasons, such as database datasets exploding in size to the point that transactions can’t cover them.</li><li>To a lesser extent, it incentivizes automation and “safe” modes of transaction, such as wallet or script use that contribute toward a robust ecosystem.</li></ul><p>On its own, this would be a rather punishing system. After all, it is inevitable that new users will be unfamiliar with how to transact with the blockchain. And even more so inevitable that people make mistakes when transacting. To provide as much information as possible, every Kadena node has a dedicated endpoint called /local on which a user can dry-run their transactions and discover the costs and outputs of a given transaction.</p><p>As mentioned above, pact -a is a family of commands. The command that generates a valid local request is pact -l -a, and can be used with any existing request YAML to produce a JSON object compatible with the /local endpoint of any node. Chain ID does not matter in this case — the endpoint will accept any valid command — but it’s good to provide accurate information to produce valid feedback for the dry run. As above, we’ll reuse the existing transfer request from &quot;emily&quot; to &quot;nick-cage&quot;:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*SMQl0hcXoW7HIFRn.png" /></figure><p>Now, let’s submit this to pact -l -a. This will generate the following JSON object:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mylOMmYXfs9jOjvb.png" /><figcaption>Nick Cage is getting locally stoked</figcaption></figure><p>Then, let’s send this to the /local endpoint. This time, rather than receiving a request key, we receive the outputs directly along with some additional metadata not included with the outputs of a /send transaction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*Wx-n9lu36ul8oDMD.png" /></figure><p>The outputs display the results, the logs, a request key, all of the metadata used in the transaction, along with the most up-to-date block time, parent block hash, and block height on that chain. Not only do you know if your transaction will succeed, but you’ll have all the context you need to figure out why it failed. Let’s see what failure looks like in this mode by using a user that does not exist as the recipient of our transfer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C6aplWmRVjI50cHX.png" /><figcaption>Lol he is definitely not Nick Cage</figcaption></figure><p>Our recipient, “Lol I am definitely not Nick Cage,” does not exist in the blockchain, and so I’ve received confirmation that my transaction failed. This information is sent along with the callstack, type of error, specific failure message, and wherein the coin contract the code that called it failed.</p><h3>Tools for Transfers</h3><p>As mentioned above, there are a few tools available to you that automate the construction of API requests (and transfers in particular). They are available in a few different forms.</p><h4>Community Transfer Scripts</h4><p>There is a <a href="https://github.com/kadena-community/kadena-transfer-js">standalone community transfer</a> script which automates the construction of transfers by providing web fields which fill in the necessary information for your API request and call our <a href="https://github.com/kadena-io/pact-lang-api">Pact Lang Javascript API</a> which sends the transactions for you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/0*DaUrf1kHUqfs64B4.png" /></figure><p>You can either set this up in your browser by using the index.html provided, or you can run it as a standalone script with node as described in the README.md of the project. If you read the first section thoroughly, it should all be very familiar, and you can picture how the YAML is being created and sent via this information. However, you’ll see that there’s a lack of gas and TTL/creationTime. That is because we’ve chosen some sensible defaults that should make the process even easier. This script will run a coin.transfer or coin.transfer-create depending on the parameters you supply. Pool operators and power miners such as BigShoots <a href="https://bigshoots.net/kadena/kadena-transfer/">have set this up on their nodes</a> as a courtesy to other users (thanks BigShoots).</p><h4>Chainweaver Wallet</h4><p>If you’re on Mac or Linux, you can make use of Kadena’s in-house Smart Wallet offering: the <a href="https://www.kadena.io/chainweaver">Chainweaver Wallet</a>.</p><p>The Chainweaver Wallet features a full Pact IDE (including a REPL) for authoring smart contracts and interacting with existing smart contracts on the Kadena blockchain in addition to its account servicing features. I recommend you run the wallet from the perspective of a smart contract writer (and, for transparency, a Kadena employee).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InzUGFWZa3qVMCGz0vk50g.png" /><figcaption>Chainweaver Accounts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhD0Y3potANXrt29pt4GJA.png" /><figcaption>Beautiful isn’t it? This is the Pact IDE embedded in the wallet</figcaption></figure><p>Chainweaver has a great UI for sending and receiving tokens using a novel address format for Chainweaver users that we are calling a Kadena Address. In the Wallets tab, locate your Chainweaver account and simply click the “send” tab, which will take you into a small popup window in which you can paste the Kadena Address of the receiving account. Depending on the context, Chainweaver can detect whether a particular receiving account exists and on what chain, and will choose whether to use coin.transfer, coin.transfer-create, or coin.transfer-crosschain depending on that context. It will even automate the previously manual step of constructing an SPV proof in the case of a cross-chain transfer. We’ve written up a <a href="https://medium.com/kadena-io/do-anything-on-the-kadena-blockchain-with-a-single-tool-cf22986a81af">thorough tutorial </a>to help you understand all of the snazzy features available in Chainweaver.</p><h4>Additional Wallet Options</h4><p>We welcome any wallet additions as community projects and will be happy to help set you up with a dedicated repository in our <a href="https://github.com/kadena-community">Kadena Community GitHub</a> organization if you have a submission. There is one already, courtesy of our Kadena’s Colin Woodbury (@fosskers). He wrote a fantastic CLI wallet aptly named <a href="https://github.com/kadena-community/bag-of-holding">Bag of Holding,</a> which you can operate from your terminal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/0*dcHxj1YuPBHz9rh9.png" /></figure><p>Bag of Holding works essentially as a nice UI around the creation and execution of API requests as described earlier in this article. It’s solid, simple, reliable, and (I think) looks great.</p><h3>Conclusion</h3><p>There you have it: an introduction to Pact transactions by way of transfers. Our tooling is in the very early stages. We welcome help from the community for documenting these tools and constructing new ones along the way. We are always happy to rep community-blessed tools if they are better than our own. We welcome anyone to contribute to the <a href="https://github.com/kadena-community">Kadena Community projects repository</a> with your own project or add to existing ones. So far, the community projects have yielded both a great terminal wallet with <a href="https://github.com/kadena-community/bag-of-holding">Bag of Holding</a>, and a <a href="https://github.com/kadena-community/bigolchungus">blazing fast GPU miner</a> courtesy of Alex Khonovalov, Edmund Noble and myriad other insanely smart community members.</p><p>Thanks to everyone who contributed, and please feel free to raise your questions to me in <a href="https://discord.io/kadena">Discord</a> — my handle is one of @topos, @pitopos, or @emilypi depending on where I am on the internet. I’m perpetually glued to my screen, so I’ll usually answer if you find me. In the event I’m sleeping, there may be a delay.</p><h3>Glossary</h3><ul><li><strong>Keyset:</strong> Refers to the <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#keysets-and-authorization">Pact Keyset</a> authorization scheme. These are a set of public keys in addition to a predicate function (e.g. keys-all, keys-any etc.) that decides the authorization policy for the keys in the keyset. For example, if I have a set of keys with the keys-all predicate, then all keys must be present as signers in a transaction to do anything with the keyset.</li><li><strong>Account:</strong> An entry in the Kadena coin contract ledger (a key-value store). This consists of a string of 3 to 256 LATIN-1 characters as a key, pointing at a value consisting of a decimal balance and a keyset governing the account.</li><li><strong>Vanity Account:</strong> We call accounts “vanity” accounts when they have a custom vanity name that is not just the public key string associated with a keyset. Think of it like a vanity license plate.</li><li><strong>Token (KDA):</strong> When we refer to “the” token, we refer to the definition and implementation of the Kadena fungible asset specification, called fungible-v1 and coin, respectively. In practice, this just means<a href="https://github.com/kadena-io/chainweb-node/blob/master/pact/coin-contract/v2/coin.pact"> the coin contract</a>!</li><li><strong>Smart Contract:</strong> <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#module-declaration">Pact modules</a> define smart contracts.</li><li><strong>API Request:</strong> An HTTP request sent to one of the <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#endpoints">endpoints</a> available on any Kadena Blockchain Node.</li><li><strong>Transaction: </strong>An API Request sent to the /send or /local endpoints of a node, which executes Pact code. Sending an API request to the /send endpoint results in a transaction that gets included in a block, while a request to /local will not.</li><li><strong>Capability:</strong> This refers to the <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#guards-and-capabilities">capability permissions system</a> baked into the Pact language. More on this to come.</li><li><strong>Dry-run:</strong> A transaction sent to the /local endpoint.</li><li><strong>Gas: </strong>How many units of compute (i.e. tokens) it takes to run a transaction</li><li><strong>Gas Limit: </strong>How much gas is available for the transaction, specified by the user.</li><li><strong>Gas Price:</strong> The price of gas that the user is willing to pay. This is a decimal multiplier for the gas limit, which results in the final gas supply available for a transaction. The result is measured against how much gas it takes to run a transaction to determine the miner reward, and any refunds the user might receive (i.e. total gas supply minus total gas used).</li><li><strong>Chain Id:</strong> The identifier for a given chain in the Kadena blockchain. (Currently, they are 0 through 9).</li><li><strong>Creation Time:</strong> Time in seconds since POSIX epoch (i.e. since 01/01/1970:00:00:00) that marks the earliest time that a transaction should be considered a candidate to be included in a block.</li><li><strong>TTL:</strong> Time-to-Live — the expiration date in seconds for how long a transaction should be considered for candidacy in a block after its creation time. TTLs can be at most 48 hours after the initial creation.</li><li><strong>Network Id:</strong> The unique identifier for the network (e.g. testnet04 or mainnet01)</li><li><strong>KeyPair:</strong> A public/private keypair.</li><li><strong>Public Metadata:</strong> The non-transactional data of a Transaction used to interact with the blockchain (i.e. what chain ID, TTL, creationTime, who the sender is, etc.)</li><li><strong>Blockchain Node:</strong> A <a href="https://github.com/kadena-io/chainweb-node">Kadena node</a></li><li><strong>Wallet:</strong> A device, physical medium, program or service which stores the public and/or private keys. It can be used to track ownership, receive, or spend cryptocurrencies.</li><li><strong>Kadena Address:</strong> The unique, secure format in which the Chainweaver Wallet stores accounts.</li><li><strong>IDE:</strong> Integrated development environment</li><li><strong>REPL:</strong> <a href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop">Read-eval-print-loop</a>. Many languages have this as a means of getting fast feedback and running code.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=153bf87d6824" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/kadena-public-blockchain-getting-started-with-transfers-153bf87d6824">Kadena Public Blockchain: Getting Started with Transfers</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pact 3.1 is Unleashed!]]></title>
            <link>https://medium.com/kadena-io/pact-3-1-is-unleashed-ebfddfb648ce?source=rss-21a77a0712aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebfddfb648ce</guid>
            <category><![CDATA[kadena]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[pact]]></category>
            <dc:creator><![CDATA[Emily Pillmore]]></dc:creator>
            <pubDate>Thu, 22 Aug 2019 15:01:01 GMT</pubDate>
            <atom:updated>2019-08-22T15:58:36.497Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pcj9Zf_irC35TwEGJlpz1Q.png" /></figure><p>After a lot of hard work by the team at <a href="http://kadena.io/">Kadena</a>, we are pleased to announce the release of <strong>Pact 3.1!</strong> This new version of Pact brings significant additions to the language, including expanded <a href="https://medium.com/kadena-io/pact-formal-verification-for-blockchain-smart-contracts-done-right-889058bd8c3f">Formal Verification</a> coverage for our interfaces and governance, and our new cross-chain features in defpact, which makes it dead simple to write cross-chain multi-step transactions.</p><p>These features continue to reinforce Pact as the premier standard for smart contract authoring in both public and private blockchains. You can try the latest version of Pact out by <a href="https://github.com/kadena-io/pact#installing-pact-with-homebrew-osx-only"><strong>downloading from our Github</strong></a><strong>.</strong></p><h3>Formal Verification</h3><p>Pact 3.1 pioneers new features that make the more complex parts of writing smart contracts as easy as possible. Along with these features, we’ve continued expanding our<strong> Formal Verification</strong> coverage.</p><h4>Pact Interfaces</h4><p>Interfaces were introduced into <a href="https://medium.com/kadena-io/announcing-pact-3-0-4b0a8f35e6a0">Pact in 3.0</a> as a way to allow users greater flexibility when layering behaviors in module code. These constructs act similarly to the interfaces in Java, or traits in Rust and Scala, with one big difference. In Pact 3.1, users can now write Formal Verification properties and even define their own custom models in the bodies of interfaces and their function signatures!</p><p>When a module implements an interface containing these properties, those properties are inherited by the module. If a module implements more than one interface, every interface’s properties are imported together, to provide the module with that much extra security. This allows users to write the specifications and laws for a module. Interfaces can thus provide robust hierarchies of safe, secure, and <em>reusable</em> smart contract behaviors with the help of Formal Verification. You can read more about interfaces and see example code <a href="https://pact-language.readthedocs.io/en/stable/pact-reference.html#interfaces">here</a>.</p><h4>Verified Governance</h4><p>For the <a href="https://medium.com/kadena-io/announcing-pact-3-0-4b0a8f35e6a0">Pact 3.0 release</a>, we debuted an exciting new set of features in Pact: <strong>guards </strong>and <strong>capabilities</strong>. These primitives allow you to create robust and flexible security metaphors as a native feature of the language. With Pact 3.1, we are proud to announce that we have Formal Verification analysis for guards and capabilities, allowing you to not just write secure and flexible code, but <em>prove</em> that it is secure and flexible code.</p><p>When writing formal verification properties for a function, users can combine a security predicate for a guard or capability such as(authorized-by ‘my-keyset)with the new governance-passes property to enforce their requirements. You can even analyze governance over database operations guarded by security protocol.</p><h4>Defpact step signatures</h4><p>One of the killer features in Pact is its ability to support generalized, multi-step transactions (e.g. escrow transactions) built directly into the core of the language via the defpactconstruct. Formal Verification in Pact now allows you to specify properties for each step in a defpact so that users can make each step sound and secure.</p><p>This is just one aspect of some of the updates we’ve made to defpacts this release. On top of this, we’ve added an incredible new feature: cross-chain transactions.</p><h3>Cross-chain Multi-step Transactions</h3><p>One of the boldest new features in this version of Pact comes as part of our ongoing work on the testnet for <a href="https://medium.com/kadena-io/announcement-kadena-public-blockchain-testnet-live-dbfb8a6477c5">our public blockchain</a>.</p><p>Blockchains like Bitcoin and Ethereum are traditionally single-chain, so their currencies naturally live on one chain. But what happens when you have a whole bunch of chains working in consensus, like in our Chainweb protocol? A currency is defined on a per-chain basis, so there would be as many currencies in the network as there would be chains. However, at Kadena, we have solved the problem of unifying disparate currencies in a multi-chain network with the power of two pre-existing standards in both Pact and the blockchain ecosystem: <strong>simple payment verification (SPV)</strong> and <strong>multi-step </strong><strong>defpact transactions.</strong></p><p>The Kadena <a href="https://github.com/kadena-io/chainweb-node/blob/master/pact/coin-contract/coin.pact#L195">coin contract</a> allows users to transfer any number of tokens from an account on one chain to an account on another chain using the power of SPV. In fact, it looks the same as your standard single-chain transfer, except now users can specify an extra parameter: the <em>target chain</em> to which they want their tokens sent.</p><p>Defpacts already had yieldand resume to securely forward data between steps. As of Pact 3.1, cross-chain transactions are as simple as specifying a target chain you’d like to yield some data to in the following step. For a user to perform the second step on the target chain, they simply provide the correct SPV proof data as part of a continuation request, and theresume call in that step will perform the proof and retrieve the data automatically.</p><p>Coin transfers are a simple example of the more general concept of cross-chain multi-step transactions: the ability to execute multi-step transactions, of which each step can occur on a <em>different chain</em>. Pact now supports this by default!</p><h4>Conclusion</h4><p>To learn more about writing safe smart contracts in Pact, visit our educational resources:</p><ul><li><a href="http://pactlang.org/">PactLang.org</a> — find videos, tutorials, and example code.</li><li><a href="http://pact.kadena.io/">Try Pact </a>— start exploring Pact (3.0) in your browser, no downloads necessary!</li><li><a href="http://discord.io/kadena">Beta test smart contracts</a> — get in touch with the team via Discord if you want to participate in our public blockchain testnet.</li><li><a href="http://kadena.io/aws">AWS Marketplace</a> — take our private blockchain for a (free) spin and try out some of these cool new features for yourself.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F9a9e56%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F9a9e56&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href">https://medium.com/media/78d30e3fd5fc84191dd13999e9cedfc2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebfddfb648ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kadena-io/pact-3-1-is-unleashed-ebfddfb648ce">Pact 3.1 is Unleashed!</a> was originally published in <a href="https://medium.com/kadena-io">Kadena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>