package
0.0.0-20240912083038-27d5587efb86
Repository: https://github.com/dipdup-io/starknet-go-api.git
Documentation: pkg.go.dev

# README

Node RPC API

Go implementation of Starknet node API

Install

go get github.com/dipdup-io/starknet-api-go/pkg/rpc

Usage

You can find example of usage in our repository.

Methods

Library implements following methods:

BlockHashAndNumber(ctx context.Context, opts ...RequestOption) (*Response[BlockHashAndNumber], error)

BlockNumber(ctx context.Context, opts ...RequestOption) (*Response[uint64], error)

Call(ctx context.Context, params CallRequest, block BlockID, opts ...RequestOption) (*Response[[]string], error)

ChainID(ctx context.Context, opts ...RequestOption) (*Response[string], error)

EstimateFee(ctx context.Context, tx Transaction, block BlockID, opts ...RequestOption) (*Response[EstmatedGas], error)

GetBlockTransactionCount(ctx context.Context, block BlockID, opts ...RequestOption) (*Response[uint64], error)

GetBlockWithTxHashes(ctx context.Context, block BlockID, opts ...RequestOption) (*Response[BlockWithTxHashes], error)

GetBlockWithTxs(ctx context.Context, bloxk BlockID, opts ...RequestOption) (*Response[BlockWithTxs], error)

GetClassAt(ctx context.Context, block BlockID, contractAddress string, opts ...RequestOption) (*Response[Class], error)

GetClassHashAt(ctx context.Context, block BlockID, contractAddress string, opts ...RequestOption) (*Response[string], error)

GetClass(ctx context.Context, block BlockID, classHash string, opts ...RequestOption) (*Response[Class], error)

GetEvents(ctx context.Context, filters EventsFilters, opts ...RequestOption) (*Response[EventsResponse], error) 

GetNonce(ctx context.Context, contract string, block BlockID, opts ...RequestOption) (*Response[string], error)

GetStateUpdate(ctx context.Context, block BlockID, opts ...RequestOption) (*Response[StateUpdate], error)

GetStorageAt(ctx context.Context, contract, key string, block BlockID, opts ...RequestOption) (*Response[string], error)

GetTransactionByBlockNumberAndIndex(ctx context.Context, block BlockID, index uint64, opts ...RequestOption) (*Response[Transaction], error)

GetTransactionByHash(ctx context.Context, hash string, opts ...RequestOption) (*Response[Transaction], error)

GetTransactionReceipts(ctx context.Context, hash string, opts ...RequestOption) (*Response[Receipt], error)

PendingTransactions(ctx context.Context, opts ...RequestOption) (*Response[Transaction], error)

Syncing(ctx context.Context, opts ...RequestOption) (*Response[Syncing], error)

Trace(ctx context.Context, block data.BlockID, opts ...RequestOption) (*Response[[]Trace], error) 

Creation

First of all you should import package in your code:

starknetData "github.com/dipdup-io/starknet-go-api/pkg/data"
rpc "github.com/dipdup-io/starknet-go-api/pkg/rpc"

Then create API object:

api := rpc.NewAPI("LINK_TO_NODE_RPC")

And call any method:

response, err := api.GetBlockTransactionCount(ctx, starknetData.BlockID{
    Number: 100,
})
if err != nil {
    log.Panic(err)
}

Timeout

If you need timeout on your request you should set it by passing context:


// by context
requestCtx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

response, err := api.GetBlockTransactionCount(requestCtx, starknetData.BlockID{
    Number: 100,
})
if err != nil {
    log.Panic(err)
}

# Functions

NewAPI - constructor of API.
WithApiKey -.
WithCustomID - set custom request id.
WithJsonRpcVersion - change json rpc version.
WithRateLimit -.

# Variables

errors.

# Structs

API - wrapper of starknet node API.
BlockHashAndNumber -.
BlockWithReceipt -.
BlockWithTxHashes -.
BlockWithTxs -.
No description provided by the author
CallRequest -.
Error -.
EstmatedGas -.
EventsFilters -.
EventsResponse -.
No description provided by the author
No description provided by the author
No description provided by the author
Receipt -.
Request -.
Response -.
Syncing -.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

ApiOption -.
RequestOption -.