Skip to content

Commit

Permalink
Extract quick-start to guides
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Nov 5, 2020
1 parent 76a8749 commit 28f7e6f
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 120 deletions.
122 changes: 2 additions & 120 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,127 +16,9 @@ JavaScript SDK for the revolutionary [æternity] blockchain, targeting the

[develop branch]: https://github.com/aeternity/aepp-sdk-js/tree/develop

## Table of content
- [Æternity's JavaScript SDK](#%C3%86ternitys-Javascript-SDK)
- [Table of content](#Table-of-content)
- [Quick Start](#Quick-Start)
- [1. Install SDK](#1-Install-SDK)
- [A) Simple Usage: with `<script>` tag](#A-Simple-Usage-with-script-tag)
- [B) Advanced Usage: with `npm` or similar](#B-Advanced-Usage-with-npm-or-similar)
- [2. Create an Account](#2-Create-an-Account)
- [A) Using the Command Line](#A-Using-the-Command-Line)
- [B) Using the SDK](#B-Using-the-SDK)
- [3. Give yourself some _AE_ tokens](#3-Give-yourself-some-AE-tokens)
- [4. Import (a chosen Flavor)](#4-Import-a-chosen-Flavor)
- [5. Play with Aetenity's blockchain features](#5-Play-with-Aetenitys-blockchain-features)
- [More: Guides & Examples](#More-Guides--Examples)
- [CLI - Command Line Client](#CLI---Command-Line-Client)
- [Contributing](#Contributing)
- [Change Log](#Change-Log)
- [License](#License)

## Quick Start

### 1. Install SDK
#### A) Simple Usage: with `<script>` tag
For those not using any JS bundling/complilation or compilation technique or tools like [_Codepen_](https://codepen.io/pen/) or similar online Editors, please check our [**Import SDK bundle with `<script>` tag**](docs/guides/import-script-tag.md).

If you're using bundling/compilation techniques (eg. `webpack`), please continue reading.

#### B) Advanced Usage: with `npm` or similar
Add the latest `@aeternity/aepp-sdk` release from npmjs.com to your project using one of these commands

```bash
# install using npm...or yarn or pnpm
npm i @aeternity/aepp-sdk
```

**Note:** To install a _Pre-Release_ (latest `beta` or `alpha` version) using on the latest Node version, you have to install the package appending the `@next` tag reference, or even use the `#` symbol and the Repo URL to install a version coming from a specific branch.
```bash
# install the @next version of the SDK
npm i @aeternity/aepp-sdk@next

# install the #develop version of the SDK
npm i https://github.com/aeternity/aepp-sdk-js#develop
```

**Note** : If you experience errors during the installation, you might need to install build tools for your OS.

Windows: Windows Build Tools
```
npm install -g windows-build-tools
```
Ubuntu / Debian: Build Essential
```
sudo apt-get update
sudo apt-get install build-essential
```
Mac:
Download [Xcode](https://apps.apple.com/de/app/xcode/id497799835?mt=12) from AppStore, then run
```
xcode-select --install
```

### 2. Create an Account
You can do many more things now, but you'll probably have to start with:

#### A) Using the Command Line
Create an account using the [💻 CLI](#cli---command-line-client)

#### B) Using the SDK

```javascript
import { Crypto } from '@aeternity/aepp-sdk/es'
const keypair = Crypto.generateKeyPair()
console.log(`Secret key: ${keypair.secretKey}`)
console.log(`Public key: ${keypair.publicKey}`)
```

### 3. Give yourself some _AE_ tokens
To get yourself some _AEs_ you can use the [🚰 Faucet Aepp](https://faucet.aepps.com/). Just add your publicKey, and you'll immediately get some test tokens.


### 4. Import (a chosen Flavor)

Import the right [flavor](docs/README.md#flavors--entry-points). For this example with get the `Universal` flavor, which contains all the features of the SDK:

```js
// Import Flavor
import Ae from '@aeternity/aepp-sdk/es/ae/universal' // or other flavor
```

### 5. Play with Aetenity's blockchain features

```js
// Use Flavor
import Ae from '@aeternity/aepp-sdk/es/ae/universal' // or other flavor
import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory' // or other flavor
import Node from '@aeternity/aepp-sdk/es/node' // or other flavor
import { AE_AMOUNT_FORMATS } from '@aeternity/aepp-sdk/es/utils/amount-formatter'

const NODE_URL = 'https://testnet.aeternity.io'
const COMPILER_URL = 'COMPILER_URL' // required for using Contract
const ACCOUNT = MemoryAccount({ keypair: { secretKey: 'A_PRIV_KEY', publicKey: 'A_PUB_ADDRESS' } })

(async function () {
const nodeInstance = await Node({ url: NODE_URL })
const sdkInstance = await Ae({
compilerUrl: COMPILER_URL,
nodes: [ { name: 'test-net', instance: nodeInstance } ],
accounts: [ ACCOUNT ]
})

await sdkInstance.height() // get top block height
console.log('Current Block Height:', height)
## Guides & Examples

await sdkInstance.spend(1, 'ak_asd23dasdasda...', { denomination: AE_AMOUNT_FORMATS.AE }) // spend one AE

})()
```

## More: Guides & Examples

Check out our [Guides](docs/README.md) and [Examples](examples/README.md).
Check out our [Quick Start guide](docs/guides/quick-start.md), [Documentation](docs/README.md), and [Examples](examples/README.md).

## CLI - Command Line Client

Expand Down
98 changes: 98 additions & 0 deletions docs/guides/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Quick Start

## 1. Install SDK
### A) Simple Usage: with `<script>` tag
For those not using any JS bundling/complilation or compilation technique or tools like [_Codepen_](https://codepen.io/pen/) or similar online Editors, please check our [**Import SDK bundle with `<script>` tag**](import-script-tag.md).

If you're using bundling/compilation techniques (eg. `webpack`), please continue reading.

### B) Advanced Usage: with `npm` or similar
Add the latest `@aeternity/aepp-sdk` release from npmjs.com to your project using one of these commands

```bash
# install using npm...or yarn or pnpm
npm i @aeternity/aepp-sdk
```

**Note:** To install a _Pre-Release_ (latest `beta` or `alpha` version) using on the latest Node version, you have to install the package appending the `@next` tag reference, or even use the `#` symbol and the Repo URL to install a version coming from a specific branch.
```bash
# install the @next version of the SDK
npm i @aeternity/aepp-sdk@next

# install the #develop version of the SDK
npm i https://github.com/aeternity/aepp-sdk-js#develop
```

**Note** : If you experience errors during the installation, you might need to install build tools for your OS.

Windows: Windows Build Tools
```
npm install -g windows-build-tools
```
Ubuntu / Debian: Build Essential
```
sudo apt-get update
sudo apt-get install build-essential
```
Mac:
Download [Xcode](https://apps.apple.com/de/app/xcode/id497799835?mt=12) from AppStore, then run
```
xcode-select --install
```

## 2. Create an Account
You can do many more things now, but you'll probably have to start with:

### A) Using the Command Line
Create an account using the [💻 CLI](#cli---command-line-client)

### B) Using the SDK

```javascript
import { Crypto } from '@aeternity/aepp-sdk/es'
const keypair = Crypto.generateKeyPair()
console.log(`Secret key: ${keypair.secretKey}`)
console.log(`Public key: ${keypair.publicKey}`)
```

## 3. Give yourself some _AE_ tokens
To get yourself some _AEs_ you can use the [🚰 Faucet Aepp](https://faucet.aepps.com/). Just add your publicKey, and you'll immediately get some test tokens.


## 4. Import (a chosen Flavor)

Import the right [flavor](../README.md#flavors--entry-points). For this example with get the `Universal` flavor, which contains all the features of the SDK:

```js
// Import Flavor
import Ae from '@aeternity/aepp-sdk/es/ae/universal' // or other flavor
```

## 5. Play with Aetenity's blockchain features

```js
// Use Flavor
import Ae from '@aeternity/aepp-sdk/es/ae/universal' // or other flavor
import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory' // or other flavor
import Node from '@aeternity/aepp-sdk/es/node' // or other flavor
import { AE_AMOUNT_FORMATS } from '@aeternity/aepp-sdk/es/utils/amount-formatter'

const NODE_URL = 'https://testnet.aeternity.io'
const COMPILER_URL = 'COMPILER_URL' // required for using Contract
const ACCOUNT = MemoryAccount({ keypair: { secretKey: 'A_PRIV_KEY', publicKey: 'A_PUB_ADDRESS' } })

(async function () {
const nodeInstance = await Node({ url: NODE_URL })
const sdkInstance = await Ae({
compilerUrl: COMPILER_URL,
nodes: [ { name: 'test-net', instance: nodeInstance } ],
accounts: [ ACCOUNT ]
})

await sdkInstance.height() // get top block height
console.log('Current Block Height:', height)

await sdkInstance.spend(1, 'ak_asd23dasdasda...', { denomination: AE_AMOUNT_FORMATS.AE }) // spend one AE

})()
```

0 comments on commit 28f7e6f

Please sign in to comment.