-
Notifications
You must be signed in to change notification settings - Fork 3
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 #128 from effectai/feat/docs-basics
Feat/docs basics
- Loading branch information
Showing
22 changed files
with
646 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,64 @@ | ||
# Terminology | ||
|
||
## Accounts | ||
|
||
Antelope accounts are different compared to other EVM blockchains, and other kinds of blockchains in the space. | ||
You still will be working with a private key, but your private key can be linked to several accounts. | ||
|
||
Here's a quick synopsis from the (Antelope documentation)[https://docs.antelope.io/docs/latest/protocol/accounts_and_permissions/]: | ||
|
||
> An account identifies a participant in an Antelope blockchain. A participant can be an individual or a group depending on the assigned permissions within the account. Accounts also represent the smart contract actors that push and receive actions to and from other accounts in the blockchain. Actions are always contained within transactions. A transaction can be one or more atomic actions. | ||
> Permissions associated with an account are used to authorize actions and transactions to other accounts. Each permission is linked to an authority table which contains a threshold that must be reached in order to allow the action associated with the given permission to be authorized for execution. The following diagram illustrates the relationship between accounts, permissions, and authorities. | ||
Simply put, an account contains a collection of permissions, and each permission is linked to an authority table to allow certain actions to be exectued. | ||
As mentioned above, a private key can be linked to several accounts, and each account can have different permissions. | ||
|
||
The anatomy of an antelope account is as follows: | ||
|
||
- `name`: The name of the account | ||
- `permissions`: The permissions associated with the account | ||
- `keys`: The keys associated with the account (private and corresponding public keys) | ||
|
||
## Wallets | ||
|
||
There are several wallets that you can use to interact with Antelope blockchains, some of them are: | ||
We recomend using Unicove and Anchor Wallet, as they are the most user friendly wallets. | ||
|
||
- [Unicove](https://unicove.com/) | ||
- [Anchor Wallet](https://www.greymass.com/anchor) | ||
- [TokenPocket](https://www.tokenpocket.pro/) | ||
- [Wombat](https://getwombat.io/) | ||
|
||
## Contracts | ||
|
||
These are the important smart contracts that are used in the Effect Network. | ||
The important contract for developing on Effect Network are: | ||
|
||
- tasks | ||
- token | ||
- vaccount | ||
|
||
With these contracts you can create tasks, and retrieve virtual accounts. | ||
|
||
These are the contracts that are deployed on the Jungle4 testnet for the Effect Network. | ||
[https://jungle4.eosq.eosnation.io/](https://jungle4.eosq.eosnation.io/) | ||
|
||
- tasks: [effecttasks2](https://jungle4.eosq.eosnation.io/account/effecttasks2) | ||
- token: [efxtoken1112](https://jungle4.eosq.eosnation.io/account/efxtoken1112) | ||
- stake: [efxstake1111](https://jungle4.eosq.eosnation.io/account/efxstake1111) | ||
- feepool: [efxfeepool11](https://jungle4.eosq.eosnation.io/account/efxfeepool11) | ||
- proposals: [efxproposals](https://jungle4.eosq.eosnation.io/account/efxproposals) | ||
- vaccount: [efxaccount11](https://jungle4.eosq.eosnation.io/account/efxaccount11) | ||
|
||
|
||
These are the contracts that are depoloyed on the EOS mainnet for the Effect Network. | ||
[https://www.bloks.io/](https://www.bloks.io/) | ||
|
||
|
||
- tasks: [force.efx](https://www.bloks.io/account/force.efx) | ||
- token: [effecttokens](https://www.bloks.io/account/effecttokens) | ||
- stake: [efxstakepool](https://www.bloks.io/account/efxstakepool) | ||
- feepool: [feepool.efx](https://www.bloks.io/account/feepool.efx) | ||
- proposals: [daoproposals](https://www.bloks.io/account/daoproposals) | ||
- vaccount: [vaccount.efx](https://www.bloks.io/account/vaccount.efx) | ||
- dao: [theeffectdao](https://www.bloks.io/account/theeffectdao) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,103 @@ | ||
# Types [Glossary of Types in effect-js.] | ||
# Types [Glossary of Types in the effect sdk.] | ||
|
||
## Campaign | ||
|
||
[See Type](https://github.com/effectai/effect-js/blob/main/src/types/campaign.ts) | ||
|
||
## Client Options | ||
|
||
The ClientOpts interface is used to define the options that can be passed to the EffectAI Client constructor. | ||
|
||
```typescript | ||
interface ClientOpts { | ||
ipfsCacheDurationInMs?: number | null; | ||
fetchProvider?: FetchProviderOptions; | ||
cacheImplementation?: Cache; | ||
} | ||
``` | ||
|
||
As we can see, the ClientOpts interface has three optional properties: | ||
|
||
## `ipfsCacheDurationIMs` | ||
|
||
This property is used to set the cache duration for the IPFS data. | ||
The default value is 600_000 milliseconds; 10 minutes. | ||
|
||
## `fetchProvider` | ||
|
||
This property is used to set the fetch provider. | ||
This is needed because of the different runtimes availalbe to Java Script. | ||
For example, in older versions of Node.js, the fetch API is not available. | ||
For older versions of Node.js, you can use the [`node-fetch` ](https://github.com/node-fetch/node-fetch) package. | ||
|
||
Since Node.js v18.0.0, the fetch API is available by default. | ||
|
||
In the browser fetch is generally available, and is available on the `window.fetch` object. | ||
You can read more about it here: [MDN Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) | ||
|
||
Other serverside Java Script runtimes such as [Bun](https://bun.sh/) and (Deno)[https://deno.com/] already have fetch available on the global `fetch` object. | ||
|
||
## `cacheImplementation` | ||
|
||
This property is used to set the cache implementation. | ||
There are three different cache mechanigms abailable in the EffectAI SDK. | ||
First of all, "IDBCache", "LocalStorageCache", "MemoryCache". | ||
Any of these can be passed to the `cacheImplementation` property while instanlizing the EffectAI Client. | ||
|
||
```typescript | ||
import { createClient, IDBCache, LocalStorageCache, MemoryCache } from '@effectai/sdk' | ||
const client = createClient({ | ||
cacheImplementation: new IDBCache() // or new LocalStorageCache() or new MemoryCache() | ||
}) | ||
``` | ||
|
||
[See Type](https://github.com/effectai/effect-js/blob/main/src/client.ts) | ||
|
||
## Asset | ||
|
||
### Description | ||
|
||
Some functions with the `@effectai/sdk` package will return a `Asset` object. | ||
This object contains information about tokens on the blockchain and contain information such as the symbol, precision, and amount. | ||
|
||
An example for the `Asset` object is as follows: | ||
|
||
|
||
```json | ||
{ | ||
"precision": 4, | ||
"symbol": "EFX", | ||
"units": 10000, | ||
"value": 1 | ||
} | ||
``` | ||
|
||
Read more about the `Asset` object here: | ||
https://wharfkit.com/docs/antelope/asset | ||
|
||
## Transaction Result | ||
|
||
### Description | ||
|
||
Some functions with the `@effectai/sdk` package will return a `TransactionResult` object. | ||
This object contains the transaction hash and the transaction receipt. | ||
|
||
The interface for the `TransactionResult` object is as follows: | ||
|
||
|
||
```ts | ||
interface TransactResult { | ||
chain: ChainDefinition | ||
request: SigningRequest | ||
resolved: ResolvedSigningRequest | undefined | ||
response?: { [key: string]: any } | ||
revisions: TransactRevisions | ||
signatures: Signature[] | ||
signer: PermissionLevel | ||
transaction: ResolvedTransaction | undefined | ||
} | ||
``` | ||
|
||
Read more about the `TransactionResult` object here: | ||
|
||
https://wharfkit.com/docs/session-kit/transact-result |
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 |
---|---|---|
@@ -1,6 +1,67 @@ | ||
# Introduction | ||
|
||
As described in the previous section, with campaigns, a template is a blueprint that allows you to input data and display it in a specific format. They are the interface used by the workers of EffectAI to interact with the data and perform the tasks required by the client. | ||
|
||
In this section, we will provide an overview of the template engine, explain the basic concepts and components of a template, and guide you through the process of creating your own template. | ||
|
||
We will be creating a simple template that lets users create bounding boxes around objects in an image. This will be done with the help of the open-source data annotation tool called [Label Studio](https://labelstud.io/). | ||
|
||
## What is a Template? | ||
|
||
A template is some HTML, CSS, and JavaScript code that defines the structure and layout of the data that is to be displayed. It's not a standard HTML5 template that uses the HTML specifications. The template engine is custom-built to handle the data that is to be displayed in the template. | ||
|
||
There is an existing HTML document, with a head and body tag defined with the requirements for EffectAI. What we need is to add what you would usually add in the body of the document. | ||
|
||
So the simplest template, which is just a text template, would look like this: | ||
|
||
```html | ||
<div> | ||
<p>Hello World!</p> | ||
</div> | ||
``` | ||
|
||
This is a simple template that displays the text "Hello World!" in a paragraph tag. But the main issue here is that we still need to load in dynamic data from a data source so that each task is different. | ||
|
||
## Parameterizing Templates: Placeholders | ||
|
||
In order to be able to use the same template for different data, we need to parameterize the template. This means that we need to define placeholders in the template that will be replaced with the actual data when the template is rendered. | ||
|
||
The way this is done in EffectAI is by using the `${}` syntax. This is similar to the way you would use template literals in JavaScript. | ||
|
||
For example, if we want to display the name of a person in the template, we would define a placeholder like this: | ||
|
||
```html | ||
<div> | ||
<p>Hello ${name}!</p> | ||
</div> | ||
``` | ||
|
||
When the template is rendered, the `${name}` placeholder will be replaced with the actual name of the person. | ||
|
||
## Submitting Templates and Retrieving Results | ||
|
||
So now we understand how to input data into the template, but how do we get results back? Workers on EffectAI will get a rendered template with the data inputted into the template. The worker will then perform the task required by the client and submit the result. | ||
|
||
Submitting is a standard submit event in HTML, but the data is saved in the EffectAI smart contracts. | ||
|
||
Here's an example of a form with an input field and a submit button: | ||
|
||
```html | ||
<h2>Placeholder example: ${placeholder}</h2> | ||
<input type="text" required placeholder="'name' attribute is required on input fields" name="test" /> | ||
<input type="submit" /> | ||
``` | ||
|
||
When we input the text "World" into the text field and submit this, we get the following submission: | ||
|
||
```json | ||
{ | ||
"test": "World" | ||
} | ||
``` | ||
|
||
## Creating Your Own Template | ||
|
||
You can try out the templates for yourself by inputting them into [EffectAI's template preview tool](https://app.effect.network/preview/). | ||
|
||
## What is a template? | ||
|
||
## Creating Your own template |
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,46 @@ | ||
# Label Studio example | ||
|
||
Here we will show an example of how to use [Label Studio](https://labelstud.io/) to label images for object detection. | ||
|
||
![Example](/labelstudioocr.png) | ||
|
||
As discussed before we will be using the Label Studio to create a labeling task for object detection. | ||
Here is an example of how to use Label Studio to create a labeling task for object detection. | ||
We have some HTML tags, that contain style sheets, the div that will be the container for Label Studio, library and scripts to initialize Label Studio. | ||
|
||
|
||
## Template | ||
```html | ||
// [!include ~/snippets/templates/index.html] | ||
``` | ||
|
||
## Input Schema | ||
|
||
Note that you can also define the input and output schema for a given template. | ||
This will allow you to define the structure of the data that will be used in the labeling task and the output that will be generated by the annotators. | ||
|
||
{/* TODO figure out how to shorten this schema and make it more readable */} | ||
|
||
```json | ||
// [!include ~/snippets/templates/input_schema.json] | ||
``` | ||
## Example output data | ||
|
||
This is what the output data will look like after the annotators have labeled the images. | ||
|
||
{/* TODO figure out how to shorten this example and make it more readable */} | ||
|
||
|
||
```json | ||
// [!include ~/snippets/templates/example.json] | ||
``` | ||
|
||
## Script | ||
|
||
You can use the following script to initialize Label Studio and create a labeling task for object detection. | ||
This script uses [bun.sh](https://bun.sh/). | ||
|
||
```typescript | ||
// [!include ~/snippets/templates/script.ts] | ||
``` | ||
|
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
Oops, something went wrong.