Skip to content

Commit

Permalink
Adds docs folder, connected to Gatsby site.
Browse files Browse the repository at this point in the history
  • Loading branch information
10thfloor committed Jan 30, 2021
1 parent f823aec commit d5da21d
Show file tree
Hide file tree
Showing 2 changed files with 642 additions and 23 deletions.
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
title: Flow GO SDK
description: Packages for Go developers to build applications that interact with the Flow network.
---

# Flow Go SDK [![GoDoc](https://godoc.org/github.com/onflow/flow-go-sdk?status.svg)](https://godoc.org/github.com/onflow/flow-go-sdk)
[![GoDoc](https://godoc.org/github.com/onflow/flow-go-sdk?status.svg)](https://godoc.org/github.com/onflow/flow-go-sdk)

The Flow Go SDK provides a set of packages for Go developers to build applications that interact with the Flow network.

Expand All @@ -15,6 +19,10 @@ Flow is a new blockchain for open worlds. Read more about it [here](https://gith
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Flow Go SDK ![GoDoc](https://godoc.org/github.com/onflow/flow-go-sdk)](#flow-go-sdk-)
- [English | [Chinese](/README_zh_CN.md)](#english--chinese)
- [What is Flow?](#what-is-flow)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Installing](#installing)
- [Generating Keys](#generating-keys)
Expand All @@ -35,21 +43,21 @@ Flow is a new blockchain for open worlds. Read more about it [here](https://gith
- [Event Query Format](#event-query-format)
- [Event Results](#event-results)
- [Querying Accounts](#querying-accounts)
- [Examples](#examples)
- [Examples](#examples)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Getting Started
# Getting Started

### Installing
## Installing

To start using the SDK, install Go 1.13 or above and run go get:

```sh
go get github.com/onflow/flow-go-sdk
```

### Generating Keys
## Generating Keys

Flow uses [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)
to control access to user accounts. Each key pair can be used in combination with
Expand Down Expand Up @@ -79,7 +87,7 @@ A private key has an accompanying public key:
publicKey := privateKey.PublicKey()
```

#### Supported Curves
### Supported Curves

The example above uses an ECDSA key pair on the P-256 (secp256r1) elliptic curve.
Flow also supports the secp256k1 curve used by Bitcoin and Ethereum.
Expand All @@ -92,7 +100,7 @@ privateKey, err := crypto.GeneratePrivateKey(crypto.ECDSA_secp256k1, seed)

Here's a full list of the supported signature and hash algorithms: [Flow Signature & Hash Algorithms](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#supported-signature--hash-algorithms)

### Creating an Account
## Creating an Account

Once you have [generated a key pair](#generating-keys), you can create a new account
using its public key.
Expand Down Expand Up @@ -165,7 +173,7 @@ if result.Status == flow.TransactionStatusSealed {
}
```

### Signing a Transaction
## Signing a Transaction

Below is a simple example of how to sign a transaction using a `crypto.PrivateKey`.

Expand Down Expand Up @@ -206,14 +214,14 @@ if err != nil {
}
```

#### How Signatures Work in Flow
### How Signatures Work in Flow

Flow introduces new concepts that allow for more flexibility when creating and signing transactions.
Before trying the examples below, we recommend that you read through the [transaction signature documentation](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#signing-a-transaction).

---

##### [Single party, single signature](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#single-party-single-signature)
#### [Single party, single signature](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#single-party-single-signature)

- Proposer, payer and authorizer are the same account (`0x01`).
- Only the envelope must be signed.
Expand Down Expand Up @@ -250,7 +258,7 @@ err := tx.SignEnvelope(account1.Address, key1.Index, key1Signer)

---

##### [Single party, multiple signatures](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#single-party-multiple-signatures)
#### [Single party, multiple signatures](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#single-party-multiple-signatures)

- Proposer, payer and authorizer are the same account (`0x01`).
- Only the envelope must be signed.
Expand Down Expand Up @@ -293,7 +301,7 @@ err = tx.SignEnvelope(account1.Address, key2.Index, key2Signer)

---

##### [Multiple parties](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties)
#### [Multiple parties](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties)

- Proposer and authorizer are the same account (`0x01`).
- Payer is a separate account (`0x02`).
Expand Down Expand Up @@ -339,7 +347,7 @@ err = tx.SignEnvelope(account2.Address, key3.Index, key3Signer)
[Full Runnable Example](/examples#multiple-parties)

---
##### [Multiple parties, two authorizers](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties)
#### [Multiple parties, two authorizers](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties)

- Proposer and authorizer are the same account (`0x01`).
- Payer is a separate account (`0x02`).
Expand Down Expand Up @@ -391,7 +399,7 @@ err = tx.SignEnvelope(account2.Address, key3.Index, key3Signer)

---

##### [Multiple parties, multiple signatures](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties-multiple-signatures)
#### [Multiple parties, multiple signatures](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties-multiple-signatures)

- Proposer and authorizer are the same account (`0x01`).
- Payer is a separate account (`0x02`).
Expand Down Expand Up @@ -450,7 +458,7 @@ err = tx.SignEnvelope(account2.Address, key4.Index, key4Signer)

[Full Runnable Example](/examples#multiple-parties-multiple-signatures)

### Sending a Transaction
## Sending a Transaction

You can submit a transaction to the network using the Access API client.

Expand All @@ -471,7 +479,7 @@ if err != nil {
}
```

### Querying Transaction Results
## Querying Transaction Results

After you have submitted a transaction, you can query its status by ID:

Expand Down Expand Up @@ -503,7 +511,7 @@ if result.Error != nil {
}
```

### Querying Blocks
## Querying Blocks

You can use the `GetLatestBlock` method to fetch the latest sealed or unsealed block:

Expand All @@ -530,7 +538,7 @@ A block contains the following fields:
- `Height` - The height of the block in the chain.
- `CollectionGuarantees` - The list of collections included in the block.

### Executing a Script
## Executing a Script

You can use the `ExecuteScriptAtLatestBlock` method to execute a read-only script against the latest sealed execution state.

Expand Down Expand Up @@ -562,7 +570,7 @@ ID := value.(cadence.Int)
myID := ID.Int()
```

### Querying Events
## Querying Events

You can query events with the `GetEventsForHeightRange` function:

Expand All @@ -579,7 +587,7 @@ if err != nil {
}
```

#### Event Query Format
### Event Query Format

An event query includes the following fields:

Expand All @@ -595,7 +603,7 @@ Read the [language documentation](https://docs.onflow.org/cadence/language/event

The blocks to filter by. Events will be returned from blocks in the range `StartHeight` to `EndHeight`, inclusive.

#### Event Results
### Event Results

The `GetEventsForHeightRange` function returns events grouped by block. Each block contains a list of events matching the query in order of execution.

Expand All @@ -609,12 +617,12 @@ for _, block := range blocks {
```

<!--
#### Decoding an Event
### Decoding an Event
TODO: example for event decoding
-->

### Querying Accounts
## Querying Accounts

You can query the state of an account with the `GetAccount` function:

Expand Down
Loading

0 comments on commit d5da21d

Please sign in to comment.