<?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"><channel><title><![CDATA[BLOG | MAGMA - Get news, a roadmap and timeline from MAGMA!]]></title><description><![CDATA[This is the MAGMA Blog, get news about the MAGMA currency, view roadmaps and timelines.]]></description><link>https://blog.magm.red</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 09:13:46 GMT</lastBuildDate><atom:link href="https://blog.magm.red/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[MAGMA on Algorand Announcement]]></title><description><![CDATA[There are only 103,949,132.625095376 MAGMA on ALGO available untill December 1st, 2028!

On December 1st, 2028 wallet address ND7CPROTTHRTGYCQUYNIKPKKIWXGIEOHTPMRERQN2NIFD7USVKGTYGPJFE will release 660,000,000 MAGMA to the REDEAUX wallet.
Although we...]]></description><link>https://blog.magm.red/magma-on-algorand-announcement</link><guid isPermaLink="true">https://blog.magm.red/magma-on-algorand-announcement</guid><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[MoltenChain]]></category><category><![CDATA[algorand]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[usdc]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 08 Dec 2024 18:57:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1733683909940/ef013686-58fc-4d16-b12f-13e0c7dc0dc3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There are only 103,949,132.625095376 MAGMA on ALGO available untill December 1st, 2028!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733684000522/6b2fccfc-c2b3-4f9b-9ea8-dd665259d9eb.jpeg" alt class="image--center mx-auto" /></p>
<p>On December 1st, 2028 wallet address <strong>ND7CPROTTHRTGYCQUYNIKPKKIWXGIEOHTPMRERQN2NIFD7USVKGTYGPJFE</strong> will release 660,000,000 MAGMA to the <strong>REDEAUX</strong> wallet.</p>
<p>Although we plan to retire MAGMA on ALGO in the first quarter of 2026 for the replacement of MAGMA's native blockchain, MoltenChain.</p>
<p>We will be offering a 1:1 trade from MAGMA on ALGO to MoltenChain where MAGMA is a native coin.</p>
<p>The MAGMA coin will be paired with USDC upon the mainnet launch, as we are working with Circle for the entire onboarding from debit/credit to the MoltenChain ecosystem.</p>
<p>The liquidity for MAGMA coin will be backed by USDC, all Algorand will be swapped to USDC-ALGO to USDC-MC and added to the liquidity pool.</p>
<p>Every purchase of MAGMA with USDC will be placed into a USDC/MAGMA liquidity pool. MAGMA holders will earn rewards for contributing to the liquidity pool.</p>
<p>Token creators will have a default liquidity pool setup for their tokens as ATOKEN/MAGMA LP. Where holders of their tokens can contribute to the LP and earn rewards for contributing to the LP.</p>
<p>Token creators will also have the option to add liquidity to any token on the network, they just need an equal value of both, which raises the TVL, and price of the token.</p>
<p>We are in the final stages of development before launching the public testnet, where we will stress and brutally attack to test it's durability and security.</p>
<p>As it stands, it can handle every attack method known to blockchain infrastructure and every attempt has been blocked, with the IP address resulting in being blacklisted.</p>
<p>We have been utilizing machine learning and we have created a sophisticated security model with an internal AI powered bot that monitors the network in real time.</p>
<p>As we continue to innovate what is stopping you from taking the leap into MAGMA?</p>
]]></content:encoded></item><item><title><![CDATA[MoltenChain Testnet]]></title><description><![CDATA[As we continue the development of MoltenChain, our prototyping phase is complete.
We have succeeded in creating a deployable node developed in Bun, Hono.js, Drizzle, Drizzle ORM, WebSockets, IPFS, using Cloudflare Workers and D1.
The amount of work g...]]></description><link>https://blog.magm.red/moltenchain-testnet</link><guid isPermaLink="true">https://blog.magm.red/moltenchain-testnet</guid><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[development]]></category><category><![CDATA[honojs]]></category><category><![CDATA[Bun]]></category><category><![CDATA[DrizzleORM]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Fri, 13 Sep 2024 17:41:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1726247482525/01be70d6-999a-4073-9029-6dfef1427fb7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As we continue the development of MoltenChain, our prototyping phase is complete.</p>
<p>We have succeeded in creating a deployable node developed in Bun, Hono.js, Drizzle, Drizzle ORM, WebSockets, IPFS, using Cloudflare Workers and D1.</p>
<p>The amount of work going into this has been a huge under taking. We are developing an entire ecosystem, powered by MAGMA.</p>
<p>There are a ton of different modules written in TypeScript. To host a node all you need is a Cloudflare account, or VPS, dedicated server; or self host in on a PC or Raspberry PI 4 or newer.</p>
<p>There will be a large amount of modules to extend the MoltenChain network, with a developer's API.</p>
<ol>
<li><p>The MoltenChain Core - The main node for launching a MC core.</p>
</li>
<li><p>MC-Wallet-Module - The module for the wallet api.</p>
</li>
<li><p>MC-Auth-Module - The module for user auth api.</p>
</li>
<li><p>MC-MAGMA - A module for the 1st layer module for the native coin on MoltenChain, MAGMA.</p>
</li>
<li><p>MC-Sentry-Module - The Security module, uses a custom event listening node to protect the network from botnets, DDoS, and deployment of malicious MCSCs.</p>
</li>
<li><p>MC-Contract-Module - The API for deploying smart contracts to the MoltenChain Network.</p>
</li>
<li><p>MC-DPOS-Module - The API for a delagated proof-of-stake DAO, module.</p>
</li>
<li><p>MC-Messenger-Module - The messenger requires MC-Wallet-Module, sends and receives messages between users.</p>
</li>
<li><p>MC-Web-Module - True realtime Dapps writen in hono.JS, dynamically pushes content in HTML, HTMX, JavaScript and CSS.</p>
</li>
<li><p>MC-StoreAPI-Module - Build custom stores using MoltenChain.</p>
</li>
</ol>
<p>With more under development.</p>
<p>Finally, the new MAGMA website is almost complete, but don't worry the old versions of the MAGMA website is hosted on Wayback Machine.</p>
]]></content:encoded></item><item><title><![CDATA[MoltenChain Bridge Swaps]]></title><description><![CDATA[The bridge swap from external blockchain networks to MAGMA (MoltenChain) is a very simple yet complex implementation. The information on this document is theoretical and may change. 
When a user wants to conduct a bridge swap from another network to ...]]></description><link>https://blog.magm.red/moltenchain-bridge-swaps</link><guid isPermaLink="true">https://blog.magm.red/moltenchain-bridge-swaps</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[swap]]></category><category><![CDATA[bridge]]></category><category><![CDATA[Liquidity pools]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sat, 16 Dec 2023 22:04:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/GnWfl_nnZro/upload/bf0a9a2f01246f64c995ca677d23290e.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The bridge swap from external blockchain networks to MAGMA (MoltenChain) is a very simple yet complex implementation. The information on this document is theoretical and may change. </p>
<p>When a user wants to conduct a bridge swap from another network to MoltenChain a couple of things need to happen. Below is an example of how this will work.</p>
<p>Bob has 1 Bitcoin and wants to get 1 BTC worth in MAGMA, the Volcanic Wallet has a bridge swap built into it's features. </p>
<ol>
<li><p>Bob will have to pay the additional fees associated with the bridge swap for the Bitcoin transaction.</p>
</li>
<li><p>Bob goes to the Volcanic Wallet, and creates a wallet.</p>
</li>
<li><p>Bob selects the SWAP tab, and selects SWAP FROM AN EXTERNAL NETWORK.
Bob selects Bitcoin, then the amount he would like to swap.</p>
</li>
<li><p>The Volcanic Wallet calculates how much MAGMA Bob will receive, and the fees associated with the transaction.</p>
</li>
<li><p>Bob accepts, and gets prompted to send an exact amount of BTC to the Volcanic Wallet’s bridge address.</p>
</li>
<li><p>After 7 confirmations, the Volcanic Wallet will send Bob the amount of MAGMA to his wallet address as given in step 4.</p>
</li>
<li><p>Once the BTC transaction is completed, the Volcanic Wallet will automatically send the BTC to a MAGMA/BTC liquidity pool wallet address. This is where all incoming bridge swapped BTC will go, and where outgoing MAGMA to BTC bridge swaps will get the BTC from.</p>
</li>
</ol>
<p>This will be the same for approximately 40 other cryptocurrencies.</p>
<p>Pre-funded Bridge Swap LP
(LP between bridges)</p>
<p>BTC - $500,000
ETH - $500,000
USDC - $500,000
DOGE - $500,000
MANA - $500,000
EUROC - $500,000
CRO - $500,000
MATIC - $500,000
DOT - $500,000
MATIC - $500,000
ALGO - $500,000
ADA - $500,000
XLM - $500,000
ICP - $500,000
SOL - $500,000
AMP - $500,000
DAI - $500,000
SAND - $500,000
GRT - $500,000
BNB - $500,000
XRP - $500,000
USDT - $500,000
AVAX - $500,000
TRX - $500,000
LINK - $500,000
LTC - $500,000
COSMOS - $500,000
BCH - $500,000
NEAR - $500,000
OP - $500,000
NANO - $500,000
EOS - $500,000
ENJ - $500,000
IOTA - $500,000
XTZ - $500,000
EGLD - $500,000
ZIL - $500,000
COMP - $500,000
WAVES - $500,000
MOVR - $500,000</p>
<p>A total of $20,000,000 in liquidity for bridge swaps, this will not be launched at all at once. We will release a batch of new bridge swap origins and destinations every 3 months.</p>
<p>The primary LP for MAGMA will be setup with USDC from Circle, we are working with Circle to release a USDC token on MoltenChain, USDC-MC or mcUSDC.</p>
<p>In addition we are working on a solution for the future to allow fiat purchases of MAGMA.</p>
<p>MoltenChain is truly going to provide nextgen features and stability never seen before. </p>
<p>Our Volcanic Wallet is truly a nextgen wallet. </p>
<p>As the development continues we are constantly thinking outside of the box, bringing new ideas, features, and experiences in a single package.</p>
]]></content:encoded></item><item><title><![CDATA[MoltenChain's Source Code Rewrite for Improved Security and Scalability]]></title><description><![CDATA[The MoltenChain team is currently in the process of re-writing the source code to incorporate some incredible improvements. We are fully dedicated to enhancing security, scalability, and performance while also speeding up smart contract deployment ti...]]></description><link>https://blog.magm.red/moltenchains-source-code-rewrite-for-improved-security-and-scalability</link><guid isPermaLink="true">https://blog.magm.red/moltenchains-source-code-rewrite-for-improved-security-and-scalability</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[The Verse]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:50:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1680551105422/282465fa-0e8f-4acf-aade-a88390d129d7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The MoltenChain team is currently in the process of re-writing the source code to incorporate some incredible improvements. We are fully dedicated to enhancing security, scalability, and performance while also speeding up smart contract deployment times.</p>
<p>Our security AI engine is undergoing a major code optimization and receiving a performance boost. We've trained it on a massive dataset of almost 16k exploits, double spending attempts, XSS, and payload attempts. This means that just like your virus detection and security software, MoltenChain scans transaction notes, messages, smart contracts, and dapps for potential issues and blocks them from ever being pushed through the network.</p>
<p>We also take node security very seriously. If a node reports a mis-matched code base, the network will lock it out, preventing it from validating, earning rewards, deploying smart contracts, or deploying dapps.</p>
<p>But that's not all - we're also focused on improving scalability. By increasing the speed of security checks, transactions and deployments will be even faster. Additionally, our code has been thoroughly optimized, resulting in quicker ping times, overall lower latency, and a 13% reduction in code with the re-write, making the package lighter than ever before.</p>
<p>Here at MoltenChain, we're driven to innovate and bring the most high-tech blockchain network to the world. By doing so, we're opening up new opportunities for independent musicians, writers, content creators, game devs, and artists. We are Redeaux Games and we can't wait to see what the future holds.</p>
]]></content:encoded></item><item><title><![CDATA[About MNFTs]]></title><description><![CDATA[MNFT (Molten Non-Fungible Tokens) is a unique standard developed by MoltenChain that allows developers to create and manage non-fungible tokens (NFTs) on the blockchain. These tokens are unique digital assets that can be used in a variety of applicat...]]></description><link>https://blog.magm.red/about-mnfts</link><guid isPermaLink="true">https://blog.magm.red/about-mnfts</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[mnft]]></category><category><![CDATA[NFT]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[MAGMA]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 26 Feb 2023 09:26:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677403377308/8ed06bdd-74f3-4d5d-92e0-20eecdd3c994.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>MNFT (Molten Non-Fungible Tokens) is a unique standard developed by MoltenChain that allows developers to create and manage non-fungible tokens (NFTs) on the blockchain. These tokens are unique digital assets that can be used in a variety of applications, including digital art, gaming, collectibles, and more.</p>
<p>One of the key features of MNFT is the ability to create gig jobs and subscription-based NFTs. This means that creators can offer their services on a per-job basis or offer recurring NFTs that provide access to exclusive content or services. This opens up new opportunities for creators to monetize their skills and content in a unique and decentralized way.</p>
<p>Another powerful feature of MNFT is the ability to create reoccurring NFTs. This allows creators to offer ongoing access to their content or services, creating a sustainable revenue stream for themselves. This is especially useful for creators who offer subscription-based content or services, as it eliminates the need for centralized payment processors and allows them to directly receive payments from their subscribers.</p>
<p>MNFT also supports the creation of different types of NFTs, including wrapped NFTs, which represent assets on other blockchain networks, and hybrid NFTs, which combine multiple NFT standards into a single token. This provides even greater flexibility for developers and creators to build unique and innovative applications on the blockchain.</p>
<p>The MoltenChain platform provides a range of tools and resources to support the development and management of MNFTs. This includes the ability to create and deploy smart contracts, as well as access to MoltenChain's robust API for seamless integration with external systems and applications.</p>
<p>Overall, MNFT is a powerful and versatile standard that opens up new possibilities for creators and developers in the world of decentralized applications. With features such as gig jobs, subscription-based NFTs, and reoccurring NFTs, MNFT provides a unique way for creators to monetize their skills and content while providing a sustainable revenue stream. The possibilities for MNFT are endless, and we can't wait to see what the future holds for this exciting standard.</p>
]]></content:encoded></item><item><title><![CDATA[MoltenChain HLMs.]]></title><description><![CDATA[MoltenChain's hot loadable modules are a game-changer for blockchain development. With the ability to dynamically load and unload modules on a running MoltenChain node, developers can quickly and easily add new functionality to their decentralized ap...]]></description><link>https://blog.magm.red/moltenchain-hlms</link><guid isPermaLink="true">https://blog.magm.red/moltenchain-hlms</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[HLM]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 26 Feb 2023 03:22:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677381578496/9727c9b1-9aa3-4ac8-b7ac-9e4ed446df48.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>MoltenChain's hot loadable modules are a game-changer for blockchain development. With the ability to dynamically load and unload modules on a running MoltenChain node, developers can quickly and easily add new functionality to their decentralized applications (dapps) without having to restart the entire node.</p>
<p>Hot loadable modules offer a number of benefits for developers. First, they enable rapid development and deployment of new features, allowing dapps to keep up with changing market demands and user needs. Second, they make it easy to experiment with new features and ideas, without the risk of disrupting the entire network.</p>
<p>MoltenChain's hot loadable modules also provide a high level of flexibility and customization. Developers can choose to use pre-built modules, or they can build their own custom modules to meet their specific requirements. This allows for a highly modular and extensible development approach that can adapt to a wide range of use cases.</p>
<p>Overall, MoltenChain's hot loadable modules are a powerful tool for blockchain developers looking to build scalable and flexible dapps. With their ability to dynamically load and unload modules, developers can experiment with new features, add new functionality to their dapps, and keep up with changing market demands.</p>
]]></content:encoded></item><item><title><![CDATA[What is MoltenChain?]]></title><description><![CDATA[MoltenChain is a next-generation blockchain platform that offers developers and businesses the tools they need to build scalable, high-performance decentralized applications (dapps). Built on top of a consensus algorithm, MoltenChain provides a fast ...]]></description><link>https://blog.magm.red/what-is-moltenchain-1</link><guid isPermaLink="true">https://blog.magm.red/what-is-moltenchain-1</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[dapps]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 26 Feb 2023 01:56:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677376244772/7e8b7252-557a-494b-b283-8aae5ef8166f.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>MoltenChain is a next-generation blockchain platform that offers developers and businesses the tools they need to build scalable, high-performance decentralized applications (dapps). Built on top of a consensus algorithm, MoltenChain provides a fast and secure way to validate transactions on the network, enabling fast transaction processing times and a high level of security.</p>
<p>In addition to its core blockchain features, MoltenChain offers a range of modules that enable developers to build a wide range of dapps. These modules include a messaging module that uses Socket.io for real-time communication, a liquidity pool module that enables the creation of liquidity pools for different tokens, and a voting module that allows users to participate in decentralized voting.</p>
<p>MoltenChain also supports the development of smart contracts using the Lua programming language. Smart contracts can be used for a variety of use cases, including decentralized exchanges, prediction markets, supply chain management, identity verification, and more.</p>
<p>One of the key features of MoltenChain is its bridge swapping functionality, which enables tokens to be exchanged between different blockchain networks. This makes it easy for developers and businesses to integrate with other blockchain networks and build interoperable decentralized applications.</p>
<p>MoltenChain also supports the creation of fungible tokens, wrapped tokens, and non-fungible tokens (NFTs). Fungible tokens are digital assets that are interchangeable and have the same value, while NFTs are unique digital assets that cannot be replicated. Wrapped tokens are tokens that represent assets on other blockchain networks and can be exchanged for the underlying asset.</p>
<p>To ensure accurate pricing for tokens, MoltenChain also provides an oracle module that sources price data from external sources and makes it available on the network. This enables developers to build decentralized applications that require real-time pricing data.</p>
<p>Scalability and performance are key priorities for MoltenChain, and the platform has been designed to support high transaction volumes and low latency. To achieve this, MoltenChain uses a high-performance tech stack that includes Node.js, TypeScript, and Lua.</p>
<p>MoltenChain also features a robust API that provides easy integration with external services and applications. This enables developers to build dapps that can communicate with external systems and provide a seamless user experience.</p>
<p>Another feature of MoltenChain is its MNFT (Molten Non-Fungible Token) standard, which enables the creation of unique digital assets that can be used in a wide range of applications. MNFTs can be used for digital art, gaming, collectibles, and more.</p>
<p>Finally, MoltenChain provides a user-friendly wallet application called Volcanic Wallet, which makes it easy for users to store and manage their digital assets. The wallet supports a range of cryptocurrencies and tokens, and includes features such as transaction history, balance tracking, and more.</p>
<p>In summary, MoltenChain is a powerful and versatile blockchain platform that provides developers and businesses with the tools they need to build innovative and scalable decentralized applications. With its fast and secure consensus mechanism, support for smart contracts and multiple types of tokens, bridge swapping functionality, oracle module, and MNFT standard, MoltenChain is poised to make a significant impact on the blockchain industry. The user-friendly Volcanic Wallet and robust API also make it easy for developers and users to engage with the platform and build exciting new applications.</p>
]]></content:encoded></item><item><title><![CDATA[An overview of MoltenChain?]]></title><description><![CDATA[MoltenChain Proof-of-Stake(PoS) blockchain for the native MAGMA cryptocurrency. The MoltenChain source code is purely written in TypeScript. With extendability using smart contract written in Lua.
MoltenChain's Features
We have written in many functi...]]></description><link>https://blog.magm.red/an-overview-of-moltenchain</link><guid isPermaLink="true">https://blog.magm.red/an-overview-of-moltenchain</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Testnet]]></category><category><![CDATA[dapps]]></category><category><![CDATA[Lua]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 26 Feb 2023 01:26:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671786942303/767b769f-02ca-403f-8e14-2ac98fe74cd8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>MoltenChain Proof-of-Stake(PoS) blockchain for the native MAGMA cryptocurrency. The MoltenChain source code is purely written in TypeScript. With extendability using smart contract written in Lua.</p>
<h3 id="heading-moltenchains-features">MoltenChain's Features</h3>
<p>We have written in many functions into the core base of MoltenChain's source code.</p>
<p>Here is a list of MoltenChain's built in features.</p>
<ol>
<li><p>5 second transaction time.</p>
</li>
<li><p>Quick fetch for bringing new nodes online quickly.</p>
</li>
<li><p>Mint and deployment of FTs, and NFTs.</p>
</li>
<li><p>Wallet functionality with atomic swapping.</p>
</li>
<li><p>Local and remote JSON as a DB function.</p>
</li>
<li><p>A smart contract mechanism for Lua scripting language.</p>
</li>
<li><p>Full compatibility with IPFS, webtorrent and H5P.</p>
</li>
<li><p>Light weight source code with quick deployment for easier to manage nodes and quick start for devs.</p>
</li>
<li><p>A built in Liquidity function.</p>
</li>
<li><p>Built in locking function for liquidity and tokens.</p>
</li>
<li><p>Custom address system with namespace style wallet addresses, example: lolcatz.magma or yourname.magma</p>
</li>
<li><p>Simple to use and easy to understand dev api.</p>
</li>
</ol>
<h3 id="heading-when-does-moltenchain-launch">When does MoltenChain launch?</h3>
<p>Although there is not a launch date set in stone, right now the current projections are MoltenChain testnet will launch around July 2023.</p>
<p>With a potential for a mainnet coin pre-sale launch around October 2023.</p>
<h3 id="heading-how-secure-will-moltenchain-be-overall">How secure will MoltenChain be overall?</h3>
<p>TypeScript uses the TypeScript compiler (tsc), which checks for errors and compiles TypeScript into JavaScript. Certain compiler options increase security, such as strict and noEmitOnError.</p>
<p>The former increases security by turning on a series of flags to force TypeScript to run in a stricter mode. For example, it turns on things such as noImplicitAny, strictNullChecks, and noImplicitThis, all of which protect your application from including unsafe constructs.</p>
<p>In addition, the option noEmitOnError prevents the tsc from creating the corresponding JavaScript file if there is an error within the code, increasing security by preventing errors from being compiled into JavaScript code.</p>
<p>While more code is written, you are generating more code to increase security. The extra code defines types and adds type checks and validation functions. Types define what input is allowed into an object; not having types can cause errors and potential security weaknesses. In TypeScript, the types are strings, numbers, and interfaces, which can help define the syntax of future type checks and input validation.</p>
<p>Writing extra code upfront to define types and ensure type safety can help save time by preventing developers from having to fix type errors later.  </p>
<p>Fixing type errors in languages without static, strict types is difficult - you have to figure out where in the code the error is generating from, how to fix it, and determine if any other errors resulted from the fix, all without the help of the IDE or the language itself. While in a strict static typed language, it will prevent these issues entirely and report any additional errors during compilation.</p>
<p>Dynamic Typing is a security problem, because it only checks types at runtime. Therefore, any security issues are caught while the application is running and not while it is under development.</p>
<p><strong>Static typing checks types at compile-time, which prevents type issues before they become vulnerabilities.</strong></p>
<p>When you are trying to remediate the source of an error or weakness, it takes longer to edit code in dynamic typing than in static typing.</p>
<p>This is due to the expressive errors and compile-time type checks native to static typing. More expressive errors give more information about where the code's errors lie, such as the file and line number.</p>
<p>Checking types at compile time means that errors are found closer to the source, making it easier to return and fix than if the error was found during runtime. </p>
<p>TypeScript Security Win: TypeScript provides static typing, which checks types at compile-time, preventing issues before they become vulnerabilities, and giving more expressive errors to aid in the identification and resolution of errors.</p>
<h4 id="heading-typescript-security-win-typescript-uses-strict-typing-preventing-accidental-typing-mistakes-that-lead-to-common-weaknesses-within-an-application"><strong>TypeScript Security Win:</strong> TypeScript uses strict typing, preventing accidental typing mistakes that lead to common weaknesses within an application.</h4>
]]></content:encoded></item><item><title><![CDATA[Partial Roll Out Of Magma-bot  Features]]></title><description><![CDATA[We got some exciting new features and games coming the MAGMA BOT!
These new games use the new version of SULFUR, the MAGMA Discord server's virtual cash!
Truth Or Dare 🔪 is a new CMDR hosted game taking place after Texas Hold Em Poker on Thurdays!
I...]]></description><link>https://blog.magm.red/partial-roll-out-of-magma-bot-features</link><guid isPermaLink="true">https://blog.magm.red/partial-roll-out-of-magma-bot-features</guid><category><![CDATA[SULFUR]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[discord]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 08 Jan 2023 07:11:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1673162457210/4a130cbb-c56a-45a7-a43a-7547e99c1361.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We got some exciting new features and games coming the MAGMA BOT!</p>
<p>These new games use the new version of SULFUR, the MAGMA Discord server's virtual cash!</p>
<p>Truth Or Dare 🔪 is a new CMDR hosted game taking place after Texas Hold Em Poker on Thurdays!</p>
<p>It will use the SULFUR v2 that ships with MAGMA BOT.</p>
<p>This version of SULFUR will only be able to be won and earned currently. We are not swapping this version with MAGMA.</p>
<p>There will be a full update on this in the near future.</p>
]]></content:encoded></item><item><title><![CDATA[MoltenChain Sub-Chain Support]]></title><description><![CDATA[SUB-CHAINS FOR TOKENS
On MoltenChain as well as minting tokens, the token creators can also deploy a smart contract to set up a side-chain for the token. With side-chains token creators can provide an independent ledger named after the token id.
Exam...]]></description><link>https://blog.magm.red/moltenchain-sub-chain-support</link><guid isPermaLink="true">https://blog.magm.red/moltenchain-sub-chain-support</guid><category><![CDATA[side-chain]]></category><category><![CDATA[MoltenChain]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[MAGMA]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Thu, 29 Dec 2022 12:52:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672317640300/6d9a8c41-94f4-4253-989c-b6f985fb776f.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-sub-chains-for-tokens">SUB-CHAINS FOR TOKENS</h3>
<p>On MoltenChain as well as minting tokens, the token creators can also deploy a smart contract to set up a side-chain for the token. With side-chains token creators can provide an independent ledger named after the token id.</p>
<p>Example: Bob creates Bobcoin with the ticker as BOBS, when Bob deploys the smart contract for the side-chain it will be named BOBS Chain. All swaps, exchanges, token lock-ups, LP buys or sells will be listed in the BOBS Chain ledger.</p>
<p>To learn more head over to <a target="_blank" href="https://moltencha.in">MoltenCha.in</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Self Destructing Private Messages]]></title><description><![CDATA[MoltenChain has included a private messaging module. Allowing private messages to be sent between users of the MoltenChain network via VolcanicWallet.
With the private messages module, smart contracts can be deployed to make these private messages se...]]></description><link>https://blog.magm.red/self-destructing-private-messages</link><guid isPermaLink="true">https://blog.magm.red/self-destructing-private-messages</guid><category><![CDATA[private messages]]></category><category><![CDATA[Self Destruct ]]></category><category><![CDATA[MoltenChain]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[Smart Contracts]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Wed, 28 Dec 2022 20:24:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672258309966/a125cd98-cc32-40ec-a5a8-a53acc30c225.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>MoltenChain has included a private messaging module. Allowing private messages to be sent between users of the MoltenChain network via VolcanicWallet.</p>
<p><strong>With the private messages module, smart contracts can be deployed to make these private messages self destruct.</strong></p>
<ol>
<li><p>Message will self destruct if not opened within a specified amount of time.</p>
</li>
<li><p>Message will self destruct after message has been opened.</p>
</li>
<li><p>Message will self destruct after a payment is received.</p>
</li>
<li><p>Message will self destruct after a payment is sent.</p>
</li>
</ol>
<p><em>We are writing a section into the Volcanic Wallet UI. The smart contracts are written and currently being tested in a private testnet setting.</em></p>
<p>To check out the smart contracts please go to our <a target="_blank" href="https://github.com/Redeaux-Games/MoltenChain">Github</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Native MAGMA Liquidity]]></title><description><![CDATA[As we re-invent the wheel on MAGMA, and plan on launching MoltenChain we are creating creative ways to create liquidity for swapping pairs.
Initial LP Options

When we launch MoltenChain and MAGMA to mainnet we will create liquidity pools with the fo...]]></description><link>https://blog.magm.red/native-magma-liquidity</link><guid isPermaLink="true">https://blog.magm.red/native-magma-liquidity</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[Liquidity]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[usdc]]></category><category><![CDATA[algorand]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Wed, 28 Dec 2022 07:06:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/ae0eed571305a87ab47877d2842a4398.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>As we re-invent the wheel on MAGMA, and plan on launching MoltenChain we are creating creative ways to create liquidity for swapping pairs.</em></p>
<h3 id="heading-initial-lp-options">Initial LP Options</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1672208225255/a4846433-fa01-4210-816a-ba8c1fda33a3.webp" alt class="image--center mx-auto" /></p>
<p><strong>When we launch MoltenChain and MAGMA to mainnet we will create liquidity pools with the following pairs:</strong></p>
<ol>
<li><p>USD/USDC to MAGMA | We will keep USD in a US bank account with the matched amount in USDC. On MoltenChain we will deploy a smart contract, and oracle to power the bridge and liquidity pool.</p>
</li>
<li><p>ALGO to MAGMA | We will keep ALGO in a wallet, matched to the amount of MAGMA to create a liquidity pool with Algorand and MAGMA, on MoltenChain we will deploy a smart contract, and oracle to power the bridge and liquidity pool.</p>
</li>
<li><p>ADA to MAGMA | We will keep ADA in a wallet, matched to the amount of MAGMA to create a liquidity pool with Cardano and MAGMA, on MoltenChain we will deploy a smart contract, and oracle to power the bridge and liquidity pool.</p>
</li>
<li><p>BTC to MAGMA | We will keep BTC in a wallet, matched to the amount of MAGMA to create a liquidity pool with Bitcoin and MAGMA, on MoltenChain we will deploy a smart contract, and oracle to power the bridge and liquidity pool.</p>
</li>
<li><p>ETH to MAGMA | We will keep ETH in a wallet, matched to the amount of MAGMA to create a liquidity pool with Ethereum and MAGMA, on MoltenChain we will deploy a smart contract, and oracle to power the bridge and liquidity pool.</p>
</li>
</ol>
<p><strong>As time goes on we will expand the pairs offered including MAGMA Stables a tethered token powered by Oracles and a swapping bridge. MAGMA Stables will be available on the following networks:</strong></p>
<ol>
<li><p>MAGMA-ALGO | A MAGMA stable token on the Algorand network.</p>
</li>
<li><p>MAGMA-ETH | A MAGMA stable token on the Ethereum network.</p>
</li>
<li><p>MAGMA-ADA | A MAGMA stable token on the Cardano network.</p>
</li>
<li><p>MAGMA-LINK | A MAGMA stable token on the ChainLink network.</p>
</li>
<li><p>MAGMA-DC | A MAGMA stable token on the DogeChain network.</p>
</li>
<li><p>MAGMA-ICP | A MAGMA stable token on Internet Computer network.</p>
</li>
<li><p>MAGMA-IOTA | A MAGMA stable token on the IOTA network.</p>
</li>
<li><p>MAGMA-ATOM | A MAGMA stable token on the Cosmos network.</p>
</li>
<li><p>MAGMA-BNB | A MAGMA stable token on the Binance network.</p>
</li>
<li><p>MAGMA-NEAR | A MAGMA stable token on the NEAR network.</p>
</li>
<li><p>MAGMA-ZIL | A MAGMA stable token on the Zilliqa network.</p>
</li>
<li><p>MAGMA-MATIC | A MAGMA stable token on the Polygon network.</p>
</li>
<li><p>MAGMA-TRX | A MAGMA stable token on the Tron network.</p>
</li>
<li><p>MAGMA-DOT | A MAGMA stable token on the Polkadot network.</p>
</li>
<li><p>MAGMA-XLM | A MAGMA stable token on the Stellar network.</p>
</li>
<li><p>MAGMA-PLS | A MAGMA stable token on the PulseChain network.</p>
</li>
<li><p>MAGMA-HECO | A MAGMA stable token on the HECO network.</p>
</li>
<li><p>MAGMA-VLX | A MAGMA stable token on the Velas network.</p>
</li>
<li><p>MAGMA-FTM | A MAGMA stable token on the Fantom network.</p>
</li>
<li><p>MAGMA-SOL | A MAGMA stable token on the Solana network.</p>
</li>
</ol>
<p><strong>Since the native MAGMA on MoltenChain will have so many stable tokens we will need to make these tokens interchangeable, to do that we will need a liquidity pool for each pair. This is why the native MAGMA will have a total supply of 16,317,000,000 MAGMA.</strong></p>
<p><em>The amount of MAGMA for each pair is 777,000,000 MAGMA and since there is a total of 21 networks, 777000000x21=16317000000.</em></p>
<p><em>The initial value of MAGMA on MoltenChain will be 0.0000007000, which is valued at $543.90 per network. With the addition of Bitcoin, Litecoin and Dogecoin.</em></p>
<p><strong>Each MAGMA stable token will require $543.90 in liquidity with their network's parent coin, for example:</strong></p>
<p>MAGMA-ALGO will require liquidity on the Algorand side with $543.90 of ALGO matched with MAGMA-ALGO, but on the MoltenChain side, we will require liquidity of 777,000,000 MAGMA to MAGMA-ALGO.</p>
<p><em>By the time we are finished, we should have a total of 50 liquidity pools with $543.90 of liquidity for each one, totaling $27,195 at $0.0000007000 per MAGMA.</em></p>
<p>We are in talks with Circle in joining them as a possible partner, in the future to handle our FIAT to MAGMA process. Circle transaction fees will be passed on to the buyer, so we can ensure the presence of liquidity.</p>
]]></content:encoded></item><item><title><![CDATA[Token Lock Smart Contract for MoltenChain]]></title><description><![CDATA[-- Smart contract for token locking mechanism on the MAGMA cryptocurrency on the MoltenChain blockchain
-- Define variables local
tokensLocked = 0 -- Number of tokens currently locked local
lockDuration = 86400 -- Duration of lock in seconds (86400 s...]]></description><link>https://blog.magm.red/smart-contracts-for-moltenchain</link><guid isPermaLink="true">https://blog.magm.red/smart-contracts-for-moltenchain</guid><category><![CDATA[SmartContracts]]></category><category><![CDATA[MoltenChain]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[development]]></category><category><![CDATA[Lua]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Thu, 22 Dec 2022 02:32:58 GMT</pubDate><content:encoded><![CDATA[<blockquote>
<p><code>-- Smart contract for token locking mechanism on the MAGMA cryptocurrency on the MoltenChain blockchain</code></p>
<p><code>-- Define variables local</code></p>
<p><code>tokensLocked = 0 -- Number of tokens currently locked local</code></p>
<p><code>lockDuration = 86400 -- Duration of lock in seconds (86400 seconds = 1 day)</code></p>
<p><code>local lockStartTime = 0 -- Timestamp of when the lock began</code></p>
<p><code>-- Function to lock tokens</code></p>
<p><code>function lockTokens(numTokens: number) if numTokens &lt; 0 then error("Number of tokens to lock must be a positive integer") end tokensLocked = tokensLocked + numTokens lockStartTime = os.time() end</code></p>
<p><code>-- Function to unlock tokens</code></p>
<p><code>function unlockTokens(numTokens: number) if numTokens &lt; 0 then error("Number of tokens to unlock must be a positive integer") end if numTokens &gt; tokensLocked then error("Cannot unlock more tokens than are currently locked") end if os.time() &lt; lockStartTime + lockDuration then error("Tokens cannot be unlocked until the lock duration has expired") end tokensLocked = tokensLocked - numTokens end</code></p>
<p><code>-- Function to check current number of locked tokens</code></p>
<p><code>function getLockedTokens() return tokensLocked end</code></p>
<p><code>-- Function to check lock duration</code></p>
<p><code>function getLockDuration() return lockDuration end</code></p>
<p><code>-- Function to check lock start time</code></p>
<p><code>function getLockStartTime() return lockStartTime end</code></p>
</blockquote>
<h3 id="heading-token-swap-smart-contract-for-moltenchain">Token Swap Smart Contract for MoltenChain</h3>
<blockquote>
<p><code>--Smart contract for token swapping on the MAGMA cryptocurrency on the MoltenChain blockchain</code></p>
<p><code>-- Define variables</code></p>
<p><code>local tokens = {} -- Table to store the tokens being swapped</code></p>
<p><code>local amounts = {} -- Table to store the amounts of each token being swapped</code></p>
<p><code>local ownerAddresses = {} -- Table to store the addresses of the owners of each token</code></p>
<p><code>local swapComplete = false -- Flag to indicate whether the swap is complete</code></p>
<p><code>-- Function to add a token to the swap</code></p>
<p><code>function addToken(token: string, amount: number, ownerAddress: string) if swapComplete then error("Swap has already been completed and no more tokens can be added") end if amount &lt; 0 then error("Amount of token must be a positive integer") end if tokens[token] then error("Token has already been added to the swap") end tokens[token] = token amounts[token] = amount ownerAddresses[token] = ownerAddress end</code></p>
<p><code>-- Function to execute the swap</code></p>
<p><code>function executeSwap() if not swapComplete then for token, ownerAddress in pairs(ownerAddresses) do transfer(token, ownerAddresses[token], amounts[token]) end swapComplete = true end end</code></p>
<p><code>-- Function to check whether the swap is complete</code></p>
<p><code>function isSwapComplete() return swapComplete end</code></p>
<p><code>-- Function to check the tokens and amounts in the swap</code></p>
<p><code>function getSwapDetails() return tokens, amounts end</code></p>
</blockquote>
<h3 id="heading-create-liquidity-pool-smart-contract">Create Liquidity Pool Smart Contract</h3>
<blockquote>
<p>-- Smart contract for a liquidity pool on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local pool = {} -- Table to store the tokens in the pool</p>
<p>local amounts = {} -- Table to store the amounts of each token in the pool</p>
<p>local owners = {} -- Table to store the addresses of the owners of each token in the pool</p>
<p>-- Function to add liquidity to the pool</p>
<p>function addLiquidity(token: string, amount: number, ownerAddress: string) if amount &lt; 0 then error("Amount of token must be a positive integer") end if not pool[token] then pool[token] = token amounts[token] = amount owners[token] = ownerAddress else amounts[token] = amounts[token] + amount end end</p>
<p>-- Function to remove liquidity from the pool</p>
<p>function removeLiquidity(token: string, amount: number, ownerAddress: string) if amount &lt; 0 then error("Amount of token must be a positive integer") end if not pool[token] then error("Token is not in the pool") end if owners[token] ~= ownerAddress then error("Only the owner of the token can remove liquidity") end if amount &gt; amounts[token] then error("Cannot remove more liquidity than is currently in the pool") end amounts[token] = amounts[token] - amount end</p>
<p>-- Function to check the current liquidity in the pool</p>
<p>function getLiquidity() return pool, amounts end</p>
</blockquote>
<h3 id="heading-locking-lp-smart-contract">Locking LP Smart Contract</h3>
<blockquote>
<p>-- Smart contract for a liquidity pool with locking on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local pool = {}</p>
<p>-- Table to store the tokens in the pool</p>
<p>local amounts = {}</p>
<p>-- Table to store the amounts of each token in the pool</p>
<p>local owners = {}</p>
<p>-- Table to store the addresses of the owners of each token in the pool</p>
<p>local lockDuration = 86400 -- Duration of lock in seconds (86400 seconds = 1 day) local lockStartTime = 0 -- Timestamp of when the lock began</p>
<p>-- Function to add liquidity to the pool</p>
<p>function addLiquidity(token: string, amount: number, ownerAddress: string) if amount &lt; 0 then error("Amount of token must be a positive integer")</p>
<p>end</p>
<p>if not pool[token] then pool[token] = token amounts[token] = amount owners[token] = ownerAddress else amounts[token] = amounts[token] + amount end lockStartTime = os.time()</p>
<p>end</p>
<p>-- Function to remove liquidity from the pool</p>
<p>function removeLiquidity(token: string, amount: number, ownerAddress: string) if amount &lt; 0 then error("Amount of token must be a positive integer")</p>
<p>end</p>
<p>if not pool[token] then error("Token is not in the pool") end if owners[token] ~= ownerAddress then error("Only the owner of the token can remove liquidity") end if amount &gt; amounts[token] then error("Cannot remove more liquidity than is currently in the pool")</p>
<p>end</p>
<p>if os.time() &lt; lockStartTime + lockDuration then error("Cannot remove liquidity until the lock duration has expired") end amounts[token] = amounts[token] - amount end</p>
<p>-- Function to check the current liquidity in the pool</p>
<p>function getLiquidity()</p>
<p>return pool, amounts</p>
<p>end</p>
<p>-- Function to check lock duration</p>
<p>function getLockDuration()</p>
<p>return lockDuration</p>
<p>end</p>
<p>-- Function to check lock start time</p>
<p>function getLockStartTime()</p>
<p>return lockStartTime</p>
<p>end</p>
</blockquote>
<h3 id="heading-nft-smart-contract">NFT Smart Contract</h3>
<blockquote>
<p>-- Smart contract for deploying non-fungible tokens with metadata on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local metadata = {}</p>
<p>-- Table to store metadata for each token</p>
<p>-- Function to deploy a non-fungible token with metadata</p>
<p>function deployNFT(tokenId: string, title: string, description: string, url: string, mediaUrl: string) if not tokenId or not title or not description or not url or not mediaUrl then error("Token ID, title, description, URL, and media URL must all be provided") end metadata[tokenId] = { title: title, description: description, url: url, mediaUrl: mediaUrl }</p>
<p>-- Deploy the token using the tokenId end</p>
<p>-- Function to get metadata for a token</p>
<p>function getMetadata(tokenId: string)</p>
<p>return metadata[tokenId]</p>
<p>end</p>
<p>-- Function to delete metadata for a token</p>
<p>function deleteMetadata(tokenId: string)</p>
<p>metadata[tokenId] = nil</p>
<p>end</p>
</blockquote>
<h3 id="heading-ft-smart-contract">FT Smart Contract</h3>
<blockquote>
<p>-- Smart contract for deploying fungible tokens with metadata on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local metadata = {}</p>
<p>-- Table to store metadata for each token</p>
<p>-- Function to deploy a fungible token with metadata</p>
<p>function deployFungibleToken(tokenId: string, name: string, amount: number, decimals: number, description: string, url: string) if not tokenId or not name or not amount or not decimals or not description or not url then error("Token ID, name, amount, decimals, description, and URL must all be provided") end metadata[tokenId] = { name: name, amount: amount, decimals: decimals, description: description, image-url: url }</p>
<p>-- Deploy the token using the tokenId, name, and amount end</p>
<p>-- Function to get metadata for a token</p>
<p>function getMetadata(tokenId: string)</p>
<p>return metadata[tokenId]</p>
<p>end</p>
<p>-- Function to delete metadata for a token</p>
<p>function deleteMetadata(tokenId: string)</p>
<p>metadata[tokenId] = nil</p>
<p>end</p>
</blockquote>
<h3 id="heading-timestamp-anything-smartcontract">Timestamp Anything SmartContract</h3>
<blockquote>
<p>-- Smart contract for creating timestamped records with metadata on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local records = {}</p>
<p>-- Table to store metadata for each record</p>
<p>-- Function to create a timestamped record with metadata</p>
<p>function createRecord(recordId: string, ownerName: string, artistName: string, songTitle: string, description: string, url: string, mediaUrl: string, imageUrl: string) if not recordId or not ownerName or not artistName or not songTitle or not description or not url or not mediaUrl or not imageUrl then error("Record ID, owner name, artist name, song title, description, URL, media URL, and image URL must all be provided") end records[recordId] = { timestamp: os.time(), ownerName: ownerName, artistName: artistName, songTitle: songTitle, description: description, url: url, mediaUrl: mediaUrl, imageUrl: imageUrl } end</p>
<p>-- Function to get metadata for a record</p>
<p>function getRecord(recordId: string)</p>
<p>return records[recordId]</p>
<p>end</p>
<p>-- Function to delete a record</p>
<p>function deleteRecord(recordId: string)</p>
<p>records[recordId] = nil</p>
<p>end</p>
</blockquote>
<h3 id="heading-burn-nft-smartcontract">Burn NFT SmartContract</h3>
<blockquote>
<p>-- Smart contract for burning non fungible tokens on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local tokenId = 0</p>
<p>-- ID of the non fungible token being burned</p>
<p>-- Function to set the ID of the non fungible token to be burned</p>
<p>function setTokenId(id: number) tokenId = id</p>
<p>end</p>
<p>-- Function to execute the burn</p>
<p>function burnToken()</p>
<p>-- Check if the user is the owner of the non fungible token using the appropriate API</p>
<p>if !isTokenOwner(tokenId)</p>
<p>then error("You are not the owner of this non fungible token and cannot burn it")</p>
<p>end</p>
<p>-- Burn the non fungible token using the appropriate</p>
<p>API burnMagmaToken(tokenId)</p>
<p>end</p>
</blockquote>
<h3 id="heading-burn-tokens-smartcontract">Burn Tokens SmartContract</h3>
<blockquote>
<p>-- Smart contract for burning fungible tokens on the MAGMA cryptocurrency on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local tokenAmount = 0</p>
<p>-- Amount of the fungible tokens being burned</p>
<p>-- Function to set the amount of fungible tokens to be burned</p>
<p>function setTokenAmount(amount: number) if amount &lt; 0 then error("Amount of fungible tokens to burn must be a positive integer") end tokenAmount = amount end</p>
<p>-- Function to execute the burn function</p>
<p>burnTokens()</p>
<p>-- Check if the user has the necessary balance of fungible tokens using the appropriate API if</p>
<p>!hasTokenBalance(tokenAmount)</p>
<p>then error("You do not have sufficient balance of fungible tokens to burn")</p>
<p>end</p>
<p>-- Burn the fungible tokens using the appropriate API</p>
<p>burnMagmaTokens(tokenAmount)</p>
<p>end</p>
</blockquote>
<h3 id="heading-mint-nft-smartcontract">Mint NFT SmartContract</h3>
<blockquote>
<p>-- Smart contract for minting non fungible tokens on the MoltenChain blockchain</p>
<p>-- Define variables</p>
<p>local name = "" -- Name of the non fungible token</p>
<p>local assetId = 0 -- ID of the asset associated with the non fungible token</p>
<p>local description = "" -- Description of the non fungible token</p>
<p>local mediaUrl = "" -- URL of the media associated with the non fungible token</p>
<p>local imageUrl = "" -- URL of the image associated with the non fungible token</p>
<p>local websiteUrl = "" -- URL of the website associated with the non fungible token</p>
<p>local royalty1Percent = 0 -- Percentage of royalties for the first recipient local</p>
<p>royalty1Address = "" -- Wallet address of the first recipient of royalties local</p>
<p>royalty2Percent = 0 -- Percentage of royalties for the second recipient local</p>
<p>royalty2Address = "" -- Wallet address of the second recipient of royalties</p>
<p>-- Function to set the metadata for the non fungible token</p>
<p>function setMetadata(n: string, aId: number, desc: string, mUrl: string, iUrl: string, wUrl: string, r1P: number, r1A: string, r2P: number, r2A: string) name = n assetId = aId description = desc mediaUrl = mUrl imageUrl = iUrl websiteUrl = wUrl royalty1Percent = r1P royalty1Address = r1A royalty2Percent = r2P royalty2Address = r2A end</p>
<p>-- Function to mint the non fungible token</p>
<p>function mintToken()</p>
<p>-- Check if all required metadata has been set</p>
<p>if name == "" or assetId == 0 or description == "" or mediaUrl == "" or imageUrl == "" or websiteUrl == "" or royalty1Percent == 0 or royalty1Address == "" then error("All required metadata has not been set") end -- Create the non fungible token object with the provided metadata local token = createMagmaNft(name, assetId, description, mediaUrl, imageUrl, websiteUrl, royalty1Percent, royalty1Address, royalty2Percent, royalty2Address)</p>
<p>-- Mint the non fungible token using the appropriate API</p>
<p>mintMagmaNft(token)</p>
<p>end</p>
</blockquote>
<h3 id="heading-royalty-smartcontract">Royalty SmartContract</h3>
<blockquote>
<p>-- Smart contract for paying royalties when a non fungible token is traded or swapped</p>
<p>-- Define variables</p>
<p>local tokenId = 0 -- ID of the non fungible token</p>
<p>local royalty1Address = "" -- Wallet address of the first recipient of royalties</p>
<p>local royalty2Address = "" -- Wallet address of the second recipient of royalties</p>
<p>-- Function to set the ID of the non fungible token and the royalty recipient addresses</p>
<p>function setTokenAndRecipients(id: number, r1A: string, r2A: string) tokenId = id royalty1Address = r1A royalty2Address = r2A</p>
<p>end</p>
<p>-- Function to pay the royalties when the non fungible token is traded</p>
<p>function payOnTrade()</p>
<p>-- Check if the token ID and royalty recipient addresses have been set</p>
<p>if tokenId == 0 or royalty1Address == "" or royalty2Address == "" then error("Token ID and royalty recipient addresses have not been set")</p>
<p>end</p>
<p>-- Get the metadata for the non fungible token using the appropriate API</p>
<p>local metadata = getMagmaNftMetadata(tokenId) -- Calculate the royalties to be paid</p>
<p>local royalty1Amount = metadata.royalty1Percent <em>getTradeAmount() / 100</em></p>
<p><em>local royalty2Amount = metadata.royalty2Percent</em> getTradeAmount() / 100</p>
<p>-- Pay the royalties using the appropriate API</p>
<p>payMagma(royalty1Address, royalty1Amount)</p>
<p>payMagma(royalty2Address, royalty2Amount)</p>
<p>end</p>
<p>-- Function to pay the royalties when the non fungible token is swapped</p>
<p>function payOnSwap() -- Check if the token ID and royalty recipient addresses have been set if tokenId == 0 or royalty1Address == "" or royalty2Address == "" then error("Token ID and royalty recipient addresses have not been set") end</p>
<p>-- Get the metadata for the non fungible token using the appropriate API</p>
<p>local metadata = getMagmaNftMetadata</p>
</blockquote>
<h3 id="heading-simple-play-to-earn-smart-contract">Simple Play-to-Earn Smart Contract</h3>
<blockquote>
<p>-- Smart contract for a play-to-earn game</p>
<p>-- Define variables</p>
<p>local walletAddress = ""</p>
<p>-- Wallet address of the player</p>
<p>local level = 0</p>
<p>-- Current level of the player</p>
<p>-- Function to set the wallet address and level of the player</p>
<p>function setPlayer(addr: string, lvl: number) walletAddress = addr level = lvl</p>
<p>end</p>
<p>-- Function to give the player 5 tokens for leveling up</p>
<p>function rewardPlayer()</p>
<p>-- Check if the wallet address and level have been set</p>
<p>if walletAddress == "" or level == 0 then error("Wallet address and level have not been set")</p>
<p>end</p>
<p>-- Give the player 5 tokens</p>
<p>issueMagma(walletAddress, 5) -- Increase the player's level by 1 level = level + 1 end</p>
<p>-- Example usage: setPlayer("magma1hj2q3q3q3q3q3q3q3q3q3q3q3q3q3q3q3q3", 5) rewardPlayer() -- Gives the player 5 tokens and increases their level to 6</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[MAGMA tokens will be re-minted upon MAGMA Native Launch!]]></title><description><![CDATA[MAGMA on Algorand has been a thing now for over a year, currently, it holds its price and this will change.
Algorand Layer 1 assets work differently from the likes of Ethereum and creating a stablecoin based on another currency does not require a sma...]]></description><link>https://blog.magm.red/magma-tokens-will-be-re-minted-upon-magma-native-launch</link><guid isPermaLink="true">https://blog.magm.red/magma-tokens-will-be-re-minted-upon-magma-native-launch</guid><category><![CDATA[mnft]]></category><category><![CDATA[MoltenChain]]></category><category><![CDATA[MAGMA]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Wed, 21 Dec 2022 21:33:01 GMT</pubDate><content:encoded><![CDATA[<p>MAGMA on Algorand has been a thing now for over a year, currently, it holds its price and this will change.</p>
<p>Algorand Layer 1 assets work differently from the likes of Ethereum and creating a stablecoin based on another currency does not require a smart contract.</p>
<p>When we add liquidity to MAGMA Native, it will be via our swapping platform, called a DEX or decentralized exchange. Based on our budget, and available USD we believe the price will of MAGMA native starts at around $0.0000007770 per MAGMA requiring us to only invest $603.729.</p>
<p>The details of MAGMA native:</p>
<ol>
<li><p>777 MILLION TOKENS TOTAL</p>
</li>
<li><p>10 Decimal Points</p>
</li>
<li><p>Beginning price of $0.0000007770</p>
</li>
</ol>
<h3 id="heading-oracles">Oracles</h3>
<p>We plan on using Oracles to keep the price of MAGMA-ALGO/MAGMA-ADA/MAGMA-XLM/MAGMA-ETH/MAGMA-BNB/MAGMA-ICP/MAGMA-DC the same as MAGMA's native coin, with this will bring on the MoltenChain's Smart Bridge technology.</p>
<h3 id="heading-what-happens-to-the-current-magma-on-algorand">What happens to the current MAGMA on Algorand?</h3>
<p>We will buy them back 1:1, meaning if Bob has 5 MAGMA on ALGO, Bob will receive 5 MAGMA-ALGO.</p>
<p>The same goes for MAGMA on Cardano and MAGMA on Stellar.</p>
<p>Once we buy them all back, we burn them, and the tokens that are locked will remain in existence until the lock expires when those will be burned as well.</p>
<h3 id="heading-what-about-the-magma-nfts">What about the MAGMA NFTs?</h3>
<p>We are building a smart bridge for NFT's as well, so if you own any of the MAGMA NFTs you will be able to transfer them, value and metadata from the Algorand, Cardano or Stellar blockchains to the MoltenChain blockchain using our future NFT marketplace called, 𝕄ℕ𝔽𝕋.𝓲𝓷𝓴 !</p>
<p>How it works is simple, if you own MAGMA NFTs the platform will ask you to connect the destination wallet, once you connect the ALGO, ADA or XLM wallet to 𝕄ℕ𝔽𝕋.𝓲𝓷𝓴 it will ask you to connect your receiving wallet if you don't have one connected. You will have to pay the network fee from the originating blockchain, and MoltenChain's fee.</p>
<p>Select the NFT's you want to transfer through the bridge and pay the first transaction fee. You will need to approve each NFT transaction, so it can transfer the NFT from the destination wallet to a wallet owned by 𝕄ℕ𝔽𝕋.𝓲𝓷𝓴</p>
<p>Once the transfer of the asset is complete, it will copy the metadata and value associated with the NFT. Then it will deploy and mint the NFT and send it to your Volcanic Wallet.</p>
<p>It will then ask for a confirmation, once confirmed. The wallet holding the original NFT will send it into the furnace, burning it out of existence.</p>
]]></content:encoded></item><item><title><![CDATA[Developing an entire blockchain with NFT & FT deployment, baked into the source code.]]></title><description><![CDATA[During our research into going as a native cryptocurrency, with an independent blockchain, we were looking at Ark. Ark allows a developer to create a blockchain and coin with their ecosystem, but due to the unstable nature of the crypto market and th...]]></description><link>https://blog.magm.red/developing-an-entire-blockchain-with-nft-ft-deployment-baked-into-the-source-code</link><guid isPermaLink="true">https://blog.magm.red/developing-an-entire-blockchain-with-nft-ft-deployment-baked-into-the-source-code</guid><category><![CDATA[MoltenChain]]></category><category><![CDATA[MAGMA]]></category><category><![CDATA[native]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[TypeScript]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Wed, 21 Dec 2022 20:43:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671651527129/ChFzuKonz.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>During our research into going as a native cryptocurrency, with an independent blockchain, we were looking at Ark. Ark allows a developer to create a blockchain and coin with their ecosystem, but due to the unstable nature of the crypto market and the fact that the Ark team, keeps changing things we decided that the path we were taking was wrong.</p>
<h3 id="heading-what-is-typescript">What is TypeScript?</h3>
<p>TypeScript adds additional syntax to JavaScript to support a <strong>tighter integration with your editor</strong>. Catch errors early in your editor.</p>
<p>TypeScript code converts to JavaScript, which <strong>runs anywhere JavaScript runs</strong>: In a browser, on Node.js or Deno and in your apps.</p>
<p>TypeScript understands JavaScript and uses <strong>type inference to give you great tooling</strong> without additional code.</p>
<h3 id="heading-crypto-in-typescript"><strong>Crypto in TypeScript</strong></h3>
<p>The following Node modules were used:</p>
<blockquote>
<ul>
<li><p><code>nodemon for automatic reloading of project on every save (npm i nodemon –save-dev)</code></p>
</li>
<li><p><code>jest for unit testing (npm i jest –save-dev)</code></p>
</li>
<li><p><code>@types-jest (npm i @types/jest) for importing Jest symbols into TypeScript unit tests</code></p>
</li>
<li><p><code>typescript for writing code in TypeScript (npm i -g typescript)</code></p>
</li>
<li><p><code>tslint (npm i tslint -g)</code></p>
</li>
<li><p><code>crypto-js (cryptographic package for generating SHA-256 hashes) (npm i crypto-js –save)</code></p>
</li>
<li><p><code>@types/crypto-js (npm i @types/crypto-js –save) for importing crypto-js symbols into TypeScript</code></p>
</li>
<li><p><code>express as a HTTP web server (npm i express –save)</code></p>
</li>
<li><p><code>@types/express for importing express symbols into TypeScript (npm i @types/express –save-dev)</code></p>
</li>
<li><p><code>body-parser as middleware for parsing HTTP requests and receiving POST requests in JSON format (npm i body-parser –save)</code></p>
</li>
<li><p><code>ws, a Node.js web socket library (npm i ws –save)</code></p>
</li>
<li><p><code>@types/ws – type definitions for ws (npm i @types/ws –save)</code></p>
</li>
<li><p><code>elliptic – for using elliptic curve cryptography to generate public-private keypairs (npm i elliptic –save)</code></p>
</li>
<li><p><code>uuid – for generating unique transaction ID’s (npm i uuid –save)</code></p>
</li>
<li><p><code>@types/uuid – type definitions for uuid (npm i @types/uuid –save)</code></p>
</li>
<li><p><code>+FT &amp; NFT deployement baked directly into MoltenChain</code></p>
</li>
<li><p><code>VolcanicWallet functions baked directly into MoltenChain</code></p>
</li>
<li><p><code>DirectStorage API baked directly into MoltenChain</code></p>
</li>
<li><p><code>MAGMAPay API baked directly into MoltenChain</code></p>
</li>
</ul>
</blockquote>
<h3 id="heading-typescript-configuration-and-issues">TypeScript Configuration and Issues</h3>
<p><a target="_blank" href="https://www.typescriptlang.org/docs/handbook/compiler-options.html">TypeScript compiler options</a> were set to be more strict to make the code more type safe. Specifically, the “noImplicitAny” was set to “true” to make the compiler force the use of explicit types throughout the code.</p>
<p><a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/tsconfig.json">tsconfig.json</a> used for this project.</p>
<blockquote>
<p><code>{     "compilerOptions": {         "strictNullChecks": true,         "noImplicitAny": true,         "moduleResolution": "node",         "target": "es5",         "lib": [             "es2015", "dom"         ],         "sourceMap": true     },     "include": [         "src/**/*",         "test/**/*",     ], }</code></p>
</blockquote>
<p>The compiler target in tsconfig.json was set to “es5”. When I tried to set it to “es6” I had many problems running Jest tests because Node does not support es6 imports and I was getting the runtime error: “SyntaxError: Unexpected token import” when importing a module like this:</p>
<blockquote>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { Block } <span class="hljs-keyword">from</span> <span class="hljs-string">"../../src/blockchain/block"</span>

