Skip to content

Commit 0f1d734

Browse files
Added installation guide to docs
1 parent d262be8 commit 0f1d734

File tree

4 files changed

+86
-9
lines changed

4 files changed

+86
-9
lines changed

documentation/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Summary
22

33
- [Start](./start.md)
4+
- [Installation](./installation.md)
45
- [Account Nonce](./account_nonce.md)
56
- [Block](./block.md)
67
- [Data Submission](./data_submission.md)

documentation/src/installation.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Installation
2+
3+
You can find Go installation instructions [here](https://go.dev/doc/install). The required minimum version of Go is 1.23.0
4+
5+
If you already have installed Go, jump to -First Time Running- section.
6+
7+
## Installing GO in an Empty Ubuntu Container
8+
Here are the instructions on how to install GO using the latest Ubuntu image.
9+
10+
```bash
11+
podman run -it --rm --name ubuntu-container ubuntu:latest
12+
apt-get update
13+
apt-get upgrade
14+
apt-get install nano wget
15+
cd ./home/ubuntu/.
16+
wget https://go.dev/dl/go1.23.5.linux-amd64.tar.gz
17+
tar -xf go1.23.5.linux-amd64.tar.gz
18+
mv ./go /usr/local/go
19+
export PATH=$PATH:/usr/local/go/bin
20+
go version
21+
# "go version go1.23.5 linux/amd64"
22+
```
23+
24+
25+
## First Time Running
26+
27+
1. Paste the following code to `main.go`:
28+
```go
29+
package main
30+
31+
import (
32+
"fmt"
33+
SDK "github.com/availproject/avail-go-sdk/sdk"
34+
)
35+
36+
func main() {
37+
sdk := SDK.NewSDK(SDK.TuringEndpoint)
38+
39+
// Use SDK.Account.NewKeyPair("Your key") to use a different account than Alice
40+
acc, err := SDK.Account.Alice()
41+
if err != nil {
42+
panic(err)
43+
}
44+
45+
tx := sdk.Tx.DataAvailability.SubmitData([]byte("MyData"))
46+
res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions().WithAppId(1))
47+
if err != nil {
48+
panic(err)
49+
}
50+
51+
// Transaction Details
52+
println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
53+
}
54+
```
55+
56+
2. Paste the following code to `go.mod`
57+
```go
58+
module mymodule
59+
60+
go 1.23.4
61+
62+
require github.com/availproject/avail-go-sdk v0.2.0-rc3
63+
```
64+
65+
3. Fetch dependencies:
66+
```bash
67+
go mod tidy
68+
```
69+
70+
4. Run Example:
71+
```bash
72+
go run .
73+
```

documentation/src/start.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SDK Version
22

3-
This Documentation is based upon avail-go version v0.2.0-rc1
3+
This Documentation is based upon avail-go version v0.2.0-rc4

main.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package main
22

33
import (
4-
"github.com/availproject/avail-go-sdk/primitives"
4+
"fmt"
55
SDK "github.com/availproject/avail-go-sdk/sdk"
66
)
77

88
func main() {
9-
sdk := SDK.NewSDK(SDK.LocalEndpoint)
9+
sdk := SDK.NewSDK(SDK.TuringEndpoint)
1010

11-
val, _ := primitives.NewH256FromHexString("0x513e312001b7e288baba4b6f94bca753f0a6d6d10dcfa2ff41e52f50bc936188")
12-
13-
rows := []uint32{}
14-
15-
rows = append(rows, 0, 1)
11+
// Use SDK.Account.NewKeyPair("Your key") to use a different account than Alice
12+
acc, err := SDK.Account.Alice()
13+
if err != nil {
14+
panic(err)
15+
}
1616

17-
_, err := sdk.Client.Rpc.Kate.QueryRows(rows, primitives.NewSome(val))
17+
tx := sdk.Tx.DataAvailability.SubmitData([]byte("MyData"))
18+
res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions().WithAppId(1))
1819
if err != nil {
1920
panic(err)
2021
}
2122

23+
// Transaction Details
24+
println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
2225
}

0 commit comments

Comments
 (0)