-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from Akord-com/add-akord
Add Akord to the docs
- Loading branch information
Showing
10 changed files
with
562 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.