<span class="hljs-comment">// So then I tried setting the compile target in tsconfig.json to “es5” but that would result in a compilation error in one of the ws (web sockets) type definition file (web sockets):</span>

node_modules/<span class="hljs-meta">@types</span>/ws/index.d.ts:<span class="hljs-number">181</span>:<span class="hljs-number">18</span> - error TS2304: Cannot find name <span class="hljs-string">'Set'</span>

<span class="hljs-comment">// So I was stuck and tried to find a solution. I looked at using Babel to transpile from ES6 to ES5 as well as using</span>

node --experimental-modules file.mjs

<span class="hljs-comment">// as outlined in Stack Overflow question: Node.js – SyntaxError: Unexpected token import .</span>

<span class="hljs-comment">// I finally found a more simple solution on this Stack Overflow answer that talks about using the “lib” compiler option in tsconfig.json:</span>

<span class="hljs-string">"lib"</span>: [<span class="hljs-string">"es2015"</span>, <span class="hljs-string">"dom"</span>]

<span class="hljs-comment">// which referenced the Angular TypeScript documentation that stated:</span>

TypeScript includes a special declaration file called lib.d.ts. This file contains the ambient declarations <span class="hljs-keyword">for</span> various common JavaScript constructs present <span class="hljs-keyword">in</span> JavaScript runtimes and the DOM.

