Skip to content

Commit

Permalink
docs: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fgladisch committed Mar 26, 2018
1 parent fe7b46a commit b34b83a
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ blockchain.add({
## Quick Start (TypeScript)

```ts
import { Blockchain } from "@anychain/core";
import { Block, Blockchain } from "@anychain/core";

interface User {
id: number;
Expand All @@ -29,7 +29,7 @@ interface User {

const blockchain: Blockchain<User> = new Blockchain<User>();

blockchain.add({
const newBlock: Block<User> = blockchain.add({
id: 42,
firstName: "Elon",
lastName: "Musk"
Expand All @@ -46,7 +46,19 @@ npm install --save @anychain/core

## API

### `#toJSON()`
### `constructor(chain?: Block<T>[])`

Pass an optional existing `chain` to the constructor.

### `#add(data: T): Block<T>`

Adds a new block with the given data to the blockchain.

### `#update(chain: Block<T>[]): boolean`

Overwrite the current `chain` with a more recent one. Returns `true` when the update was successful.

### `#toJSON(): string`

Returns the following JSON for the example above:

Expand All @@ -73,14 +85,14 @@ Returns the following JSON for the example above:
]
```

### `#getChain()`
### `#getChain(): Block<T>[]`

Returns the full chain as array.
Returns the full `chain` as array.

### `#getGenesisBlock()`
### `#getGenesisBlock(): Block<T>`

Returns the first block in the chain (genesis).
Returns the first `block` in the `chain` (genesis).

### `#getLatestBlock()`
### `#getLatestBlock(): Block<T>`

Returns the latest block in the chain.
Returns the latest `block` in the `chain`.

0 comments on commit b34b83a

Please sign in to comment.