<?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 superical on Medium]]></title>
        <description><![CDATA[Stories by superical on Medium]]></description>
        <link>https://medium.com/@superical?source=rss-37a95dd3fa03------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_qg92fjCEwF7qzzBd8FR2g.jpeg</url>
            <title>Stories by superical on Medium</title>
            <link>https://medium.com/@superical?source=rss-37a95dd3fa03------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:52:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@superical/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[Foundry code snippets to get started quickly in your Solidity Testing]]></title>
            <link>https://coinsbench.com/foundry-code-snippets-to-get-started-quickly-in-your-solidity-testing-9971c6b521a3?source=rss-37a95dd3fa03------2</link>
            <guid isPermaLink="false">https://medium.com/p/9971c6b521a3</guid>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[foundry]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[superical]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 19:22:01 GMT</pubDate>
            <atom:updated>2024-03-11T15:48:26.044Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zTAZ75RmZTI-FhgK.png" /></figure><p>I’ve spent a considerable amount of time using <a href="https://github.com/NomicFoundation/hardhat">Hardhat</a> for my Solidity smart contract development and it has proven to be a great tool with an amazing set of plugins built for it. Before transitioning to Hardhat, I was using <a href="https://github.com/trufflesuite/truffle">Truffle</a> before it was poised to sunset. Yet some time back, I learnt about another framework called <a href="https://github.com/foundry-rs/foundry">Foundry</a>, which appears to be a promising toolkit tailored for Ethereum smart contract development. That was my third time shifting to a new Solidity toolkit and I know the pain of having to re-learn a new tool just to replicate the tasks I can already perform with a tool I’m familiar with.</p><p>To avoid constantly toggling between the <a href="https://book.getfoundry.sh/">Forge documentation</a> and my code all the time in search of answers, I compiled a list of code snippets back then to achieve some of the common tasks in Foundry. This way, I had a single place to refer to as I familiarised myself with Foundry.</p><p>After getting comfortable with Foundry, I’ve completely forgotten about the snippets I had compiled. Many months later, I found these snippets again when I was clearing my files. Then I thought to myself: why not share them somewhere? Who knows they might be helpful to someone else out there. Of course, this compilation isn’t intended to serve as a complete reference — that’s what the <a href="https://book.getfoundry.sh/">Foundry documentation</a> is for — but rather, it’s meant to fast-track the learning process for anyone (like myself many months back) planning to undertake a similar transition, or maybe just to see how testing in Foundry looks like before considering taking it up.</p><h3>Running a test</h3><p>When we want to run the test against a particular test file, say, test/MyContract.t.sol, we can run forge with this command:</p><pre>forge test --match-path test/MyContract.t.sol -vvv<br><br># Or, to fork a network:<br>forge test --fork-url https://infura.io/... --match-path test/MyContract.t.sol -vvv</pre><p>We can’t use only like in Mocha in Hardhat to run only a specific test, but we can specify the name of the contract and function name to run with forge:</p><pre>forge test --match-path test/MyContract.t.sol -match-contract MyContractTest --match-test testTransferFrom </pre><p>In this case, we are targeting the test testTransferFrom in the contract MyContractTest written in the file test/MyContract.t.sol.</p><h3>Formatting Code Style</h3><p>In Foundry, we can auto-format our code with the following command:</p><pre>forge fmt</pre><p>If we only want to check the code style without updating the files (useful when running as linter in CI), we can use the --check flag:</p><pre>forge fmt --check</pre><p>Personally, I still prefer using Prettier to format my code. But, conveniently, Foundry has a code formatter out of the box!</p><h3>Console.log</h3><p>Similar to Hardhat, we can also console log any values into the terminal output. In the contract, we need to import the console library before we can use it. Just make sure we remember to remove those console.log before we compile and deploy the contracts.</p><pre>import &quot;forge-std/console.sol&quot;;<br><br>console.log(&quot;Counter Value:&quot;, counter);</pre><p>However, we don’t have to import the console library in the Test files because the Forge standard package already imports it:</p><pre>import &quot;forge-std/Test.sol&quot;;<br><br>contract MyTest is Test {<br>  function testSomething() public {<br>    console.log(&quot;Hello!&quot;);<br>  }<br>}</pre><h3>Value of msg.sender</h3><p>At the time when a contract is created in Foundry test, the msg.sender is the address of the test driver contract. For example:</p><pre>contract MyOwnableContract {<br>  address public owner;<br><br>  constructor() {<br>    owner = msg.sender;<br>  }<br>}<br><br>contract MyTest is Test {<br>  MyOwnableContract public contract;<br><br>  function setUp() public {<br>    // msg.sender in MyOwnableContract is MyTest<br>    contract = new MyOwnableContract();<br>  }<br><br>  function testOwner() public {<br>    // This should be true<br>    assertEq(contract.owner(), address(this));<br>  }<br>}</pre><h3>Making a call as an address</h3><p>I like that this is something that can be done more conveniently in Foundry than in Hardhat. If we want to call with a different address, we just have to use vm.prank():</p><pre>function setUp() public {<br>  vm.prank(address(123));<br>  contract = new MyOwnableContract();<br>}<br><br>// Or, if we have multiple calls to be made by an address...<br><br>function setUp() public {<br>  vm.startPrank(address(123));<br><br>  contract = new MyOwnableContract();<br>  contract.setFee(10);<br>  contract.setPool(address(1));<br><br>  vm.stopPrank();<br>}</pre><h3>Testing for Reverts and Errors</h3><p>Let’s say we have the following contract that reverts errors:</p><pre>contract MyErrorContract {<br>  error InvalidCall(uint256 param1, uint256 param2);<br><br>  function erroneousMethod() public {<br>    require(false, &quot;Error occurred&quot;);<br>  }<br><br>  function customErrorMethod() public {<br>    revert InvalidCall(1, 2);<br>  }<br>}</pre><p>And we want to test that the expected errors are being reverted:</p><pre>contract MyTest is Test {<br>  MyErrorContract public contract;<br><br>  function setUp() public {<br>    contract = new MyErrorContract();<br>  }<br><br>  function testFail() public {<br>    contract.erroneousMethod();  // Pass<br>  }<br><br>  function testRequireRevert() public {<br>    vm.expectRevert(bytes(&quot;Error occurred&quot;));<br>    contract.erroneousMethod();<br>  }<br><br>  function testCustomErrorWithoutParams() public {<br>    vm.expectRevert(MyErrorContract.InvalidCall.selector);<br>    contract.customErrorMethod();<br>  }<br><br>  function testCustomErrorWithParams() public {<br>    vm.expectRevert(abi.encodeWithSelector(MyErrorContract.InvalidCall.selector, 1, 2));<br>    contract.customErrorMethod();<br>  }<br>}</pre><h3>Testing for Events Emitted</h3><p>We can also test for the events emitted from the contract. Testing for events emitted in Foundry is slightly more cumbersome compared to Hardhat as we have to remember to specify the position of the data in the event we want to check with vm.expectEmit and then simulate emitting the event with the expected data.</p><pre>contract MyTest is Test {<br>  MyToken public token;<br><br>  // Have to declare event in test so that we can emit the expected event later<br>  event Transfer(address indexed from, address indexed to, uint256 amount);<br><br>  function setUp() public {<br>    token = new MyToken();<br>  }<br><br>  function testEmitEventAllParams() public {<br>    // The first 3 arguments: true if parameter data position in event is indexed<br>    // The last argument: true if we want to check the other non-indexed paramter data<br>    // In this case, the Transfer event only has from and to indexed<br>    vm.expectEmit(true, true, false, true);<br><br>    // Emit the event that we expect to see<br>    emit Transfer(address(this), address(123), 456);<br><br>    // Call the contract to actually emit the Transfer event<br>    token.transfer(address(this), address(123), 456);<br>  }<br><br>  function testEmitEventSomeParams() public {<br>    // In this case, we only want to test the first parameter, so we set the rest to false<br>    vm.expectEmit(true, false, false, false);<br><br>    // Emit the event that we expect to see<br>    emit Transfer(address(this), address(123), 456);<br><br>    // This will still pass because the first parameter address(this) matches correctly<br>    // The other parameters have different values but still pass because they are not checked<br>    token.transfer(address(this), address(222), 333);<br>  }<br>}</pre><h3>Testing with Time</h3><p>We can also control the time progression in our tests:</p><pre>contract MyTest is Test {<br>  MyStakeContract public stakeContract;<br>  uint256 private startTime;<br><br>  function setUp() public {<br>    // Stake contract allows unstaking 21 days later<br>    stakeContract = new MyStakeContract(21 days);<br>    startTime = block.timestamp;<br>  }<br><br>  function testFailUnstakeBeforeFastForwardTime() {<br>    stakeContract.stake(5);<br><br>    stakeContract.unstakeAll();  // Fail as it&#39;s not 21 days yet<br>  }<br><br>  function testUnstakeAfterFastForwardTime() {<br>    stakeContract.stake(5);<br>    // Sets the timestamp to 21 days from startTime <br>    vm.warp(startTime + 21 days);<br><br>    stakeContract.unstakeAll();  // Pass after fast-forward time<br>  }<br><br>  function testAdvanceTime() {<br>    uint256 now = block.timestamp;<br><br>    skip(100);<br>    assertEq(block.timestamp, now + 100);<br><br>    rewind(100);<br>    assertEq(block.timestamp, now + 100 - 10);<br>  }<br><br>  function testSetBlockNumber() {<br>    vm.roll(100);<br>    assertEq(block.number, 100);<br>  }<br>}</pre><h3>Sending Ethers and ERC20 Tokens</h3><pre>function testSendETH() public {<br>  // Sets the balance of address(1) to 100<br>  deal(address(1), 100);<br>  assertEq(address(1).balance, 100);<br><br>  // Sets the balance of address(2) to 100<br>  hoax(address(2), 100);<br>  // And automatically have the caller as address(2) in the next call<br>  (bool ok,) = address(3).call{value: amount}(&quot;&quot;);<br>  assertEq(ok, true);<br>}<br><br>function testSendERC20() public {<br>  IERC20 public WETH = IERC20(0xCA......);<br>  address recipient = address(1);<br><br>  uint256 initSupply = WETH.totalSupply();<br><br>  // mints 1million at 18 decimals WETH to recipient and updates total supply<br>  deal(address(WETH), recipient, 1e6 * 1e18, true);<br>  uint256 recipientBalance = WETH.balanceOf(recipient);<br>  uint256 newSupply = WETH.totalSupply();  <br><br>  assertEq(recipientBalance, 1e6 * 1e18);<br>  assertEq(newSupply, initSupply + 1e6 * 1e18);<br>}</pre><h3>Signatures</h3><p>Using Foundry to test for signature-related operations.</p><pre>function testSignature() public {<br>  uint256 privateKey = 123;<br>  address pubKey = vm.addr(privateKey);<br><br>  bytes32 messageHash = keccak256(&quot;message&quot;);<br>  (bytes32 r, bytes32 s, uint8 v) = vm.sign(privateKey, messageHash);<br>  address signer = ecrecover(messageHash, v, r, s);<br><br>  assertEq(signer, pubKey);<br>}</pre><h3>Smart Contract Deployment</h3><h4>Deploy using Create</h4><p>The easiest way to deploy a smart contract in Foundry is calling the forge create command:</p><pre>forge create --private-key $PRIVATE_KEY -f https://infura.io/... --constructor-args &quot;Wrapped Ether&quot; &quot;WETH&quot;</pre><h4>Deploy using Scripts</h4><p>We can also have more control over how we want to perform our deployment. We can write a Foundry script and make use of the new keyword to deploy a new contract. It’s important to not forget the vm.startBroadcast() before and vm.stopBroadcast() after the lines that should be sent to the blockchain. It also requires a default run() function where we have the actual instructions for our deployment. This is the “main” function in our script.</p><pre>import {Script} from &quot;forge-std/Script.sol&quot;;<br>import &quot;../MyTestContract.sol&quot;;<br><br>contract MyScript is Script {<br>  function run() public returns (MyTestContract) {<br>    // Reads the value of PRIVATE_KEY in .env file<br>    address deployer = vm.envUint(&quot;PRIVATE_KEY&quot;);<br><br>    // Specify that we are deploying as the deployer address<br>    vm.startBroadcast(deployer);<br>    MyTestContract res = new MyTestContract();<br>    // More lines of code for deployment, if any<br>    vm.stopBroadcast();<br><br>    return res;<br>  }<br>}<br></pre><h4>Running the Deployment Script</h4><p>Running the script is simple. We just have to call forge script:</p><pre>forge script script/MyScript.sol:MyScript --f https://infura.io/... --broadcast</pre><p>We must pass along the --broadcast. Otherwise, it will only be a simulation. If we wish to verify the contract as well, we can include --verify together with our Etherscan API key:</p><pre>forge script script/MyScript.sol:MyScript --f https://infura.io/... --broadcast --verify --etherscan-api-key ETHERSCAN_API_KEY</pre><p>This is all that I have compiled!</p><p>I hope these recipes and snippets will save you some time from navigating the Foundry documentation for some of the most common tasks in your smart contract development, especially when starting with Foundry.</p><p>Let me know if you think I should also include any other snippets here!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9971c6b521a3" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/foundry-code-snippets-to-get-started-quickly-in-your-solidity-testing-9971c6b521a3">Foundry code snippets to get started quickly in your Solidity Testing</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I went down the rabbit hole of Purpose Bound Money so you don’t have to]]></title>
            <link>https://medium.com/govtechsingapore/i-went-down-the-rabbit-hole-of-purpose-bound-money-so-you-dont-have-to-39ace24d8597?source=rss-37a95dd3fa03------2</link>
            <guid isPermaLink="false">https://medium.com/p/39ace24d8597</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[cbdc]]></category>
            <dc:creator><![CDATA[superical]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 02:49:11 GMT</pubDate>
            <atom:updated>2024-01-19T00:34:22.717Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a story of my journey exploring and building the Purpose Bound Money (PBM) protocol for <a href="https://www.mas.gov.sg/schemes-and-initiatives/project-orchid">Project Orchid</a>.</p><blockquote>Check out our project’s website at <a href="https://www,pbm.money/">www.pbm.money</a> and GitHub repository at <a href="https://github.com/GovTechSG/cbdc-purpose-bound-money">https://github.com/GovTechSG/cbdc-purpose-bound-money</a>.</blockquote><blockquote>The Project Orchid is a multi-phase project initiated by the Monetary Authority of Singapore (MAS) to explore the design and technical aspects of a retail Central Bank Digital Currency (CBDC) system for Singapore.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-TXgQtm3xTS7AAEG4EBrQ.png" /></figure><h3>Understanding Purpose-Bound Money</h3><p>The <a href="https://www.mas.gov.sg/-/media/mas-media-library/development/fintech/project-orchid/mas-project-orchid-report.pdf">Project Orchid whitepaper</a> provides a pretty interesting introduction to the concept of PBM, though it may also be a bit challenging to grasp on the first read. I find that the key to appreciating PBM lies in understanding the concepts of <em>Programmable Payment</em> and <em>Programmable Money</em>. With Programmable Payment, the rules and logic of a payment reside outside of the medium of exchange, and transfers are often facilitated by a third-party backend implementing the rules. Since the rules are decoupled from the value, they can be applied to different forms of money. Conversely, with Programmable Money, the rules are embedded within the money itself. When programmable money is transferred, its rules and value are transferred together, all without intermediaries. Stablecoins and CBDCs are implementations of programmable money. PBM is a protocol that aims to combine both the concepts of programmable payment and programmable money. PBMs have their logic embedded within themselves moving together as they get transferred without intermediaries, while also allowing the rules to be applied to different underlying digital currencies. I’d recommend anyone interested to take a look at the whitepaper and form their own interpretations.</p><figure><img alt="Possible models of programmable digital currency (Source: Project Orchid whitepaper)" src="https://cdn-images-1.medium.com/max/1024/0*CC2j3jPYrVprJLJV" /><figcaption>Possible models of programmable digital currency (Source: Project Orchid whitepaper)</figcaption></figure><h3>Our Purpose Bound Money</h3><h4>A Brief Background</h4><p>Our project is a collaboration between SkillsFuture Singapore (SSG), United Overseas Bank (UOB) and GovTech (where I’m with) to develop a PBM protocol that wraps Digital Singapore Dollars (DSGD) using ERC-20 standards. In terms of roles, UOB acts as the DSGD issuer, SSG as the spender, an overseas training provider as the recipient, and GovTech as the implementer. The PBM wraps the DSGD issued by UOB and is pegged 1:1 with the DSGD, which can be off-ramped into fiat when redeemed from UOB. When participating citizens use their SSG credits to apply for courses, SSG pays the training providers with the payment conditions embedded in the PBM.</p><p>The PBM’s conditions allow the spender, SSG in this case, to specify a holding period for each payment, during which it’s escrowed before the payee can redeem the money. If the spender believes the service hasn’t been fulfilled, i.e. the participant did not attend the course, they can recall the payment within this period. Likewise, the payee has the option to refund during this time. Once an escrow matures, the PBM is automatically released to the recipient’s wallet. Check out section 7.4 of the Project Orchid whitepaper for more details on our case in the project.</p><h4>The Approach</h4><p>I’m sure there are different approaches to developing the PBM. Considering the requirements, timeline and nature of the pilot, what I’m about to discuss was my approach at the time of implementation. There are 3 main components to the project, namely, smart contracts, PBM portal and wallet.</p><h4>1. Smart Contracts</h4><p>The smart contracts are where we implement the conditions for the payments. Essentially, each PBM (based on the rules in our case) undergoes a lifecycle: from initiation to being escrowed, to ready for withdrawal, and finally to withdrawn, with the possibility of status changes due to recalls or refunds during the escrow period. All the contracts were deployed on Polygon PoS. There are a few parts to the smart contracts:</p><ol><li><strong>PBM Token<br></strong>The PBM is implemented as an ERC-20 token. It wraps another ERC-20 token as its underlying asset. Access controls are implemented to the token to facilitate the participating users’ roles in the pilot. For instance, the PBM token allows a Payer role to recall a payment and a Payee role to refund a payment.</li><li><strong>PBM Vault</strong><br>When the spender specifies a holding period, the PBM will be escrowed into a vault. This vault stores and holds the PBM for a specified period and issues a “receipt“ vPBM to the recipients for withdrawing their PBM later. As an aside, I’ve released the vault contract as a standalone library that can be used in other cases too. You can check it out at<a href="https://github.com/GovTechSG/time-lock-vault"> https://github.com/GovTechSG/time-lock-vault</a>.</li><li><strong>Task Manager</strong><br>This manages the contract automation which integrates with the Gelato network to automatically release the exact amount of PBM in a payment to the recipient’s wallet when an escrow matures. For example, if a payment of 280.95 DSGD is supposed to be escrowed for 14 days, it will stand by to withdraw 280.95 PBM from the vault on day 14 upon maturity and automatically release them to the recipient’s wallet.</li><li><strong>Deployment scripts</strong><br>These are not smart contracts per se, but I wrote a bunch of contract deployment scripts, which later saved me a ton of time and hassle.</li></ol><h4>2. PBM Portal</h4><p>The PBM portal is a Web3 frontend to facilitate payment issuance, recall, and history review for spenders while allowing recipients to check payment statuses and unwrap their PBM into DSGD for off-ramping. The frontend was mainly implemented using React and ethers.js.</p><p>A few aspects of the UX in the design may appear familiar as I incorporated some of the common Web3 design patterns while designing the frontend. For instance, the interface for unwrapping PBM may resemble those seen in DEX swap interfaces. A key challenge I faced was helping both spenders and recipients visualise the statuses of their payments and balances. Recognising that the PBM lifecycle may not be inherently apparent, I had to design a dashboard with a pie chart that shows users’ balance amounts at each stage of the lifecycle for easier tracking and understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lZK5j2gd3co873XO" /><figcaption>Purpose Bound Money Web Portal — Dashboard and PBM Unwrapping</figcaption></figure><p>It was also important to empathise with the users in the pilot as many are not web3 natives and were interacting with the blockchain for the first time. So, it’s understandable that some may feel anxious about making mistakes. Thus, the confirmation prompts are specially designed to clarify the exact actions they’re about to take. I’ve learnt that making the user’s actions explicitly clear to them is quite effective in reducing their anxiety, which often arises from the self-doubt and uncertainty they feel about their intended actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*aly7T1nnbEzPhX_d" /><figcaption>Purpose Bound Money Web Portal — Payment and Confirmation Prompt</figcaption></figure><p>To see more UX screens for the frontend, check out this <a href="https://bit.ly/48aNVPH">link</a> for the deck of UI mockups I’ve designed for the project.</p><p>The PBM portal is simply an interface for the users to interact with more intuitively. All the payments and their rules were transacted and settled entirely on the blockchain without intermediaries.</p><h4>3. Wallet</h4><p>Although our project ultimately settled on using the Metamask wallet, I think we could certainly implement a more friendly solution for the wallet should the project move into a commercial phase. In fact, I had initially built a few prototypes around account abstraction and also wallet connect for the PBM portal. These prototypes were intended to have a friendlier UX that didn’t require users to have a wallet extension (such as Metamask), deal with their private keys or hold crypto for gas fees. They also used the system’s passkey, which reads the user’s fingerprint or face ID, to retrieve the user’s account to send the PBMs. Unfortunately, due to time constraints and added complexity, these prototypes did not make it into the final build of the project. Nevertheless, here’s a glimpse of how connecting an account to the PBM portal without Metamask in one of my early-stage prototypes looked like:</p><figure><img alt="Create and connect account flow in an initial wallet prototype" src="https://cdn-images-1.medium.com/max/800/1*_8y58SmZlldqcDyzDejCeA.gif" /><figcaption>Create and connect account flow using fingerprint in an early-stage wallet prototype</figcaption></figure><h3>Just my imagination…</h3><p>This section mostly reflects my learnings and imagination drawn from the whole process in the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*paOWH7HSK882vrbC.jpeg" /></figure><p>As I was developing the PBM protocol for the project, I began thinking to myself that PBM could potentially be used a little more than it seemed, be it originally intended or not. I’ll elaborate on what I mean. PBM is essentially a wrap token with some rules. For the crypto natives, except for the rules, it’s like your WETH and WBTC. In other words, it is a token that wraps another token for its value. An issuer can issue a digital currency token such as the DSGD backed by fiat reserves. Let’s call this currency token the base token for now. Instead of applying the rules only through the PBM, this base token can afford to have some fundamental logic and rules pertinent to the issuer. The PBM then wraps the base token’s existing rules and adds its own. After this, the PBM can be utilised under the set of combined rules programmed. Now comes the interesting part: <em>what if we could loop this wrapping process?</em> Imagine a PBM token called <em>$XYZ</em> that wraps another PBM which then wraps another PBM which finally wraps a base token. I think you start to see where I’m going. Suddenly, the <em>$XYZ</em> token is now a composite PBM that has a few layers of rules and logic to it. Could this be useful, with <em>$XYZ</em> carrying the composite rules, used across organisations or partnerships between businesses or even integration with existing DeFi protocols?🤔</p><p>I’ve drawn a diagram to illustrate the idea. Note the different shapes used in the diagram to represent the layers of PBM wrapping.</p><figure><img alt="My imagination of PBM (decorating, decorating, decorating…)" src="https://cdn-images-1.medium.com/max/1024/1*zF27itssxPKqffz9cDxFFA.png" /><figcaption>My imagination of a potential PBM protocol (wrap, wrap, wrap…)</figcaption></figure><p>Here, the issuer could be a bank, a private issuer or even a DAO. Each issuer is likely to issue its digital tokens (depicted as <em>DSGDA</em> and <em>DSGDB</em>) with some basic rules. They are going to be the base tokens. Regulators might mandate certain rules and logic for these tokens to qualify as “regulated” for use. For instance, perhaps, every token might need to facilitate user blacklisting for AML compliance. Regulators could incorporate these rules in a PBM (depicted as <em>R-PBM</em> token in the diagram) which issuers can then use to wrap their tokens before distributing them. Once in circulation, users of these PBM tokens could either use them as-is or wrap them with additional layers of PBMs with bespoke conditions. For example, a business with specific payment conditions with other businesses could wrap the <em>R-PBM</em> with another PBM embedded with their conditions (depicted as <em>BizX-R-PBM-DSGDA</em> token). Likewise, a business or public agency with specific standard rules for handling money within their organisations could encode these rules in another PBM (depicted as <em>AgencyZ-R-PBM-DSGDB</em>) and wrap with it. When there is a use case to spend <em>AgencyZ-R-PBM-DSGDB</em> under some conditions, those conditions could be embedded into yet another PBM and further wrapped again. In the diagram, I used an example of learning credits where the conditions of the credits are embedded in <em>LearningCredits-AgencyZ-R-PBM-DSGDB</em>. This could also apply to use cases such as paying for services (depicted as <em>CompK-AgencyZ-R-PBM-DSGDB</em>), welfare payouts, and others. You get the idea. It’s a little bit like Lego for money.</p><p>Of course, this potential use remains in the realm of my imagination since I haven’t had the chance to experiment with it in the project yet. I believe it won’t be without its challenges. The technical design would require careful planning. The first thing that comes to mind is preventing conflicting rules. Still, it will certainly be interesting to see how it might develop.</p><h3>It’s a wrap!</h3><p>I’m thrilled that our recent PBM pilot in Project Orchid concluded successfully on the Polygon PoS mainnet. All monies were SAFU. *<em>phew</em>*😅</p><p>I’m also deeply grateful to all our partners in the project for being such awesome collaborators!</p><p>I see Project Orchid as sort of like design fiction for digital currency in our society. The whitepaper provides several seemingly abstract concepts of PBM and might leave some seeking explicit answers to immediate uses slightly baulked. However, I find the real (and fun) value of this project lies not so much in having an immediate answer but in provoking us to <a href="https://youtu.be/4fro_xPdj5E?si=m-iMZ_PEh19H1T84&amp;t=165">speculate</a> about the use and design of an emerging technology within our society in the possible futures — that might not be too far off considering the developments in this field.🚀</p><p>Share your thoughts in the comments!</p><p>Visit our project’s website at <a href="https://www.pbm.money/">www.pbm.money</a> and GitHub repository at <a href="https://github.com/GovTechSG/cbdc-purpose-bound-money">https://github.com/GovTechSG/cbdc-purpose-bound-money</a>.</p><p><em>Now, clap below for this article to find your purpose.</em>🤪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39ace24d8597" width="1" height="1" alt=""><hr><p><a href="https://medium.com/govtechsingapore/i-went-down-the-rabbit-hole-of-purpose-bound-money-so-you-dont-have-to-39ace24d8597">I went down the rabbit hole of Purpose Bound Money so you don’t have to</a> was originally published in <a href="https://medium.com/govtechsingapore">GovTech Singapore</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>