Skip to content

Commit

Permalink
Merge pull request #322 from Akord-com/add-akord
Browse files Browse the repository at this point in the history
Add Akord to the docs
  • Loading branch information
twilson63 committed Jun 4, 2024
2 parents 1546206 + a00a245 commit aa5a8fb
Show file tree
Hide file tree
Showing 10 changed files with 562 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/src/.vuepress/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const getI18NSidebar = (langCode) => [
text: "Turbo-SDK",
link: get_i18n_link(langCode, "/guides/posting-transactions/turbo")
},
{
text: "Akord",
link: get_i18n_link(langCode, "/guides/posting-transactions/akord")
},
],
},
{
Expand Down Expand Up @@ -231,6 +235,10 @@ const getI18NSidebar = (langCode) => [
text: "arseeding-js",
link: get_i18n_link(langCode, "/guides/deploying-manifests/arseeding-js"),
},
{
text: "Akord",
link: get_i18n_link(langCode, "/guides/deploying-manifests/akord"),
},
],
},
{
Expand Down Expand Up @@ -305,6 +313,17 @@ const getI18NSidebar = (langCode) => [
{
text: get_i18n_str(langCode, "guides-atomic-asset"),
link: get_i18n_link(langCode, "/guides/smartweave/atomic-assets/index"),
collapsible: false,
children: [
{
text: "using Akord",
link: get_i18n_link(langCode, "/guides/smartweave/atomic-assets/akord.md"),
},
{
text: "using ArDrive CLI",
link: get_i18n_link(langCode, "/guides/smartweave/atomic-assets/ardrive-cli.md"),
}
],
},
{
text: get_i18n_str(langCode, "guides-atomic-token"),
Expand Down
1 change: 1 addition & 0 deletions docs/src/concepts/post-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ An example of how to post a 100KB or less bundled transaction with an Arweave wa
- [irys.xyz](../guides/posting-transactions/irys.md) example
- [dispatch](../guides/posting-transactions/dispatch.md) example
- [arseeding-js](../guides/posting-transactions/arseeding-js.md) example
- [akord](../guides/posting-transactions/akord.md) example
2 changes: 2 additions & 0 deletions docs/src/guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Snack-sized guides for the building blocks of the Permaweb
- [arweave.app](deploying-manifests/arweave-app.md)
- [ardrive](deploying-manifests/ardrive.md)
- [irys.xyz](deploying-manifests/irys.md)
- [Akord](deploying-manifests/akord.md)
- [Deploying PSTs](deploying-psts.md)
- [GraphQL](querying-arweave/queryingArweave.md)
- [ArDB](querying-arweave/ardb.md)
Expand All @@ -26,6 +27,7 @@ Snack-sized guides for the building blocks of the Permaweb
- [Irys Query Package](irysQueryPackage.md)
- SmartWeave
- [Atomic Assets](smartweave/atomic-assets/index.md)
- [using Akord](smartweave/atomic-assets/akord.md)
- [using ArDrive CLI](smartweave/atomic-assets/ardrive-cli.md)
- [Atomic Tokens](atomic-tokens/intro.md)
- [Vouch](vouch.md)
Expand Down
168 changes: 168 additions & 0 deletions docs/src/guides/deploying-manifests/akord.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
## with Akord CLI

You can generate manifests using [Akord CLI](https://github.com/Akord-com/akord-cli).

### Before you get started

> Requires NodeJS - https://nodejs.org
<CodeGroup>
<CodeGroupItem title="NPM">

```console
npm install -g @akord/akord-cli
```

</CodeGroupItem>
<CodeGroupItem title="YARN">

```console
yarn global add @akord/akord-cli
```

</CodeGroupItem>
</CodeGroup>

### Login to Akord (you can create an account [here](https://v2.akord.com/signup))
Once you have the CLI installed, log in by following the prompts to authenticate with your Akord username and password.

```console
akord login {your_email_address}
```

### Choose your vault
You'll need a vault id of your public vault to generate the manifest. To list your vaults:

```console
akord vault:list
```

### Generate manifest
Now that you are logged in and you have a vault id, you can generate the manifest for your files and contents. \
If you do not have "index.html" file in your vault, you can provide a custom index:

```console
akord manifest:generate {vaultId} --index "my-custom-index.html"
```

After generating the manifest, a file named manifest.json will appear in your vault. Once it's confirmed on the Arweave blockchain and propagated by the gateways, your public vault will be available on the permaweb under following link: https://arweave.net/{uri}

## with AkordJS

Alternatively, you can generate your manifests using [AkordJS](https://github.com/Akord-com/akord-js) package.

### Before you get started

> Requires NodeJS - https://nodejs.org
<CodeGroup>
<CodeGroupItem title="NPM">

```console
npm install @akord/akord-js
```

</CodeGroupItem>
<CodeGroupItem title="YARN">

```console
yarn add @akord/akord-js
```

</CodeGroupItem>
</CodeGroup>

### Let's generate manifest

### Generate a manifest automatically from files inside a vault
```js
import { Akord, Auth } from '@akord/akord-js'

// First, let's initialize Akord instance
// In order to use AkordJS, you first need an Akord account.
// Sign up for Akord here: https://v2.akord.com/signup
const { wallet } = await Auth.signIn(email, password);
const akord = await Akord.init(wallet);

// Let's create a public vault to contain our files
const { vaultId } = await akord.vault.create("My hello world app", { public: true });

// Let's upload a Hello world html file
const { stackId } = await akord.stack.create(
vaultId,
["<html><body><h1>Hello World</h1></body></html>"],
{ name: "index.html", mimeType: "text/html" }
);

// Let's generate a manifest
const { uri } = await akord.manifest.generate(vaultId);
// In few minutes, you will be able to access your manifest here: https://arweave.net/{uri}
```


### Upload your own manifest file manually
```js
import { Akord, Auth } from '@akord/akord-js'

// First, let's initialize Akord instance
// In order to use AkordJS, you first need an Akord account.
// Sign up for Akord here: https://v2.akord.com/signup
const { wallet } = await Auth.signIn(email, password);
const akord = await Akord.init(wallet);

// let's define our manifest
const manifest = {
"manifest": "arweave/paths",
"version": "0.1.0",
"index": {
"path": "index.html"
},
"paths": {
"index.html": {
"id": "cG7Hdi_iTQPoEYgQJFqJ8NMpN4KoZ-vH_j7pG4iP7NI"
},
"js/app.js": {
"id": "fZ4d7bkCAUiXSfo3zFsPiQvpLVKVtXUKB6kiLNt2XVQ"
},
"css/style.css": {
"id": "fZ4d7bkCAUiXSfo3zFsPiQvpLVKVtXUKB6kiLNt2XVQ"
},
"css/mobile.css": {
"id": "fZ4d7bkCAUiXSfo3zFsPiQvpLVKVtXUKB6kiLNt2XVQ"
},
"assets/img/logo.png": {
"id": "QYWh-QsozsYu2wor0ZygI5Zoa_fRYFc8_X1RkYmw_fU"
},
"assets/img/icon.png": {
"id": "0543SMRGYuGKTaqLzmpOyK4AxAB96Fra2guHzYxjRGo"
}
}
};

// Let's create a public vault to contain the manifest
const { vaultId } = await akord.vault.create("My manifest", { public: true });

const { uri } = await akord.manifest.generate(vaultId, manifest);
// In few minutes, you will be able to access your manifest here: https://arweave.net/{uri}
```

### Congrats!

Once the transaction is accepted on Arweave network (it takes 5-15 minutes on average), \
you can access the permaweb URL in your web browser by replacing {uri} with your unique manifest tx id:
https://arweave.net/{uri}

## with Akord web app

From the [web app](https://v2.akord.com/login) it's also possible to create the manifest and add it to your vault by selecting "Add Manifest" from the "+" button inside your public permanent vault.

The action will automatically create a manifest for all of the files & folders within the vault.

You can download your manifest and view it in the media gallery by clicking the title in the vault.

It's as simple as that!

## Resources & further reading
- [Generating manifests in Akord vaults](https://docs.akord.com/nft-projects/get-the-arweave-urls)
- [Publishing a website to the permaweb](https://docs.akord.com/api-and-dev-tools/learn/publishing-a-website)
- [AkordJS manifest module](https://github.com/Akord-com/akord-js?tab=readme-ov-file#manifest)
1 change: 1 addition & 0 deletions docs/src/guides/posting-transactions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Please the the examples attached to Posting Transactions Core Concept.
- [dispatch](/guides//posting-transactions/dispatch.md) example
- [arseeding-js](/guides//posting-transactions/arseeding-js.md) example
- [turbo](/guides//posting-transactions/turbo.md) example
- [akord](/guides/posting-transactions/akord.md) example
104 changes: 104 additions & 0 deletions docs/src/guides/posting-transactions/akord.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Posting Transactions using Akord

Posting transactions to Arweave can be done directly via Akord API, no new dependencies in your code, just a simple HTTP.

## Getting Started

You just need two things to get started:

- [Create your Akord account (100 MB free)](https://v2.akord.com/signup)

- [Get your API key here](https://v2.akord.com/account/developers)

## HTTP API

```js
import fs from "fs";

const data = fs.readFileSync('PATH_TO_YOUR_FILE_HERE');

// add some custom tags to the transaction
const tags = [
{
name: "Title",
value: "My first Arweave file"
},
{
name: "Type",
value: "image"
}
];

// encode tags to base64
const jsonTags = JSON.stringify(tags);
const encodedTags = Buffer.from(jsonTags).toString('base64');

const response = await fetch('https://api.akord.com/files', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Api-Key': 'YOUR_API_KEY_HERE',
'Content-Type': 'YOUR_FILE_MIME_TYPE_HERE', // see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
'Tags': encodedTags
},
body: data
});
const body = await response.json();
console.log(body);
```

That's it! You just uploaded the file to Arweave. Here is the example response body:

```json
{
"id": "a6f1fbfc-403d-4607-b648-4b949fdd50bd",
// technical id of upload. can be used to get metadata of the upload or file binary from Akord cache
"mimeType": "image/jpeg", // depends on content-type of upload, goes as a tag
"sizeInBytes": 437432,
"cloud": {
"uri": "a6f1fbfc-403d-4607-b648-4b949fdd50bd", // same as ID
"url": "https://api.akord.com/files/a6f1fbfc-403d-4607-b648-4b949fdd50bd", // url to binary served from Akord cache
},
"tx": {
"id": "LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", // fixed ID of Arweave transaction (ANS-104 data item ID)
"status": "scheduled", // indicates where is your file in Arweave bundling context:
// scheduled - file is in Akord cache and is scheduled for ANS-104 bundling
// verification - file is being verified for malicious content
// blocked - file is recognized as malicious, won't go to Arweave
// bundled - file is bundled and is scheduled for posting
// pending - file was posted to Arweave
// committed - file is confirmed on Arweave
// rejected - this indicates a technical problem with our bundling service
"tags": [
{
"name": "Title",
"value": "My first Arweave file"
},
{
"name": "Type",
"value": "image"
},
{
"name": "Content-Type",
"value": "image/jpeg"
}
], // your Arweave tags appended to transaction
"statusUrl": "https://api.akord.com/files/a6f1fbfc-403d-4607-b648-4b949fdd50bd/status",
// check file status endpoint, returns similar JSON schema
"gatewayUrls": [
"https://arweave.net/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E",
// this url will only work when file is in 'committed' status
"https://akrd.net/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E"
// Akord instance of Arweave gateway - this url will work always, even right after upload since it falls back to Akord cache when file is not yet on Arweave
],
"viewblockUrl": "https://viewblock.io/arweave/tx/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", // see your file on ViewBlock - this url will only work when file is in 'committed' status & indexed by ViewBlock
"info": "Transaction is visible on the blockchain indexers when in the \"committed\" status.",
}
}
```

## Resources
- For an overview of all the ways you can post transactions, see the [Posting Transactions](../../concepts/post-transactions.md) section of the cookbook.
- More examples of how to upload files to Arweave with Akord API can be found [here](https://docs.akord.com/api-and-dev-tools/quickest-way-to-upload-to-arweave).
- Full documentation of Akord API can be found [here](https://api.akord.com/docs).
- More about bundles [ANS-104 Standard](https://specs.g8way.io/#/view/xwOgX-MmqN5_-Ny_zNu2A8o-PnTGsoRb_3FrtiMAkuw)
Loading

0 comments on commit aa5a8fb

Please sign in to comment.