diff --git a/docs/build/massa-web3/deweb/deweb-link.md b/docs/build/massa-web3/deweb/deweb-link.md new file mode 100644 index 000000000..694cc7e2a --- /dev/null +++ b/docs/build/massa-web3/deweb/deweb-link.md @@ -0,0 +1,94 @@ +--- +id: deweb-link +sidebar_label: deweb link +--- + +# Deweb Linking + +## The Problem +In web2, you can link site A to another site B by displaying the URL of site B in site A. +In web3, displaying a link to a decentralized website is not so straightforward. +A deweb website is identified by one (or several) MNS (Massa Name System) domain but you can't just display it inside a `` tag because most browsers don't handle MNS. +To access a deweb site, you have to incorporate its MNS as a subdomain of the URL of a [deweb provider](../../../deweb/provider/setup-public-instance.mdx). But which provider should you choose when you want to create a link to a deweb site ? +The usual way is to hardcode the provider into a URL like this: `.` +The drawback of this approach is that you force the user to use a specific provider. This causes the following issues: +- Add centralization +- If the provider is down, the link is dead +- If the user is running his own provider (see [here](../../../learn/decentralized-web.mdx) and [here](../../../deweb/local-server-config/setup-local-server.mdx)) they can't use it to access the linked site. + + +## Solution +### resolveDeweb function +Massa-web3 provides a function that abstracts provider selection logic: + +```typescript +async function resolveDeweb(uri: string, chainId = CHAIN_ID.Mainnet): Promise +``` + +- uri: The mns domain of the deweb site. Must be suffixed by ".massa" e.g., "dws.massa", "mip.massa"... +- chainId: Optional parameter to specify the network (mainnet, buildnet) on which the website is stored. Default: mainnet. +- Returns: A promise that resolves to an operational URL containing a provider and the mns URI as subdomain. If no providers have been found, return a fallback URL that redirects to a page allowing the user to choose a public provider. + +:::info +This function only works in a browser +::: + +For example, if you want to put a link to [Syntra](https://syntra.massa.network/) (onchain token scheduling Dapp powered by [autonomous smart contracts](../../../learn/asc/intro.mdx)) decentralized website in your website, you can do something like that: +```html +syntra.massa +``` + +Under the hood, `resolveDeweb` function does the following: +- Checks if the current browser natively supports Massa name system. If so, it just returns the URI as passed in parameter: + "`http://.massa/`". +For now, the only browser that supports MNS is [Decentr](https://decentr.net), on Windows OS only. +- If no native support, checks if the [deweb provider plugin](../../../learn/decentralized-web.mdx) of [Massa Station](../../../massaStation/home.mdx) is running. If so, it will return +"`http://.localhost:/`". +e.g. *"massexplo.massa/blocks"* -> *"http://massexplo.localhost:4242/blocks"* (the port is random) +- If no station deweb plugin is available, check if the user is running a [local deweb server](../../../deweb/local-server-config/setup-local-server.mdx). If so, return +"`http://.localhost:8080/ *"http://adm.localhost:8080/options/nodes"* +- If no local deweb server is running, check if the current website, the one displaying the link, is served to the user by a deweb provider. If the website the user is currently visiting is a decentralized one, it means that it is served to him via a deweb provider. So we can use the same provider the user is currently using to serve the deweb website in the link. The function will thus return +"`http://./`". +e.g. *"compound.massa/lend"* -> *"http://compound.massa.network/lend"* +- If none of the previous providers are available, return a fallback URL : +``` +https://deweb.massa.network/deweb_redirect?chain_id=&deweb_url= +``` + +This fallback URL has two query parameters: +- *chain_id*: the chain id used in the `resolveDeweb` function +- *deweb_url*: the URI passed as parameter to `resolveDeweb` + + +### redirection page +The redirection page targeted by the fallback URL is hosted on `deweb.massa` decentralized website. +The page helps the user to get a provider in two means: + +- It allows the user to choose a public deweb provider among a community-maintained list. When the user clicks on the button, the deweb website required by the user is automatically opened in a new tab with the URL of the selected provider. +- The page also suggests the user to access the deweb site by using their own deweb provider. The user is invited to download one of the following tools : + - massa station deweb plugin + - decentr browser if the current OS is Windows + - run the provider server binary localy on the computer. + +![redirection page](./images/deweb_redirect_page.png) + +:::caution +Public providers proposed on the page are not checked. Ensure you trust the provider's admin. +::: + +### useResolveDeweb +`useResolveDeweb` is a react hook available in Massalabs [react ui kit](https://github.com/massalabs/ui-kit) react tool kit. It's a wrapper around `resolveDeweb` function. + +```ts +function useResolveDeweb(Url: string, chainId?: bigint): {resolvedUrl: string, isLoading: boolean, error: string | null} +``` + +Parameters: +- Url: the URL of the deweb site. The URL can be a mns domain with a deweb provider domain. The ".massa" suffix after the mns domain is not required, but the protocol prefix ("http://") does. +- chainId: Same as for `resolveDeweb` + +Result: +- resolvedUrl: the result returned by `resolveDeweb` +- isLoading: Whether the URL creation process is pending or not +- error: eventual error of the process. \ No newline at end of file diff --git a/docs/build/massa-web3/deweb/deweb-overview.md b/docs/build/massa-web3/deweb/deweb-overview.md new file mode 100644 index 000000000..f60203fbf --- /dev/null +++ b/docs/build/massa-web3/deweb/deweb-overview.md @@ -0,0 +1,10 @@ +--- +id: massa-web3-deweb-overview +sidebar_label: Overview +sidebar_position: 1 +--- + +# Overview + +**Massa-web3** provides utility code to help builders integrate the decentralized web paradigm into their products easily. +For more info on Deweb, have a look at [Decentralized Web](./../../../learn/decentralized-web.mdx). \ No newline at end of file diff --git a/docs/build/massa-web3/deweb/images/deweb_redirect_page.png b/docs/build/massa-web3/deweb/images/deweb_redirect_page.png new file mode 100644 index 000000000..5b064046c Binary files /dev/null and b/docs/build/massa-web3/deweb/images/deweb_redirect_page.png differ diff --git a/docs/deweb/upload/overview.mdx b/docs/deweb/upload/overview.mdx index 5726cc648..581ac7384 100644 --- a/docs/deweb/upload/overview.mdx +++ b/docs/deweb/upload/overview.mdx @@ -4,10 +4,11 @@ title: Overview # Overview -To deploy a website on the Massa blockchain, you can use the DeWeb CLI by following the [Uploading a Website](../cli/upload) guide. -This guide provides an overview of the process and the steps to upload your website. +There are two ways to easily deploy and manage your websites on the Massa blockchain: -We are working on additional user-friendly tools to make website deployment accessible to all users, regardless of technical experience. -These upcoming solutions will simplify the upload process, providing an intuitive interface for deploying websites on the Massa blockchain. +- **easy uploader**: It's an online user-friendly tool that makes website deployment and management accessible to all users, regardless of technical experience. +You can use it right now [here](https://dws.massa.network). +- **Deweb CLI**: This is a command-line tool that allows you to upload and manage your sites with more fine-grained control. +To use it, you can follow the [Uploading a Website](../cli/upload) guide that provides an overview of the process and the steps to upload your website. Stay tuned for more updates! diff --git a/docs/node/all-configs.mdx b/docs/node/all-configs.mdx index 12567c4d0..ae6f202ac 100644 --- a/docs/node/all-configs.mdx +++ b/docs/node/all-configs.mdx @@ -17,7 +17,7 @@ instability and/or a complete desynchronization from Massa blockchain. ## Node configuration You can override the default configuration via -the `massa-node/config/config.toml` file. +the `massa-node/base_config/config.toml` file. diff --git a/sidebars.js b/sidebars.js index 0c964bc39..af6e97cc5 100644 --- a/sidebars.js +++ b/sidebars.js @@ -348,6 +348,23 @@ const sidebars = { }, ], }, + { + type: "category", + collapsible: false, + label: "Deweb", + items: [ + { + type: "doc", + id: "build/massa-web3/deweb/massa-web3-deweb-overview", + label: "Overview", + }, + { + type: "doc", + id: "build/massa-web3/deweb/deweb-link", + label: "Deweb Link", + }, + ], + }, ], }, {