Based on the --target, TypeScript adds additional ambient declarations like <span class="hljs-built_in">Promise</span> <span class="hljs-keyword">if</span> the target is es6.

Since the QuickStart is targeting es5, you can override the list <span class="hljs-keyword">of</span> declaration files to be included:

content_copy
<span class="hljs-string">"lib"</span>: [<span class="hljs-string">"es2015"</span>, <span class="hljs-string">"dom"</span>]
Thanks to that, you have all the es6 typings even when targeting es5.
</code></pre>
</blockquote>
<h3 id="heading-unit-testing-with-jest">Unit Testing with Jest</h3>
<p>This blockchain was thoroughly unit tested using the <a target="_blank" href="https://jestjs.io/">Jest testing framework</a>. All Jest unit tests are in the Github <a target="_blank" href="https://github.com/gomisha/blockchain/tree/master/test">test folder</a> and are appended with a “.test” to correspond with the file they are testing. For example, <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/test/wallet/transaction.test.ts">transaction.test.ts</a> contains the unit tests for <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/wallet/transaction.ts">transaction.ts</a>.</p>
<p>Jest needs to be <a target="_blank" href="http://jestjs.io/docs/en/configuration.html">configured</a> to run in Node mode instead of its default “jsdom” or browser mode. The jest section in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/package.json">package.json</a>, is:</p>
<blockquote>
<p>"jest": {<br />    "transform": {},<br />    "testRegex": "/test/.*\.test\.(js)$",<br />    "testEnvironment": "node"<br />  }</p>
</blockquote>
<h2 id="heading-blockchain-trustless-system">Blockchain – Trustless System</h2>
<p>A blockchain is a public and immutable shared ledger that stores all transactions for an application, such as a cryptocurrency like Bitcoin and Ethereum. For a cryptocurrency application, the ledger stores all transactions such as who transferred funds to who, similar to a bank ledger. Each set of transactions is represented as a block on the blockchain. A block can store multiple transactions, as shown in the <a target="_blank" href="https://www.youtube.com/watch?v=43ylJkVmnNA">demo video</a>.</p>
<p>Once a transaction has been committed (mined) to the blockchain (ledger), it can’t be edited or removed. Also, all nodes on the blockchain network keep a replicated copy of the blockchain so there is no central place where the block chain is stored. When a new block is added to the blockchain, all nodes in the blockchain network are updated to have the newest version of the blockchain.</p>
<p>Every block in the chain is linked to the previous block by storing the <a target="_blank" href="https://en.wikipedia.org/wiki/Cryptographic_hash_function">hash value</a> of the previous block, which creates a chain of blocks.</p>
<p>Instead of a central trusted authority like a bank, the blockchain network itself acts as the trusted authority because of its built in trust and security features. This eliminates the need for middle men such as banks and doesn’t have a single point of failure. An attacker would have to take over a large segment of a blockchain network in order to compromise it whereas a bank robber only needs to rob a single bank to steal a lot of money.</p>
<h2 id="heading-block-class">Block Class</h2>
<p>The fundamental object of the blockchain is the block, which represents an individual link in the blockchain. The blockchain stores the following properties:</p>
<ul>
<li><p>current hash (based on the timestamp, hash of previous block and transactions)</p>
</li>
<li><p>hash of the previous block</p>
</li>
<li><p>timestamp</p>
</li>
<li><p>data to store (cryptocurrency transactions but can store generic data, as well)</p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Cryptographic_nonce">nonce</a> value (for mining new blocks)</p>
</li>
<li><p><a target="_blank" href="http://learnmeabitcoin.com/guide/difficulty">difficulty</a> value (for mining new blocks)</p>
</li>
</ul>
<p>The code for the Block class is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/blockchain/block.ts">src/blockchain/block.ts</a>. This snippet shows the above properties:</p>
<blockquote>
<p><code>export default class Block {</code></p>
<p><code>timestamp: number;</code></p>
<p><code>lastHash: string;</code></p>
<p><code>hash: string;</code></p>
<p><code>//for cryptocurrency - transactions are the data in each block //but the blockchain can hold any data data: any; nonce: number;</code></p>
<p><code>difficulty: number;</code></p>
<p><code>}</code></p>
</blockquote>
<h3 id="heading-genesis-block">Genesis Block</h3>
<p>The Genesis Block is the very first block in a blockchain – a way to start a blockchain. Since there’s no preceding block, the genesis block uses hard coded dummy values for its previous hash value. This way, when the second block gets added to the blockchain, it will set the value of its previous hash to the hash of the genesis block. Since the genesis block is hard coded, we make it a static method of the Block class, so it’s accessible without instantiating a Block object.</p>
<p>The code for the genesis block is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/blockchain/block.ts">src/blockchain/block.ts</a>:</p>
<blockquote>
<p><code>/**    * First block of the blockchain.    */   static getGenesisBlock(): Block {     let genesisTx: Transaction = new Transaction();     genesisTx.id = "genesis";     genesisTx.txInput = new TransactionInput(0, "-----");     return new Block(0, '-----', 'f1r5t-ha4h', genesisTx, 0, config.DIFFICULTY);   }</code></p>
</blockquote>
<h2 id="heading-blockchain-class">Blockchain Class</h2>
<p>The Blockchain class is responsible for</p>
<ul>
<li><p>storing the list of blocks on the blockchain</p>
</li>
<li><p>adding new blocks to the chain</p>
</li>
<li><p>validating new blockschains</p>
</li>
<li><p>replacing current blockchain with a new one (when synchronizing with other nodes)</p>
</li>
</ul>
<p>The code for the blockchain class is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/blockchain/index.ts">src/blockchain/index.ts</a>. The following code snippet shows the storage of an array of blocks within the Blockchain class, which illustrates that when a new blockchain is created, it comes pre-loaded with a single block – the <a target="_blank" href="https://en.bitcoin.it/wiki/Genesis_block">genesis block</a>:</p>
<blockquote>
<p><code>export default class Blockchain {     chain: Block [];     constructor() {         this.chain = [Block.getGenesisBlock()];     } }</code></p>
</blockquote>
<h2 id="heading-blockchain-replication">Blockchain Replication</h2>
<p>Every node on the network needs to have the same copy of the blockchain. So what happens when a new block gets mined on one node? Now the system has to replicate the new block to all the other nodes on the network so every node is in sync and has the same copy of the blockchain.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671653800072/IeMTHrOIC.png" alt class="image--center mx-auto" /></p>
<p>Since the blockchain needs to be replicated among all nodes in the network, the question arises – what happens if two nodes mine a block at the same time? This is when there’s a fork in the blockchain and the system needs to reconcile the fork and merge all the new blocks.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671653839824/eWIMBpWY6.png" alt class="image--center mx-auto" /></p>
<p>When a fork occurs, some nodes will get replicated from node A and some will get replicated from node B which will create the following scenario:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671653891204/6q-kW_Ypr.png" alt class="image--center mx-auto" /></p>
<p>We will use the rule that the longest chain will be accepted as the main chain. If there is a conflict between multiple nodes mining blocks at the same time, eventually, one chain will be longer and that will be accepted as the master blockchain. The other blocks that were mined on the shorter chain will be incorporated into the main blockchain.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671653943457/vpETKCd0C.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-web-application">Web Application</h2>
<p>The web application expose a series of JSON endpoints that will allow each node on the network to interact with the blockchain with its own HTTP server:</p>
<ul>
<li><p>GET /blocks – view node’s copy of the full blockchain</p>
</li>
<li><p>GET /balance – view node’s wallet balance</p>
</li>
<li><p>GET /public-key – view node’s public key (to know the wallet address to transfer cryptocurency to)</p>
</li>
<li><p>GET /transactions – view node’s copy of the transaction pool (transactions that haven’t been mined)</p>
</li>
<li><p>POST /mine – to add a generic new block to the chain (for adding non cryptocurrency blocks to the blockchain)</p>
</li>
<li><p>POST /mine-transactions – to add cryptocurrency transactions to the blockchain</p>
</li>
<li><p>POST /transact – add cryptocurrency transaction to the transaction pool</p>
</li>
</ul>
<p>The code for the web application is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/app/index.ts">src/app/index.ts</a>:</p>
<h2 id="heading-peer-to-peer-server">Peer-to-Peer Server</h2>
<p>Each node on the blockchain network needs the ability to communicate with other nodes (peers) on the network in order to:</p>
<ul>
<li><p>get an updated blockchain from its peers</p>
</li>
<li><p>for broadcasting to other nodes when it has an updated version of the blockchain</p>
</li>
</ul>
<p>Each peer-to-peer server uses <a target="_blank" href="https://www.html5rocks.com/en/tutorials/websockets/basics/">web sockets</a> instead of HTTP to communicate with each node.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671654037503/L1xl1OGQw.png" alt class="image--center mx-auto" /></p>
<p>Blockchain synchronization between nodes is done by sending a synchronization message to other nodes as soon as new block is mined on any node. However, before a node replaces its blockchain from an update it received from one of its peers, it needs to check that the updated chain is longer than its current chain and that the new blockchain is valid (by validating its hashes). For new nodes that just join the network, they get an updated version of the blockchain from one of its peers.</p>
<p>The peer-to-peer server is also responsible for synchronizing and clearing the transaction pool between nodes.</p>
<p>The code for the peer-to-peer server is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/app/p2p-server.ts">src/app/p2p-server.ts</a>, which contains the code for blockchain synchronization between nodes:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">/**
 * Convenience method for sending blockchain on a socket.
 * Specifies that message contains blockchain by setting "type" parameter.
 * @param webSocket The WebScoket to send the blockchain on.
 */</span>
