Go library providing an abstraction to Starknet nodes.
This library is under development; expect APIs and data structures to change until it reaches version 1.0. In addition, clients' implementations of both their own and the standard API are themselves under development so implementation of the the full API can be incomplete.
go-starknet-client
is a standard Go module which can be installed with:
go get github.com/attestantio/go-starknet-client
go-starknet-client
supports execution nodes that comply with the standard execution node API.
Please read the Go documentation for this library for interface information.
Below is a complete annotated example to access an execution node.
package main
import (
"context"
"fmt"
execclient "github.com/attestantio/go-starknet-client"
"github.com/attestantio/go-starknet-client/jsonrpc"
"github.com/rs/zerolog"
)
func main() {
// Provide a cancellable context to the creation function.
ctx, cancel := context.WithCancel(context.Background())
client, err := jsonrpc.New(ctx,
// WithAddress supplies the address of the execution node, as a URL.
jsonrpc.WithAddress("http://localhost:8545/"),
// LogLevel supplies the level of logging to carry out.
jsonrpc.WithLogLevel(zerolog.WarnLevel),
)
if err != nil {
panic(err)
}
fmt.Printf("Connected to %s\n", client.Name())
blockNumber, err := provider.BlockNumber(ctx)
if err != nil {
panic(err)
}
fmt.Printf("Current block number is %v\n", blockNumber)
// Cancelling the context passed to New() frees up resources held by the
// client, closes connections, clears handlers, etc.
cancel()
}
Jim McDonald: @mcdee.
Contributions welcome. Please check out the issues.
Apache-2.0 © 2021 Attestant Limited