Skip to content

Commit

Permalink
Update AEWeb documentation (#31)
Browse files Browse the repository at this point in the history
* aeweb examples use the new format

* aeweb deploy page

* Add jsonc for json with comments

---------

Co-authored-by: Samuel Manzanera <samuelmanzanera@protonmail.com>
Co-authored-by: Samuel Manzanera <samuelmanzanera@users.noreply.github.com>
  • Loading branch information
3 people committed May 26, 2023
1 parent c9ee340 commit f9b6ee2
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 23 deletions.
75 changes: 75 additions & 0 deletions docs/participate/aeweb/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
id: deploy
title: AEWeb - Deploy
sidebar_label: Deploy
sidebar_position: 3
---


# AEWeb CLI (Command-Line Interface)

Repository: https://github.com/archethic-foundation/aeweb-cli

This tool, built with NodeJS, can be used to deploy files and websites to the Archethic blockchain.
Once installed, as instructed in the README, the `aeweb` command is available.

## aeweb generate-address

This command is used to generate an address from a seed.

:::info Use case
You might use this on TestNet for example, to determine an address to use the [faucet](https://testnet.archethic.net/faucet) on.
:::


```bash
$ aeweb generate-address --seed myseedphrase --index 0
00005da88a4adaf5b40c958a20db981bd168008e03efbb7fc9d35e11be182a0d3065
```



## aeweb deploy

This command is used to deploy the content of a folder or a single file. It will create the [transactions](./how-it-works), estimate the fees and, after confirmation, will write the transactions on the network.

Parameters:
- `seed` The keychain seed, used to prove you are the owner of the transaction chain used to pay the fees
- `endpoint` https://testnet.archethic.net | https://mainnet.archethic.net | http://127.0.0.1:4000
- `path` The path of the folder/file to upload


```
$ aeweb deploy --seed myseedphrase --endpoint https://testnet.archethic.net --path ./website
Connecting to https://testnet.archethic.net
Creating file structure and compress content...
Creating transactions ...
Estimating fees ...
Total Fee Requirement would be : 2.58933391 UCO ( $ 0.23 | € 0.22), for 3 transactions.
Do you want to continue. (yes/no) yes
Sending 3 transactions...
Transaction 1...
Waiting transaction validation...
Transaction confirmed !
See transaction in explorer: https://testnet.archethic.net/explorer/transaction/000013c531...
-----------
Transaction 2...
Waiting transaction validation...
Transaction confirmed !
See transaction in explorer: https://testnet.archethic.net/explorer/transaction/0000a78a35...
-----------
Transaction 3...
Waiting transaction validation...
Transaction confirmed !
See transaction in explorer: https://testnet.archethic.net/explorer/transaction/0000f1126e...
-----------
Website is deployed at: https://testnet.archethic.net/api/web_hosting/00007d9167...
```

:::info There Can Be Only One
**There can only be a single deployment per seed.** Which makes it possible to update it by running the exact same command. The endpoint of your deployment will not change.

If you need to deploy another website, use another seed (and transfer funds to it via the Wallet app).
:::


3 changes: 2 additions & 1 deletion docs/participate/aeweb/dns.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
id: dns
title: AEWeb (DNS)
title: AEWeb - Domain names
sidebar_label: Domain Names
sidebar_position: 2
---

DNS (Domain Name System) is a mechanism which resolves websites names to server IP addresses, making website's URL nicer.
Expand Down
51 changes: 29 additions & 22 deletions docs/participate/aeweb/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,30 @@ The reference transaction's address will become the address of the website manag
```json
{
"aewebVersion": 1,
"hashFunction": "sha-1",
"metaData": {
"index.html": {
"addresses": ["0FB27DAC...."],
"size": 68420,
"hash": "ABC123F...",
"encoding": "gzip",
"size": "10000",
"hash": "0df1Acd..."
"addresses": ["0FB27DAC...."]
},
"scripts/main.js": {
"addresses": ["0AC1BFA9..."],
...
},
}
"size": 255121,
"hash": "01AB2CD...",
"encoding": "gzip",
"addresses": ["0AC1BFA9..."]
}
}
}
```

The other transactions will contain the content of the files
The other transactions (called `data`) will contain the content of the files encoded in base64

```json
{
"index.html": "b298kJKFS98dj7Xdnsq...." // base64 of the file's content
"index.html": "b298kJKFS98dj7Xdnsq....",
"scripts/main.js": "aGVsbG8gd29ybGQ="
}
```

Expand All @@ -76,41 +80,44 @@ For example, you could have a website which contains: 5 files:

1. Reference:

```json
```jsonc
{
"aewebVersion": 1,
"hashFunction": "sha-1",
"metaData": {
"index.html": {
"addresses": ["0ac7fj..."],
...
"addresses": ["0ac7fj..."]
},
"app.css": {
"addresses": ["0ac7fj..."],
"assets/app.css": {
...
"addresses": ["0ac7fj..."]
},
"image.jpg": {
"addresses": ["0ac7fj...", "1fb2ha..."],
"assets/image.jpg": {
...
}
// image.jpg is too big to fit in a single data transaction
"addresses": ["0ac7fj...", "1fb2ha..."]
}
}
```
2. HTML + CSS + Image (chunked by 30%)
```json
```jsonc
// data transaction: "0ac7fj..."
{
"index.html": "...",
"app.css": "..."
"image.jpg": "..."
"assets/app.css": "..."
"assets/image.jpg": "..."
}
```
3. Image (remaining chunks)
```json
```jsonc
// data transaction: "1fb2ha..."
{
"image.jpg": "..."
"assets/image.jpg": "..."
}
```
Expand All @@ -121,7 +128,7 @@ Any Archethic node expose an API dedicated for the web hosting by AEWeb.
This API takes a reference address as a parameter, and then proceeds to take the path of the file, just like any web server would do.
```sh
https://mainnet.archethic.net/api/web_hosting/0cs19fd13......../image.jpg
https://mainnet.archethic.net/api/web_hosting/0c19fd13......../image.jpg
```
![aeweb_CDN](/img/aeweb_CDN.svg)
Expand Down

0 comments on commit f9b6ee2

Please sign in to comment.