sendChain(webSocket: WebSocket): <span class="hljs-built_in">void</span> {
  webSocket.send(<span class="hljs-built_in">JSON</span>.stringify({
    <span class="hljs-keyword">type</span>:MESSAGE_TYPES.chain,
    chain: <span class="hljs-built_in">this</span>.blockchain.chain
  }));
}
</code></pre>
<p>The peer-to-peer server is also responsible for processing incoming messages from other nodes and determining what to do, based on the message type. There are three message command types:</p>
<ul>
<li><p>replace the current blockchain with a new blockchain</p>
</li>
<li><p>update or add a new transaction in the transaction pool</p>
</li>
<li><p>clear the transaction pool</p>
</li>
</ul>
<p>Code snippet for processing incoming messages:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">/**
 * Process incoming message, based on the message type.
 * @param socket Socket of incoming message.
 */</span>
messageHandler(socket: WebSocket): <span class="hljs-built_in">void</span> {
  socket.on(<span class="hljs-string">"message"</span>, <span class="hljs-function"><span class="hljs-params">message</span> =&gt;</span> {
    <span class="hljs-keyword">const</span> messageData = <span class="hljs-built_in">JSON</span>.parse(message.toString());

    <span class="hljs-keyword">switch</span>(messageData.type) {
      <span class="hljs-keyword">case</span> MESSAGE_TYPES.chain:
        <span class="hljs-built_in">this</span>.blockchain.replaceChain(messageData.chain);
        <span class="hljs-keyword">break</span>;
      <span class="hljs-keyword">case</span> MESSAGE_TYPES.transaction:
        <span class="hljs-built_in">this</span>.tp.updateOrAddTransaction(messageData.transaction);
        <span class="hljs-keyword">break</span>;
      <span class="hljs-keyword">case</span> MESSAGE_TYPES.clear_transactions:
        <span class="hljs-built_in">this</span>.tp.clear();
        <span class="hljs-keyword">break</span>;
      <span class="hljs-keyword">default</span>:
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Undefined message type: "</span> + messageData.type);
    }
  });
}
</code></pre>
<h2 id="heading-cryptocurrency-app">Cryptocurrency App</h2>
<p>On top of our blockchain, we have a cryptocurrency app that leverages the blockchain to allow transferring digital currency between individuals. Our cryptocurrency app consists of:</p>
<ul>
<li><p>Wallet object for each user</p>
</li>
<li><p>Public-private key pair for digital signatures and verifying signatures from other people</p>
</li>
<li><p>Transaction objects to represent the currency exchange between parties</p>
</li>
</ul>
<h2 id="heading-cryptocurrency-wallet">Cryptocurrency Wallet</h2>
<p>Our cryptocurrency app uses a wallet to store a user’s balance and the public-private key pair. The private key is used to generate digital signatures and the public key is used to verify signatures from other people. The public address of the wallet is just the public key. The key pair is generated with <a target="_blank" href="https://en.bitcoin.it/wiki/Secp256k1">secp256k1 elliptical algorithm</a>, the same algorithm used by Bitcoin.</p>
<p>The wallet class is implemented in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/wallet/index.ts">src/wallet/index.ts</a>. Here is a snippet that shows the wallet properties and constructor. Note that each wallet starts with a pre-set balance.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">class</span> Wallet {
    balance: <span class="hljs-built_in">number</span>;
    keypair: <span class="hljs-built_in">any</span>;
    publicKey: <span class="hljs-built_in">any</span>;
    <span class="hljs-keyword">static</span> bcWallet: Wallet;

    <span class="hljs-comment">//for balance re-calculation - need to know from where to start recalculating</span>
    lastBlockTimestamp: <span class="hljs-built_in">number</span>;

    <span class="hljs-comment">//when last did balance recalculation, this was the last block</span>
    lastBlockBalanceCalc: <span class="hljs-built_in">number</span>;

    <span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
        <span class="hljs-built_in">this</span>.balance = config.INITIAL_BALANCE;
        <span class="hljs-built_in">this</span>.keypair = ChainUtil.genKeyPair();
        <span class="hljs-built_in">this</span>.publicKey = <span class="hljs-built_in">this</span>.keypair.getPublic().encode(<span class="hljs-string">"hex"</span>);
        <span class="hljs-built_in">this</span>.lastBlockTimestamp = <span class="hljs-number">0</span>;
        <span class="hljs-built_in">this</span>.lastBlockBalanceCalc = <span class="hljs-number">0</span>;
    }
}
</code></pre>
<h2 id="heading-blockchain-wallet">Blockchain Wallet</h2>
<p>The blockchain wallet is implemented in the Wallet class as a <a target="_blank" href="https://en.wikipedia.org/wiki/Singleton_pattern">Singleton</a> so the same wallet instance can be reused. The blockchain wallet code is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/wallet/index.ts">src/wallet/index.ts</a>:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">/**
 * Uses Singleton pattern to retrieve the special Blockchain Wallet.
 * Creates it only one time.
 */</span>
