diff --git a/docs/learn/architecture/basic-concepts.mdx b/docs/learn/architecture/basic-concepts.mdx index ced316cb..fac96953 100644 --- a/docs/learn/architecture/basic-concepts.mdx +++ b/docs/learn/architecture/basic-concepts.mdx @@ -161,7 +161,7 @@ These use cases exemplify the transformative potential of Autonomous Smart Contr processes across various industries. :::info - Learn more about Autonomous Smart Contracts [here](/docu-dev/docs/learn/autonomous-sc). + Learn more about Autonomous Smart Contracts [here](/docu-dev/docs/learn/asc/autonomous-smart-contract). ::: ## Storage costs diff --git a/docs/learn/asc/autonomous-sc.webp b/docs/learn/asc/autonomous-sc.webp new file mode 100644 index 00000000..47198541 Binary files /dev/null and b/docs/learn/asc/autonomous-sc.webp differ diff --git a/docs/learn/asc/autonomous-smart-contract.mdx b/docs/learn/asc/autonomous-smart-contract.mdx new file mode 100644 index 00000000..7943a1dc --- /dev/null +++ b/docs/learn/asc/autonomous-smart-contract.mdx @@ -0,0 +1,39 @@ +--- +id: autonomous-smart-contract +sidebar_label: Introduction +--- + +# Autonomous Smart Contracts + +## Introduction + +Massa Blockchain introduces a groundbreaking feature known as Autonomous Smart Contracts. +These smart contracts possess a unique capability: they can independently determine their own activation without any external actors. +By the end of this section, you will gain a fundamental understanding of: + +- The limitations of current smart contracts on existing blockchains +- How Massa Blockchain overcomes these limitations by empowering pre-programmed execution +- The inner workings and mechanisms behind autonomous smart contracts +- The use cases enables by autonomous smart contracts + +## Challenges with Existing Smart Contracts + +In today's blockchain landscape, smart contracts face limitations when it comes to automating operations without external triggers. +While automation lies at the heart of numerous industries, particularly in the realm of modern finance, only +certain actions within decentralized finance (DeFi) protocols, such as lending and arbitration, are automated. +However, even these actions are typically executed by off-chain bots. The absence of external calls prevents smart contracts, +as they exist in current public blockchains, from performing automated operations. + +Many decentralized protocols rely on recurrent triggers to ensure their smooth operation. +For example, in decentralized lending protocols, borrowers lock crypto assets as collateral when obtaining loans. +If the value of the collateralized asset drops below a specified threshold, the borrower's position becomes under-collateralized +and requires immediate action. To maintain the integrity of the protocol, such positions must be liquidated. Currently, +these liquidations are executed by organizations or individuals who run bots, often on centralized cloud services. + +## The Need for a Reliable Automation Mechanism + +The reliance on recurrent triggers is a prevalent requirement across numerous applications. +Consequently, significant time and effort have been invested in developing more dependable networks of bots to ensure +the timely execution of transactions. +However, since these solutions operate off-chain, there is no guarantee that the execution will be triggered effectively. +In cases where bots fail to execute transactions, decentralized protocols face risks, as do the applications built on top of them. diff --git a/docs/learn/asc/on-blockchain.mdx b/docs/learn/asc/on-blockchain.mdx new file mode 100644 index 00000000..ea71e86a --- /dev/null +++ b/docs/learn/asc/on-blockchain.mdx @@ -0,0 +1,36 @@ +--- +id: massa-asc +sidebar_label: Autonomous Smart Contracts +--- +# Massa's Autonomous Smart Contracts + +Massa's Autonomous Smart Contracts address the challenges of reliability, sophistication, and centralization that plague dApps +seeking to offer automated smart-contract execution on behalf of their users. +These innovative smart contracts introduce the ability to self-wake, granting them the power to autonomously perform arbitrary operations. +For instance, they can be programmed to trigger specific calls when predefined exchange rate targets are met in a decentralized exchange. + +## The Mechanism within Massa Network + +![Autonomous SCs](./autonomous-sc.webp) + +Standard operations are sent to an *operation pool* and are executed when they are included in a block. The cost of +execution is paid by the sender of the operation when the operation is executed. + +Autonomous smart contracts works by emitting messages which will schedule the execution. Those messages are emitted +by smart contracts, through operations sent by users or by autonomous operations. Messages are then stored in an +*asynchronous pool*. Contrary to standard operations, the gas required by autonomous smart contracts is paid upfront. + +The asynchronous pool is deterministic by nature as it’s filled with messages that ultimately come from operations +included in blocks, which are processed by every node of the network. The pool has a finite size and messages +are removed based on the fees and after a certain number of slots if they were not executed. + +As for normal operations, the number of autonomous operations that can be executed is limited, through a maximum amount +of gas. In practice, it’s possible that your message isn’t executed at the slot that you want, but in a later slot, +when there is enough space to include your message. If you want your message to be included as soon as possible, the +fees needs to be higher than other messages (just like standard operations). + +Messages are ordered using the following formula: + +$(Reverse(Ratio(msg.fee, max(msg.max_gas,1))), emission\_slot, emission\_index),$ + +where $emission\_index$ is an index that differentiate multiple messages created in the same slot. diff --git a/docs/learn/asc/use-cases.mdx b/docs/learn/asc/use-cases.mdx new file mode 100644 index 00000000..dd79878c --- /dev/null +++ b/docs/learn/asc/use-cases.mdx @@ -0,0 +1,42 @@ +--- +id: use-cases +sidebar_label: Use-cases +--- +# Use-cases & Applications + +Autonomous smart contracts offers a wide range of compelling use-cases that were either impossible, too costly, or risky to do with benchmark are met. + +Here are some of the best use cases for autonomous smart contracts: + +1. **Decentralized Finance (DeFi)**: Autonomous smart contracts can revolutionize DeFi applications by enabling automated and self-executing actions. Some notable use cases include: + - Automated liquidations: Smart contracts can automatically trigger the liquidation of under-collateralized positions in lending protocols when predetermined thresholds are breached. + - Yield farming strategies: Contracts can autonomously perform yield farming strategies, automatically swapping and reinvesting tokens based on predefined conditions. + - Dynamic portfolio rebalancing: Smart contracts can automatically adjust portfolio allocations based on market conditions, ensuring desired asset ratios are maintained. + +2. **Supply Chain Management**: Autonomous smart contracts have the potential to streamline supply chain processes by automating specific actions triggered by predefined conditions. Key use cases include: + - Automatic inventory management: Contracts can initiate purchase orders or trigger production when inventory levels reach predefined thresholds, ensuring optimal stock levels. + - Quality control and compliance: Smart contracts can autonomously perform quality checks and audits based on predefined criteria, ensuring compliance with standards and regulations. + +3. **Insurance Claims**: Autonomous smart contracts can revolutionize the insurance industry by automating claims processes. Notable use cases include: + - Instant claims settlement: Contracts can automatically trigger claim payments when specific conditions, such as verified damage or loss, are met, accelerating the claims settlement process. + - Parametric insurance: Smart contracts can leverage external data feeds, such as weather or seismic information, to autonomously determine and process claims without human intervention. + +4. **Gaming and NFTs**: Autonomous smart contracts can bring enhanced functionality and interactivity, and cost-reduction in on-chain execution, to gaming and non-fungible token (NFT) platforms. Key use cases include: + - Dynamic NFTs: Contracts can imbue NFTs with evolving characteristics or abilities based on predefined conditions, creating captivating and unique gaming experiences. + - Automated auctions: Contracts can autonomously initiate and manage auctions for rare items, with bidding and settlement executed automatically when predetermined criteria are met. + +5. **Decentralized Autonomous Organizations (DAOs)**: Autonomous smart contracts are instrumental in enabling self-governance and decision-making within DAOs. Notable use cases include: + - Voting and governance: Contracts can autonomously trigger voting processes based on predefined conditions, empowering token holders to participate in important decision-making. There are various applications for this: from voting in local communities to democratic processes in corporate governance. + - Automated fund management: Smart contracts can autonomously allocate funds, distribute dividends, or trigger investments based on predefined rules and performance metrics. + +6. **Real Estate Transactions**: Smart contracts can streamline various aspects of real estate transactions, increasing efficiency and reducing the need for intermediaries. Key use cases include: + - Escrow and payment automation: Contracts can securely hold funds in escrow and automatically release them when specific conditions, such as successful property transfer or completion of milestones, are met. + - Streamlined rental agreements: Contracts can automate rental payments, manage security deposits, and enforce the terms and conditions stipulated in the agreement. + +These examples illustrate just a few of the many compelling use cases for autonomous smart contracts. +The self wake-up functionality empowers automated processes, reduces reliance on intermediaries, and enhances efficiency and +transparency across diverse industries. + +## Going further + +If you want to go further and start coding your own autonomous smart contract, head to the [Build section](/docs/build/home). diff --git a/docs/learn/autonomous-sc.mdx b/docs/learn/autonomous-sc.mdx deleted file mode 100644 index 4642920f..00000000 --- a/docs/learn/autonomous-sc.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -id: autonomous-sc -sidebar_label: Autonomous Smart Contracts ---- - -# Autonomous Smart Contracts - -Improve significantly: https://docs.massa.net/en/latest/general-doc/autonomous-sc.html \ No newline at end of file diff --git a/docs/tutorial/trading-bot.mdx b/docs/tutorial/trading-bot.mdx index a8606f09..52af3c62 100644 --- a/docs/tutorial/trading-bot.mdx +++ b/docs/tutorial/trading-bot.mdx @@ -5,7 +5,7 @@ sidebar_label: Trading bot # Autonomous Trading Bot -This video is a great example of how to use Massa's [autonomous smart contracts](/docs/learn/autonomous-sc) to build a trading bot that will automatically buy and sell tokens on the [Dusa](https://dusa.io) decentralized exchange (DEX). +This video is a great example of how to use Massa's [autonomous smart contracts](/docs/learn/asc/autonomous-smart-contract) to build a trading bot that will automatically buy and sell tokens on the [Dusa](https://dusa.io) decentralized exchange (DEX). This tutorial covers all the tooling required to build a decentralized application on the Massa blockchain, from the smart contract to the front-end interface, making it a great way to get started with Massa. diff --git a/sidebars.js b/sidebars.js index 96b8c73c..410d3f28 100644 --- a/sidebars.js +++ b/sidebars.js @@ -51,6 +51,26 @@ const sidebars = { type: "doc", id: "learn/architecture/storage-costs", }, + { + type: "html", + value: "