2
2
3
3
You can find Go installation instructions [ here] ( https://go.dev/doc/install ) . The required minimum version of Go is 1.23.0
4
4
5
- If you already have installed Go, jump to -First Time Running- section.
5
+ If you already have installed Go (version no less than 1.23.0) , jump to ` Add Avail-GO SDK as dependency ` section.
6
6
7
7
## Installing GO in an Empty Ubuntu Container
8
8
Here are the instructions on how to install GO using the latest Ubuntu image.
@@ -20,9 +20,27 @@ export PATH=$PATH:/usr/local/go/bin
20
20
go version
21
21
# "go version go1.23.5 linux/amd64"
22
22
```
23
+ ## Add Avail-GO SDK as dependency
23
24
25
+ #### To Existing Project
24
26
25
- ## First Time Running
27
+ ``` bash
28
+ # Fetches Avail-GO SDK v0.2.0-rc5. This might not be the newest version so make sure to check out the latest github avail-go-sdk release.
29
+ # Link to Github: https://github.com/availproject/avail-go-sdk/releases
30
+ go get github.com/availproject/
[email protected]
31
+ ```
32
+
33
+ #### To A New Project
34
+
35
+ ``` bash
36
+ # Creates a new project with name myproject
37
+ go mod init myproject
38
+ # Fetches Avail-GO SDK v0.2.0-rc5. This might not be the newest version so make sure to check out the latest github avail-go-sdk release.
39
+ # Link to Github: https://github.com/availproject/avail-go-sdk/releases
40
+ go get github.com/availproject/
[email protected]
41
+ ```
42
+
43
+ #### First Time Running
26
44
27
45
1 . Paste the following code to ` main.go ` :
28
46
``` go
@@ -34,15 +52,16 @@ import (
34
52
)
35
53
36
54
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 ()
55
+ sdk , err := SDK.NewSDK (SDK.TuringEndpoint )
41
56
if err != nil {
42
57
panic (err)
43
58
}
44
59
60
+ // Use SDK.Account.NewKeyPair("Your key") to use a different account than Ferdie
61
+ acc := SDK.Account .Ferdie ()
62
+
45
63
tx := sdk.Tx .DataAvailability .SubmitData ([]byte (" MyData" ))
64
+ println (" Submitting new Transaction... Can take up to 20 seconds" )
46
65
res , err := tx.ExecuteAndWatchInclusion (acc, SDK.NewTransactionOptions ().WithAppId (1 ))
47
66
if err != nil {
48
67
panic (err)
@@ -53,21 +72,12 @@ func main() {
53
72
}
54
73
```
55
74
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 -rc4
63
- ```
64
-
65
- 3 . Fetch dependencies:
75
+ 2 . Fetch dependencies:
66
76
``` bash
67
77
go mod tidy
68
78
```
69
79
70
- 4 . Run Example:
80
+ 3 . Run Example:
71
81
``` bash
72
82
go run .
73
83
```
0 commit comments