<span class="hljs-keyword">static</span> getBlockchainWallet():Wallet {
  <span class="hljs-keyword">if</span>(!Wallet.bcWallet) {
    Wallet.bcWallet = <span class="hljs-keyword">new</span> <span class="hljs-built_in">this</span>();
    Wallet.bcWallet.publicKey = config.BLOCKCHAIN_WALLET_ADDRESS;
  }
  <span class="hljs-keyword">return</span> Wallet.bcWallet;
}
</code></pre>
<h2 id="heading-cryptocurrency-transactions">Cryptocurrency Transactions</h2>
<p>Each block in the blockchain will store one or more cryptocurrency transactions. Since the blockchain is a permanent record of all transactions, each user can see a complete history of their transactions on the blockchain. Each transaction object consists of:</p>
<ul>
<li><p>a unique ID to identify the transaction object (to make transactions easier to find in large collections)</p>
</li>
<li><p>a single Transaction Input object</p>
</li>
<li><p>an array of Transaction Output objects</p>
</li>
</ul>
<p>Code for the Transaction class is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/wallet/transaction.ts">src/wallet/transaction.ts</a>. Here is a snippet of the properties of the Transaction class:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">class</span> Transaction {
    id: <span class="hljs-built_in">string</span>;
    txInput: TransactionInput;
    txOutputs: TransactionOutput[];

    <span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
        <span class="hljs-built_in">this</span>.id = ChainUtil.genID();
        <span class="hljs-built_in">this</span>.txOutputs = [];
    }
}
</code></pre>
<p>Each Transaction Input object contains:</p>
<ul>
<li><p>the sender’s address (which is their public key)</p>
</li>
<li><p>sender’s starting balance before the transaction</p>
</li>
<li><p>timestamp</p>
</li>
<li><p>sender’s signature of the transaction</p>
</li>
</ul>
<p>Code for the Transaction Input class is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/wallet/transaction-input.ts">src/wallet/transaction-input.ts</a>:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">class</span> TransactionInput {
    amount: <span class="hljs-built_in">number</span>;
    address: <span class="hljs-built_in">string</span>;
    timestamp: <span class="hljs-built_in">number</span>;
    signature: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(<span class="hljs-params">amount: <span class="hljs-built_in">number</span>, address: <span class="hljs-built_in">string</span></span>) {
        <span class="hljs-built_in">this</span>.amount = amount;
        <span class="hljs-built_in">this</span>.address = address;
    }
}
</code></pre>
<p>Each Transaction Output object contains:</p>
<ul>
<li><p>recipient of transaction (i.e. the other wallet)</p>
</li>
<li><p>amount of currency transferred to recipient</p>
</li>
</ul>
<p>Code for the Transaction Output class is in <a target="_blank" href="https://github.com/gomisha/blockchain/blob/master/src/wallet/transaction-output.ts">src/wallet/transaction-output.ts</a>:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">class</span> TransactionOutput {
    amount: <span class="hljs-built_in">number</span>;
    address: <span class="hljs-built_in">string</span>;
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671654267253/9cCrsxAzE.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-since-moltenchain-is-a-proof-of-stake-blockchain-our-code-works-a-little-differnet">Since MoltenChain is a Proof-Of-Stake Blockchain our code works a little differnet...</h1>
<h2 id="heading-magma-native-on-moltenchain-in-typescript">MAGMA NATIVE ON MOLTENCHAIN in TypeScript</h2>
<h3 id="heading-moltenchain-and-magma-coin-initialization-script">MoltenChain and MAGMA Coin initialization script</h3>
<p><code>import { Block, Blockchain, Transaction } from "./blockchain";</code></p>
<p><code>class MAGMA extends Token { constructor(name: string, symbol: string, totalSupply: number) { super(name, symbol, totalSupply); }</code></p>
<p><code>static createNewToken(name: string, symbol: string, totalSupply: number) { return new MAGMA(name, symbol, totalSupply); } }</code></p>
<p><code>class MoltenChain extends Blockchain { constructor() { super(); }</code></p>
<p><code>static createNewBlockchain() { return new MoltenChain(); }</code></p>
<p><code>static createNewTransaction(sender: string, receiver: string, amount: number) { return new Transaction(sender, receiver, amount); }</code></p>
<p><code>static createNewBlock(prevHash: string, transactions: Transaction[]) { return new Block(prevHash, transactions); } }</code></p>
<p><code>const proofOfStake = (blockchain: MoltenChain, token: MAGMA) =&gt; { const currentBlock = blockchain.getLatestBlock(); const validators = token.getTopHolders();</code></p>
<p><code>let selectedValidator: string; let maxStake = 0;</code></p>
<p><code>validators.forEach(validator =&gt; { const stake = token.balanceOf(validator); if (stake &gt; maxStake) { selectedValidator = validator; maxStake = stake; } });</code></p>
<p><code>if (selectedValidator) { currentBlock.validator = selectedValidator; } };</code></p>
<p><code>const createNewMAGMAToken = (name: string, symbol: string, totalSupply: number) =&gt; { const magmaToken = MAGMA.createNewToken(name, symbol, totalSupply); console.log(Successfully created new MAGMA token: ${magmaToken.name} (${magmaToken.symbol}) with total supply of ${magmaToken.totalSupply}); return magmaToken; };</code></p>
<p><code>const createNewMoltenChainBlockchain = () =&gt; { const moltenChain = MoltenChain.createNewBlockchain(); console.log(Successfully created new MoltenChain blockchain.); return moltenChain; };</code></p>
<p><code>const createNewTransaction = (sender: string, receiver: string, amount: number, moltenChain: MoltenChain, magmaToken: MAGMA) =&gt; { magmaToken.transfer(sender, receiver, amount); const transaction = MoltenChain.createNewTransaction(sender, receiver, amount); moltenChain.addTransaction(transaction); console.log(Successfully added new transaction to MoltenChain blockchain: ${JSON.stringify(transaction)}); return transaction; };</code></p>
<p><code>const createNewBlock = (moltenChain: MoltenChain, magmaToken: MAGMA) =&gt; { const prevHash = moltenChain.getLatestBlock().hash; const transactions = moltenChain.pendingTransactions; proofOfStake(moltenChain, magmaToken); const block = MoltenChain.createNewBlock(prevHash, transactions); moltenChain.addBlock(block); console.log(Successfully added new block to MoltenChain blockchain: ${JSON.stringify(block)}); return</code></p>
<h3 id="heading-wallet-in-typescript">WALLET IN TYPESCRIPT</h3>
<p><code>import { MoltenChain, MAGMA } from "./moltenChain";</code></p>
<p><code>class Wallet { private balance: number; private moltenChain: MoltenChain; private address: string;</code></p>
<p><code>constructor(address: string, moltenChain: MoltenChain) { this.balance = 0; this.moltenChain = moltenChain; this.address = address; }</code></p>
<p><code>public async createNewToken(proofOfStake: number): Promise { if (this.balance &lt; proofOfStake) { throw new Error("Insufficient funds to create new token"); } this.balance -= proofOfStake; return this.moltenChain.createNewToken(this.address, proofOfStake); }</code></p>
<p><code>public async transferToken(token: MAGMA, recipient: string, amount: number): Promise { if (this.balance &lt; amount) { throw new Error("Insufficient funds to transfer token"); } this.balance -= amount; return this.moltenChain.transferToken(token, this.address, recipient, amount); }</code></p>
<p><code>public async getBalance(): Promise { return this.moltenChain.getBalance(this.address); } }</code></p>
<h3 id="heading-moltenchain-nft-deployment">MOLTENCHAIN NFT DEPLOYMENT</h3>
<p><code>define the MAGMA cryptocurrency and MoltenChain blockchain class MAGMA { constructor() { this.balance = 0; } }</code></p>
<p><code>class MoltenChain { constructor() { this.chain = []; this.currentBlock = { nonce: 0, data: [], previousHash: '' }; this.difficulty = 3; this.pendingTransactions = []; }</code></p>
<p><code>// proof of stake protocol to create a non fungible token createNonFungibleToken(data: any, stake: MAGMA) { // check if stake is sufficient if (stake.balance &lt; this.difficulty) { console.log('Insufficient stake'); return; }</code></p>
<p><code>// create a new block with the non fungible token data let newBlock = { nonce: this.currentBlock.nonce + 1, data: data, previousHash: this.currentBlock.previousHash };</code></p>
<p><code>// add the new block to the chain and update the current block this.chain.push(newBlock); this.currentBlock = newBlock;</code></p>
<p><code>// decrease the stake balance and add the non fungible token to the pending transactions stake.balance -= this.difficulty; this.pendingTransactions.push({type: 'nonFungibleToken', data: data}); } }</code></p>
<h3 id="heading-moltenchain-mint-fungible-token">MOLTENCHAIN MINT FUNGIBLE TOKEN</h3>
<p><code>import { Block, Blockchain, Transaction, FungibleToken, ProofOfStake } from 'moltenchain';class MAGMA implements FungibleToken { private name: string; private symbol: string; private totalSupply: number; private transactions: Transaction[];constructor(name: string, symbol: string, totalSupply: number) { this.name = name; this.symbol = symbol; this.totalSupply = totalSupply; this.transactions = []; }public getName(): string { return this.name; }public getSymbol(): string { return this.symbol; }public getTotalSupply(): number { return this.totalSupply; }public transfer(from: string, to: string, amount: number): boolean { // validate transaction if (amount &lt;= 0 || !this.validateTransaction(from, to, amount)) { return false; }// create new transaction const transaction = new Transaction(from, to, amount); this.transactions.push(transaction); return true; }public balanceOf(address: string): number { let balance = 0; for (const transaction of this.transactions) { if (transaction.from === address) { balance -= transaction.amount; } if (transaction.to === address) { balance += transaction.amount; } } return balance; }private validateTransaction(from: string, to: string, amount: number): boolean { // check if sender has sufficient balance if (this.balanceOf(from) &lt; amount) { return false; } return true; } }class MoltenChain extends Blockchain { private proofOfStake: ProofOfStake; private magma: MAGMA;constructor(proofOfStake: ProofOfStake, magma: MAGMA) { super(); this.proofOfStake = proofOfStake; this.magma = magma; }public createBlock(data: any): Block { // validate block with proof of stake if (!this.proofOfStake.validateBlock(data)) { throw new Error('Invalid block'); }// create new block with data and previous hash const block = new Block(data, this.getLatestBlock().hash); this.addBlock(block); return block; }public getFungibleToken(): MAGMA { return this.magma; } }const proofOfStake = new ProofOfStake(); const magma = new MAGMA('MAGMA', 'MAG', 1000000); const moltenChain = new MoltenChain(proofOfStake, magma);console.log(moltenChain.getFungibleToken().transfer('wallet1', 'wallet2', 500)); console.log(moltenChain.getFungibleToken().balanceOf('wallet1')); console.log(moltenChain.getFungibleToken().balanceOf('wallet2'));moltenChain.createBlock({ data:</code></p>
<h3 id="heading-grab-mnft-metadata-from-moltenchain">GRAB MNFT METADATA FROM MOLTENCHAIN</h3>
<p><code>import { Block, Transaction, NonFungibleToken } from 'moltenchain';</code></p>
<p><code>class MAGMA implements NonFungibleToken { // Non-fungible token metadata name: string; symbol: string; totalSupply: number; owner: string; metadata: any;</code></p>
<p><code>constructor(name: string, symbol: string, totalSupply: number, owner: string, metadata: any) { this.name = name; this.symbol = symbol; this.totalSupply = totalSupply; this.owner = owner; this.metadata = metadata; } }</code></p>
<p><code>class MoltenChain { // Blockchain properties chain: Block[]; currentBlock: Block; difficulty: number;</code></p>
<p><code>// Proof of stake properties validators: string[]; stake: number;</code></p>
<p><code>constructor(difficulty: number, validators: string[], stake: number) { this.chain = [this.createGenesisBlock()]; this.currentBlock = this.chain[0]; this.difficulty = difficulty; this.validators = validators; this.stake = stake; }</code></p>
<p><code>// Creates the first block in the blockchain (genesis block) createGenesisBlock(): Block { return new Block(Date.now(), [], '0'); }</code></p>
<p><code>// Returns the latest block in the blockchain getLatestBlock(): Block { return this.chain[this.chain.length - 1]; }</code></p>
<p><code>// Adds a new block to the blockchain addBlock(newBlock: Block): void { newBlock.previousHash = this.getLatestBlock().hash; newBlock.mineBlock(this.difficulty); this.chain.push(newBlock); }</code></p>
<p><code>// Validates the blockchain isChainValid(): boolean { for (let i = 1; i &lt; this.chain.length; i++) { const currentBlock = this.chain[i]; const previousBlock = this.chain[i - 1];</code></p>
<p><code>// Check if block has been tampered with if (currentBlock.hash !== currentBlock.calculateHash()) { return false; }</code></p>
<p><code>// Check if previous block hash points to the correct block if (currentBlock.previousHash !== previousBlock.hash) { return false; } } return true; }</code></p>
<p><code>// Adds a new transaction to the blockchain addTransaction(transaction: Transaction): number { if (!transaction.fromAddress || !transaction.toAddress) { throw new Error('Transaction must include from and to addresses'); }</code></p>
<p><code>// Check if validator has sufficient stake if (this.validators.indexOf(transaction.fromAddress) === -1 || this.stake &lt; transaction.amount) { throw new Error('Validator does not have sufficient stake'); }</code></p>
<p><code>// Add transaction to current block this.currentBlock.transactions.push(transaction);</code></p>
<p><code>// Check if block is full and create a new one if it is if (this.currentBlock.transactions.length &gt;= this.difficulty) { this.addBlock(new Block(Date.now(), [], this</code></p>
<h3 id="heading-this-a-rough-write-up-we-currently-testing-it-and-improving-the-code">This a rough write-up, we currently testing it and improving the code.</h3>
<p>Tightening it up, even more, the smart contracts on MoltenChain are written in Lua.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { Blockchain, Block, FungibleToken, NonFungibleToken, SmartContract, ProofOfStake } <span class="hljs-keyword">from</span> <span class="hljs-string">'moltenchain'</span>;

<span class="hljs-keyword">class</span> MAGMA <span class="hljs-keyword">extends</span> Blockchain {
<span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
<span class="hljs-built_in">super</span>();
<span class="hljs-built_in">this</span>.name = <span class="hljs-string">'MAGMA'</span>;
<span class="hljs-built_in">this</span>.consensus = <span class="hljs-keyword">new</span> ProofOfStake();
}

createFungibleToken(name: <span class="hljs-built_in">string</span>, symbol: <span class="hljs-built_in">string</span>, totalSupply: <span class="hljs-built_in">number</span>): FungibleToken {
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> FungibleToken(name, symbol, totalSupply);
}

createNonFungibleToken(name: <span class="hljs-built_in">string</span>, symbol: <span class="hljs-built_in">string</span>, data: <span class="hljs-built_in">any</span>): NonFungibleToken {
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> NonFungibleToken(name, symbol, data);
}

createSmartContract(code: <span class="hljs-built_in">string</span>, language: <span class="hljs-built_in">string</span>): SmartContract {
<span class="hljs-keyword">if</span> (language !== <span class="hljs-string">'lua'</span>) {
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'Only LUA is supported for smart contracts on MoltenChain'</span>);
}
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> SmartContract(code, language);
}
}

<span class="hljs-keyword">const</span> magma = <span class="hljs-keyword">new</span> MAGMA();

<span class="hljs-keyword">const</span> myFungibleToken = magma.createFungibleToken(<span class="hljs-string">'My Token'</span>, <span class="hljs-string">'MTK'</span>, <span class="hljs-number">100</span>);
<span class="hljs-keyword">const</span> myNonFungibleToken = magma.createNonFungibleToken(<span class="hljs-string">'My Collectible'</span>, <span class="hljs-string">'MTC'</span>, { rarity: <span class="hljs-string">'rare'</span> });
<span class="hljs-keyword">const</span> mySmartContract = magma.createSmartContract(<span class="hljs-string">'print("Hello, MoltenChain!")'</span>, <span class="hljs-string">'lua'</span>);
</code></pre>
<h3 id="heading-storing-moltenchain-records-to-the-cloud">Storing MoltenChain records to the cloud</h3>
<blockquote>
<p><code>import { Storage } from '@google-cloud/storage';</code></p>
<p><code>// Function to save records to the cloud storage for the MoltenChain blockchain async function saveRecords(records: any[], bucketName: string): Promise {</code></p>
<p><code>// Create a client for interacting with the Google Cloud Storage API</code></p>
<p><code>const storage = new Storage();</code></p>
<p><code>// Get a reference to the specified bucket</code></p>
<p><code>const bucket = storage.bucket(bucketName);</code></p>
<p><code>// Convert the records to a JSON string</code></p>
<p><code>const json = JSON.stringify(records);</code></p>
<p><code>// Create a new file in the bucket with the JSON data await bucket.file('molten_chain_records.json').save(json); }</code></p>
<p><code>// Example usage:</code></p>
<p><code>const records = [ { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Charlie', age: 35 }, ]; saveRecords(records, 'molten_chain_records_bucket').then(() =&gt; { console.log('Records saved successfully'); }).catch((error) =&gt; { console.error(error); });</code></p>
</blockquote>
<h3 id="heading-local-moltenchain-records">Local MoltenChain records</h3>
<blockquote>
<p>import { writeFileSync } from 'fs';</p>
<p>// Function to save records to an external storage location for the MoltenChain blockchain</p>
<p>function saveRecords(records: any[], filePath: string): void {</p>
<p>// Convert the records to a JSON string</p>
<p>const json = JSON.stringify(records);</p>
<p>// Save the JSON to the specified file path</p>
<p>writeFileSync(filePath, json); }</p>
<p>// Example usage:</p>
<p>const records = [ { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Charlie', age: 35 }, ]; saveRecords(records, '/path/to/molten_chain_records.json');</p>
</blockquote>
<h3 id="heading-moltenchain-smart-contracts-in-lua">MoltenChain Smart Contracts in LUA</h3>
<p>Here is an example of a token-locking smart contract for MoltenChain written in LUA.</p>
<blockquote>
<p><code>-- Smart contract for token locking mechanism on the MAGMA cryptocurrency on the MoltenChain blockchain</code></p>
<p><code>-- Define variables</code></p>
<p><code>local tokensLocked = 0</code></p>
<p><code>-- Number of tokens currently locked</code></p>
<p><code>local lockDuration = 86400 -- Duration of lock in seconds (86400 seconds = 1 day) local lockStartTime = 0 -- Timestamp of when the lock began</code></p>
<p><code>-- Function to lock tokens</code></p>
<p><code>function lockTokens(numTokens: number) if numTokens &lt; 0 then error("Number of tokens to lock must be a positive integer") end tokensLocked = tokensLocked + numTokens lockStartTime = os.time() end</code></p>
<p><code>-- Function to unlock tokens</code></p>
<p><code>function unlockTokens(numTokens: number) if numTokens &lt; 0 then error("Number of tokens to unlock must be a positive integer") end if numTokens &gt; tokensLocked then error("Cannot unlock more tokens than are currently locked") end if os.time() &lt; lockStartTime + lockDuration then error("Tokens cannot be unlocked until the lock duration has expired") end tokensLocked = tokensLocked - numTokens end</code></p>
<p><code>-- Function to check current number of locked tokens</code></p>
<p><code>function getLockedTokens() return tokensLocked end</code></p>
<p><code>-- Function to check lock duration</code></p>
<p><code>function getLockDuration() return lockDuration end</code></p>
<p><code>-- Function to check lock start time</code></p>
<p><code>function getLockStartTime() return lockStartTime end</code></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[MAGMA Bot for Discord]]></title><description><![CDATA[The MAGMA Bot for Discord is a modular system, and you can use it in the minimal state, by just installing the main module of the suite of bot modules.
MAGMA-Bot | Main module includes the entire SULFUR ecosystem, multiplayer games like Tic Tac Toe, ...]]></description><link>https://blog.magm.red/magma-bot-for-discord</link><guid isPermaLink="true">https://blog.magm.red/magma-bot-for-discord</guid><category><![CDATA[MAGMA]]></category><category><![CDATA[algorand]]></category><category><![CDATA[play-to-earn crypto]]></category><category><![CDATA[discord]]></category><category><![CDATA[bot]]></category><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Tue, 11 Oct 2022 19:22:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1665514114177/onJCjso4-.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The MAGMA Bot for Discord is a modular system, and you can use it in the minimal state, by just installing the main module of the suite of bot modules.</p>
<p><strong>MAGMA-Bot</strong> | Main module includes the entire SULFUR ecosystem, multiplayer games like Tic Tac Toe, Rock Paper Scissors, Chess, Mini Battles, The Walking Dead, and many more.</p>
<p>A full blown casino with a slot machine, poker, 3 card poker, blackjack, craps, roulette, and more.</p>
<p>Single player games like Demon Tree, My Storyline, and more.</p>
<p>Run contests, trivias, giveaways, lotteries and more.</p>
<p>Daily rewards, and weekly lootboxes based on role level.</p>
<p>Hire a hitman to kill another user and remain anonymous, pay the hitman in SULFUR.</p>
<p>Exchange system, you will need to purchase MAGMA for your server to have the capability to exchange SULFUR to MAGMA.</p>
<p>To buy MAGMA for your server exchange, please join the MAGMA Discord Server at https://discord.magm.red.</p>
<p><strong>MAGMA-Bot Moderation</strong> | A complete moderation and administration bot with custom commands, a punishment system with jail, parole and fines. An execution command to ban jailed members.</p>
<p>A complete verification system designed to protect your members from scammers and prevent your server from getting spammed.</p>
<p>eXP leveling system that automatically rewards users with new roles that earn higher SULFUR rewards.</p>
<p>A complete admin panel, and mods also, based on the role if admin, admin tools will be available in the panel. If the user has a moderation role, they will have a moderators panel.</p>
<p><strong>MAGMA-BOT Members</strong> | The member's module offers a unique experience to the server by adding various commands that allow members to take actions against each other weather good or bad. For example you could give someone a hug, or a slap.</p>
<p><strong>MAGMA-Bot Helpers</strong> | Is adding additional options such as full documentation of commands and a command to setup the roles, channels, categories, MAGMA wallets, permissions. Bot traps, anf much more.</p>
<p>enables future features like global functions in leaderboards, and rewarding top communities with MAGMA every week.</p>
<p>Cross server events and competitions, plus much more.</p>
]]></content:encoded></item><item><title><![CDATA[How it all began...]]></title><description><![CDATA[The MAGMA currency is the currency within world of The Verse, Lairiah. But that isn't all it has been created for, step in the journey of what MAGMA is in it's current form, and where we are taking it in the future.
MAGMA sets out to be a beacon for ...]]></description><link>https://blog.magm.red/how-it-all-began</link><guid isPermaLink="true">https://blog.magm.red/how-it-all-began</guid><dc:creator><![CDATA[Redeaux Corporation]]></dc:creator><pubDate>Sun, 15 May 2022 23:15:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1653019945496/gDH1MardZ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The MAGMA currency is the currency within world of The Verse, Lairiah. But that isn't all it has been created for, step in the journey of what MAGMA is in it's current form, and where we are taking it in the future.</p>
<p>MAGMA sets out to be a beacon for independents, independent musicians, independent content creators, independent game devs, independent artists, and so much more.</p>
<p>We wanted to create a community for creative individuals and a platform for them to monetize their ideas and creations.</p>
<p>To better understand what we are trying to accomplish, here are some of our products that will utilized MAGMA, offering quick low cost payments across the world.</p>
<p>Explode is our streaming service currently is a proof of concept, allows independent musicians and pod-casters to publish their recordings on the Explode platform. Fans listening can tip the artist, and instantly send MAGMA directly to the artist, all non custodial and peer to peer.</p>
<p>The Verse is a virtual multiverse platform featuring the world of Lairiah and uses MAGMA for the economy. Explode is streaming inside The Verse, exposing the independent musicians and pod-casters to even more potential fans.</p>
<p>The Verse has many ways MAGMA is being used, things like:</p>
<ol>
<li>Buying, leasing and selling property</li>
<li>Developing and designing 3d games and minting custom NFTs as in game content.</li>
<li>Create digital experiences</li>
<li>Own a virtual business or bring you business virtual.</li>
<li>What you can create is only limited by your imagination.</li>
</ol>
<p>MAGMA was first minted on the Algorand blockchain and is currently available on the Algorand blockchain.</p>
]]></content:encoded></item></channel></rss>