<?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 Ben Chatwin on Medium]]></title>
        <description><![CDATA[Stories by Ben Chatwin on Medium]]></description>
        <link>https://medium.com/@benjamin.g.chatwin?source=rss-2752a09ebd0c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8BOBpA7ZEqIUsgAfaUritg.jpeg</url>
            <title>Stories by Ben Chatwin on Medium</title>
            <link>https://medium.com/@benjamin.g.chatwin?source=rss-2752a09ebd0c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:47:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@benjamin.g.chatwin/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[How to create Native Caradano Tokens using your Daedalus Wallet on Mac]]></title>
            <link>https://medium.com/@benjamin.g.chatwin/how-to-create-native-caradano-tokens-using-your-daedalus-wallet-on-mac-4968f177fefe?source=rss-2752a09ebd0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4968f177fefe</guid>
            <category><![CDATA[cardano]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[tokenization]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Ben Chatwin]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 17:51:42 GMT</pubDate>
            <atom:updated>2021-06-10T17:52:44.760Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lp7T67hiMqtwcXiKDdHiZA.png" /></figure><p>As always the struggle of getting dependencies sorted out when playing around with new software is 90% of the challenge. Luckily, if you are using a Daedalus wallet, all these things are taken care of for you!</p><p><strong>Before we get started</strong></p><ul><li>This guide is for Mac, it may work for windows and it should work for Linux but I cannot say for sure.</li><li>You should have Daedalus installed and the node should be up-to-date.</li><li>You should have a fairly sound knowledge of the command line.</li><li>You will need a handful of ADA, around 5 should be plenty.</li></ul><p>Inspiration drawn from the following sources and in some cases directly copied and expanded for clarification purposes. This community is amazing and people deserve to be recognised:</p><ul><li><a href="https://adamaker.space/using-daedalus-as-a-cardano-node/">adamaker.space tutorial</a></li><li><a href="https://docs.cardano.org/en/latest/native-tokens/getting-started-with-native-tokens.html">docs.cardano.org</a> — always consult the docs!</li></ul><p><strong>Format of tutorial</strong></p><p><strong><em>Some explantion</em></strong></p><pre>code to copy/pasgte</pre><p><strong><em>break</em></strong></p><pre>## Which should produce something that looks like the following: ##</pre><pre>some output that you should expect</pre><p><strong>With that out of the way … let&#39;s go! 🚀</strong></p><p>The first step is to find your ‘Daedalus Mainnet.app’ file in the terminal. Mine was in <strong><em>/Applications</em></strong>. You can simply look in your Applications folder and copy and paste the directory into your terminal.</p><pre>cd /Applications</pre><p>Then change into the ‘Daedalus Mainnet.app’ folder.</p><pre>cd ‘Daedalus Mainnet.app’</pre><p>Then navigate into another two folders.</p><pre>cd Contents/MacOS/</pre><p>For the remainder of the tutorial, I needed to use the root user. This may not be a good idea and you may not want to follow this, but it’s what worked for me.</p><pre>sudo -i</pre><p>You will need to enter your password and now you are running as the root user. This means that you will not have to use ‘sudo’ so frequently. <strong><em>To repeat, this may not be a good idea, run at your own risk.</em></strong></p><pre>ls</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>Daedalus Mainnet  <strong>cardano-node</strong>  libiconv-nocharset.dylib <br>Frontend   cardano-wallet   libiconv.dylib <br>cardano-address   libcharset.1.dylib  libsodium.23.dylib <br>cardano-cli   libffi.7.dylib   libz.dylib   pay_ex.vkey   protocol.json cardano-launcher libgmp.10.dylib</pre><p>You should see a list of available files. These are all the files and folders we will be working with. Now we are going to locate the socket that is running our code:</p><pre>ps -ef | grep cardano-node</pre><p>This will give you a list of currently running programs — We are interested in the section in bold.</p><pre>## Which should produce something that looks like the following: ##</pre><pre>501   580   535   0  7:59AM ??       152:28.00 cardano-node run --socket-path cardano-node.socket --shutdown-ipc 3 --topology /Applications/Daedalus Mainnet.app/Contents/Resources/topology.yaml --database-path chain --port 49234 --config /Applications/Daedalus Mainnet.app/Contents/Resources/config.yaml</pre><pre>501   581   535   0  7:59AM ??        10:10.82 cardano-wallet serve --shutdown-handler --port 49235 --database /Users/lizardswap/Library/Application Support/Daedalus Mainnet/wallets --tls-ca-cert /Users/lizardswap/Library/Application Support/Daedalus Mainnet/tls/server/ca.crt --tls-sv-cert /Users/lizardswap/Library/Application Support/Daedalus Mainnet/tls/server/server.crt --tls-sv-key /Users/lizardswap/Library/Application Support/Daedalus Mainnet/tls/server/server.key --token-metadata-server <a href="https://tokens.cardano.org/">https://tokens.cardano.org</a> --sync-tolerance 300s --mainnet --node-socket <strong>/Users/lizardswap/Library/Application Support/Daedalus Mainnet/cardano-node.socket</strong></pre><pre>0  2375 99681   0 11:49AM ttys001    0:00.00 grep cardano-node</pre><p>To make this very clear:</p><pre><strong>/Users/lizardswap/Library/Application Support/Daedalus Mainnet/cardano-node.socket</strong></pre><p>This is the socket that the Cardano Node is running on. We need to export this as it will be used in the following steps.</p><pre>export CARDANO_NODE_SOCKET_PATH=&quot;<strong>/Users/lizardswap/Library/Application Support/Daedalus Mainnet/cardano-node.socket</strong>&quot;</pre><p>We can check this worked by running:</p><pre>export -p</pre><p>This will give you a list of exports and you should see the command we previously executed in that list. While we are setting things up we can run the following command to ensure we can continue using the <strong>cardano-cli</strong> from other folders if we are moving around.</p><pre>export PATH=$PWD:$PATH</pre><p>To check things are working we can write our first <strong>cardano-cli</strong> command</p><pre>cardano-cli get-tip --mainnet</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>{<br>    &quot;hash&quot;: &quot;38cf45a6402cf263404bb3c4aa59d1dc38395a2b69683f3add6b7026f928513f&quot;,<br>    &quot;block&quot;: 5828142,<br>    &quot;slot&quot;: 31666361<br>}</pre><p>Next, we are going to create a new Cardano verification and signing key:</p><pre>cardano-cli address key-gen \</pre><pre>--verification-key-file pay_ex.vkey \</pre><pre>--signing-key-file pay_ex.skey</pre><p>You can check these files:</p><pre>cat pay_ex.skey</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>{<br>    &quot;type&quot;: &quot;PaymentSigningKeyShelley_ed25519&quot;,<br>    &quot;description&quot;: &quot;Payment Signing Key&quot;,<br>    &quot;cborHex&quot;: &quot;58209ac879df4c7b7ba5daae41cbbbd31d90fe4241fb5e8b4f21b698282b22184302&quot;<br>}</pre><p>Next, we are going to generate a new Cardano payment address:</p><pre>cardano-cli address build \</pre><pre>--payment-verification-key-file pay_ex.vkey \</pre><pre>--out-file pay_ex.addr \</pre><pre>--mainnet</pre><p>Once again you can check your results:</p><pre>cat pay_ex.addr</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk</pre><p>Let’s have a look at our address:</p><pre>cardano-cli query utxo --address addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk --mainnet</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>TxHash                                 TxIx        Amount<br>--------------------------------------------------------------------------------------</pre><p>The address should be empty because it has no ADA/Lovelace. Send some ADA to this address (at least 2 ADA) and take another look at the wallet:</p><pre>cardano-cli query utxo --address addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk --mainnet</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>TxHash                                 TxIx        Amount<br>--------------------------------------------------------------------<br>9c1a6d745986d6d10754e0c7a70c3f942d2964e9d4917dca3c88cabb0d9b9be6     0        2000000 lovelace</pre><p>As you can see the wallet we just created now has 2,000,000 lovelace = 2 ADA. One more step before we can start the miniting process:</p><pre>cardano-cli  query protocol-parameters \<br>--mainnet \<br>--out-file protocol_ex.json</pre><p>And now we can start the minting process, generating a policy folder and some policy keys.</p><pre>mkdir policy_ex</pre><pre>cardano-cli address key-gen <strong>\</strong></pre><pre>--verification-key-file policy_ex/policy_ex.vkey <strong>\</strong></pre><pre>--signing-key-file policy_ex/policy_ex.skey</pre><p>Then we need to update this policy.</p><pre>touch policy_ex/policy_ex.script &amp;&amp; echo &quot;&quot; &gt; policy_ex/policy_ex.script</pre><pre>echo &quot;{&quot; &gt;&gt; policy_ex/policy_ex.script</pre><pre>echo &quot;  \&quot;keyHash\&quot;: \&quot;<strong>$(</strong>./cardano-cli address key-hash --payment-verification-key-file policy_ex/policy_ex.vkey<strong>)</strong>\&quot;,&quot; &gt;&gt; policy_ex/policy_ex.script</pre><pre>echo &quot;  \&quot;type\&quot;: \&quot;sig\&quot;&quot; &gt;&gt; policy_ex/policy_ex.script</pre><pre>echo &quot;}&quot; &gt;&gt; policy_ex/policy_ex.script</pre><p>Let’s have a look at this policy to make sure we are still on track:</p><pre>cat policy_ex/policy_ex.script</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>{<br>  &quot;keyHash&quot;: &quot;cdb501c1b5f3fa3b4c5ba9d9813ea19133a5ee1d2e2912327ee6f200&quot;,<br>  &quot;type&quot;: &quot;sig&quot;<br>}</pre><p>Now we are going to create the asset which will produce a hash for the asset:</p><pre>cardano-cli transaction policyid — script-file ./policy_ex/policy_ex.script</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713</pre><p>Now we are going to start building the transactions. This is where things start to get a little bit messy so take your time with these next steps. Let’s have a quick look at the relevant data points we have (I suggest you organise these in a document):</p><pre><strong>wallet_address</strong>: addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk</pre><pre><strong>lovelace_count</strong>: 2000000</pre><pre><strong>UTXO (the transition we sent to ourselves)</strong>: 9c1a6d745986d6d10754e0c7a70c3f942d2964e9d4917dca3c88cabb0d9b9be6</pre><pre><strong>Policyid</strong>: 52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713</pre><p>We are going to use these to construct a raw transaction. Below is an example without using the actual inputs just so you can understand what inputs go where:</p><pre>cardano-cli transaction build-raw \</pre><pre>--mary-era \</pre><pre>--fee 0 \</pre><pre>--tx-in <strong>UTXO#0</strong> \</pre><pre>--tx-out <strong>wallet_address</strong>+<strong>lovelace_count</strong>+&quot;1000000000     <strong>Policyid</strong>.liztoken&quot; \</pre><pre>--mint=&quot;1000000000 <strong>Policyid</strong>.liztoken&quot; \</pre><pre>--out-file matx.raw</pre><pre>## Take special note of the #0 after the UTXO</pre><p>Now inserting the actual inputs:</p><pre>cardano-cli transaction build-raw \</pre><pre>--mary-era \</pre><pre>--fee 0 \</pre><pre>--tx-in 9c1a6d745986d6d10754e0c7a70c3f942d2964e9d4917dca3c88cabb0d9b9be6#0 \</pre><pre>--tx-out addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk+2000000+&quot;1000000000     52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713.liztoken&quot; \</pre><pre>--mint=&quot;1000000000 52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713.liztoken&quot; \</pre><pre>--out-file matx.raw</pre><p>We can have a look at this file to check we are on the right track:</p><pre>cat matx.raw</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>{<br>    &quot;type&quot;: &quot;TxBodyMary&quot;,<br>    &quot;description&quot;: &quot;&quot;,<br>    &quot;cborHex&quot;: &quot;82a400818258209c1a6d745986d6d10754e0c7a70c3f942d2964e9d4917dca3c88cabb0d9b9be600018182581d61afa6bb0482c37ead18fa06f256314d6a63570d49097b02d225d04d2f821a001e8480a1581c52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713a1486c697a746f6b656e1a3b9aca00020009a1581c52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713a1486c697a746f6b656e1a3b9aca00f6&quot;<br>}</pre><p>Now we need to calculate the fee:</p><pre>cardano-cli transaction calculate-min-fee \<br>&gt; --tx-body-file matx.raw \<br>&gt; --tx-in-count 1 \<br>&gt; --tx-out-count 1 \<br>&gt; --witness-count 3 \<br>&gt; --protocol-params-file protocol_ex.json</pre><pre>## Which should produce something that looks like the following: ##</pre><pre>186005 Lovelace</pre><p>Now we need to include this in our accounting. Without going into how eUTXOs work, the accounting model is</p><pre><strong>sum of inputs = sum of outputs - transaction fee</strong></pre><p>So in our case:</p><pre>lovelace_in = 2000000<br>transaction cost = 186005<br>lovelace_out = 2000000 - 186005 = 1813995</pre><p>Re-create the raw transaction with these figures:</p><pre>cardano-cli transaction build-raw \</pre><pre>--mary-era \</pre><pre>--fee <strong>186005</strong> \</pre><pre>--tx-in 9c1a6d745986d6d10754e0c7a70c3f942d2964e9d4917dca3c88cabb0d9b9be6#0 \</pre><pre>--tx-out addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk+<strong>1813995</strong>+&quot;1000000000     52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713.liztoken&quot; \</pre><pre>--mint=&quot;1000000000 52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713.liztoken&quot; \</pre><pre>--out-file matx.raw</pre><p>Sign the transaction:</p><pre>cardano-cli transaction sign \</pre><pre>--signing-key-file pay_ex.skey \</pre><pre>--signing-key-file policy_ex/policy_ex.skey \</pre><pre>--script-file policy_ex/policy_ex.script \</pre><pre>--mainnet \</pre><pre>--tx-body-file matx.raw \</pre><pre>--out-file matx.signed</pre><p>The moment of truth! 🤞🏽</p><pre>cardano-cli transaction submit --tx-file  matx.signed --mainnet</pre><pre>## Which should produce something that looks like the following: ##</pre><pre><strong>Transaction successfully submitted.</strong></pre><p>Taking a look at our wallet we should see some extra tokens:</p><pre>cardano-cli query utxo --address addr1vxh6dwcystphatgclgr0y433f44xx4cdfyyhkqkjyhgy6tcd0m6xk --mainnet</pre><pre>TxHash                                  TxIx        Amount<br>--------------------------------------------------------------------------------------<br>6db5c90965d61b8ede1dab66553831b832774068f2020d3c4933fca4c91973e6     0        1813995 lovelace + 1000000000 52cfa814eac1d2f9ce3dd92fa3e9a94b6b87dbc2f5f093a8ccaea713.liztoken</pre><p><strong>Congratulations you have now created your very own Native Cardano tokens!</strong></p><p>If anyone needs any help you can ping me on Twitter <a href="https://twitter.com/Ben_g_chatwin">https://twitter.com/Ben_g_chatwin</a></p><p>If there are mistakes let me know! 😊</p><p><strong><em>I will be creating follow-up tutorials for sending to your own wallet, creating NFTs and even smart contracts! Let me know what you want.</em></strong></p><p><strong><em>Last updated 10th June 2021.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4968f177fefe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A quick node.js and sqlite3 guide]]></title>
            <link>https://medium.com/@benjamin.g.chatwin/a-quick-node-js-and-sqlite3-guide-8ed015b79267?source=rss-2752a09ebd0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ed015b79267</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Ben Chatwin]]></dc:creator>
            <pubDate>Sat, 19 Dec 2020 05:29:40 GMT</pubDate>
            <atom:updated>2020-12-24T07:11:58.505Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to create a basic application with node.js and sqlite3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CZrbYnCqbxUFhVTBX8oPfg.png" /></figure><p>A fast, simple and no-fuss guide to setup a node project with sqlite3. Enjoy 😎 Here is what we will get done:</p><ol><li>Setup a node.js project</li><li>Setup a basic sqlite3 database</li><li>Create a table, insert some data and read that data</li></ol><p>Simple! 🚀</p><h3>What you will need</h3><ol><li>Have installed node.js (<a href="https://nodejs.org/en/">You can do that here</a> ✅)</li><li><strong>Nice to have </strong>written a few lines of javascript before</li><li><strong>Nice to have</strong> used the terminal before</li></ol><h3>Creating a node.js project</h3><p>Create a new project directory and create app.js. Below are the terminal commands but you can just as well create these in VScode or whatever editing software you are using 👍</p><pre>mkdir node_demo<br>cd node_demo<br>touch app.js</pre><p>Next, we are going to initialise our node project and follow the prompts:</p><pre>npm init</pre><pre>package name: (node_demo) <br>version: (1.0.0) <br>description: sqlite3 demo #You don&#39;t have to fill this in 😊<br>entry point: (app.js) <br>test command: <br>git repository: <br>keywords: <br>author: Ben Chatwin<br>license: (ISC)</pre><p>Next, we are going to into sqlite3:</p><pre>npm install sqlite3</pre><p>Now we are ready to code! Here is it all with comments, I will bring down each line below.</p><pre>const sqlite3 = require(‘sqlite3’);<br>let db = new sqlite3.Database(“./demo.db”, (err) =&gt; {<br>  if (err) {<br>    console.log(‘Error when creating the database’, err)<br>    } else {<br>    console.log(‘Database created!’)<br>    createTable()<br>    }<br>  })</pre><pre>const createTable = () =&gt; {<br>  console.log(“create database table contacts”);<br>  db.run(“CREATE TABLE IF NOT EXISTS contacts(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)”);<br>  }</pre><pre>const insertData = () =&gt; {<br>  console.log(“Insert data”)<br>  db.run(‘INSERT INTO contacts (name) VALUES (?)’, [“contact 001”]);<br>  }</pre><pre>insertData()</pre><pre>const readData = () =&gt; {<br>  console.log(“Read data from contacts”);<br>  db.all(“SELECT rowid AS id, name FROM contacts”, function(err,     rows) {<br>  rows.forEach(function(row) {<br>  console.log(row.id + “: “ + row.name);<br>  });<br>});<br>}</pre><pre>readData()</pre><pre>db.close();</pre><h3>The breakdown…</h3><p>Importing packages that you want to work with, in this case, sqlite3 😊</p><pre>const sqlite3 = require(‘sqlite3’);</pre><p>Create a variable that will initiate the connection to our database</p><pre>let db = new sqlite3.Database(“./demo.db”, (err) =&gt; {<br>  if (err) {<br>    console.log(‘Error when creating the database’, err)<br>    } else {<br>    console.log(‘Database created!’)<br>    createTable() # This function is described below<br>    }<br>  })</pre><p>Create a function that creates a table within our database</p><pre>const createTable = () =&gt; {<br>  console.log(“create database table contacts”);<br>  db.run(“CREATE TABLE IF NOT EXISTS contacts(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)”);<br>  }</pre><p>Create a function that inserts data into our database</p><pre>const insertData = () =&gt; {<br>  console.log(“Insert data”)<br>  db.run(‘INSERT INTO contacts (name) VALUES (?)’, [“contact 001”]);<br>  }</pre><p>Create a function that reads data from our database</p><pre>const readData = () =&gt; {<br>  console.log(“Read data from contacts”);<br>  db.all(“SELECT rowid AS id, name FROM contacts”, function(err,     rows) {<br>  rows.forEach(function(row) {<br>  console.log(row.id + “: “ + row.name);<br>  });<br>});<br>}</pre><h3>Key takeaways</h3><ul><li>Programming doesn’t have to be difficult.</li><li>These are the building blocks for exciting business applications</li><li>sqlite3 gets you going fast!</li></ul><p>Stay tuned for more node.js and sqlite3 in the future 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ed015b79267" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>