An open API service indexing awesome lists of open source software.

https://github.com/nethermindeth/starknet.go

Golang Library for StarkNet/Cairo
https://github.com/nethermindeth/starknet.go

blockchain go golang nubia starknet

Last synced: about 2 months ago
JSON representation

Golang Library for StarkNet/Cairo

Awesome Lists containing this project

README

        








Go Reference





Main tests














Get the gopher Starkpilled






**starknet.go** will get your golang backends and WASM frontends to Starknet easily.
With simple abstractions for the Starknet RPC, account management and common
operations on the wallets. The package has excellent documentation for a smooth
0 to 1 experience.

# ๐ŸŒŸ Features

- Seamless interaction with the Starknet RPC
- Tight integration with Juno
- Account management: Deploy accounts easily
- Good concurrency support

# Getting Started

- library documentation available at [pkg.go.dev](https://pkg.go.dev/github.com/NethermindEth/starknet.go).
- [simple call example](./examples/simpleCall) to make a contract call to a testnet contract.
- [deploy account example](./examples/deployAccount) to deploy a new account contract on testnet.
- [invoke transaction example](./examples/invoke) to add a new invoke transaction on testnet.
- [declare transaction example](./examples/simpleDeclare) to add a new contract on testnet.
- [deploy contract UDC example](./examples/deployContractUDC) to deploy an ERC20 token using [UDC (Universal Deployer Contract)](https://docs.starknet.io/architecture-and-concepts/accounts/universal-deployer/) on testnet.
- [typed data example](./examples/typedData) to sign and verify a typed data.
- [websocket example](./examples/websocket) to learn how to subscribe to WebSocket methods.

### Run Examples

***starknet simpleCall***

```sh
cd examples/simpleCall
go run main.go
```
> Check [here](examples/simpleCall/README.md) for more details

***starknet simpleDeclare***

```sh
cd examples/simpleDeclare
go run main.go
```
> Check [here](examples/simpleDeclare/README.md) for more details

***starknet deployAccount***

```sh
cd examples/deployAccount
go run main.go
```

> Check [here](examples/deployAccount/README.md) for more details

***starknet invoke***

```sh
cd examples/invoke
go run main.go simpleInvoke.go verboseInvoke.go
```

> Check [here](examples/invoke/README.md) for more details

***starknet deployContractUDC***

```sh
cd examples/deployContractUDC
go run main.go
```

> Check [here](examples/deployContractUDC/README.md) for more details.

***starknet readEvents***

```sh
cd examples/readEvents
go run main.go
```
> Check [here](examples/readEvents/README.md) for more details

***starknet typedData***

```sh
cd examples/typedData
go run main.go
```

> Check [here](examples/typedData/README.md) for more details.

***starknet websocket***

```sh
cd examples/websocket
go run main.go
```

> Check [here](examples/websocket/README.md) for more details.


Check [here](https://github.com/NethermindEth/starknet.go/tree/main/examples) for some FAQ answered by these examples.

### RPC

`starknet.go` RPC implements the Starknet [RPC v0.8.0 spec](https://github.com/starkware-libs/starknet-specs/releases/tag/v0.8.0)

| Method | Implemented (*) |
| ------------------------------------------ | ------------------ |
| `starknet_getBlockWithReceipts` | :heavy_check_mark: |
| `starknet_getBlockWithTxHashes` | :heavy_check_mark: |
| `starknet_getBlockWithTxs` | :heavy_check_mark: |
| `starknet_getStateUpdate` | :heavy_check_mark: |
| `starknet_getStorageAt` | :heavy_check_mark: |
| `starknet_getTransactionByHash` | :heavy_check_mark: |
| `starknet_getTransactionByBlockIdAndIndex` | :heavy_check_mark: |
| `starknet_getTransactionReceipt` | :heavy_check_mark: |
| `starknet_getTransactionStatus` | :heavy_check_mark: |
| `starknet_getClass` | :heavy_check_mark: |
| `starknet_getClassHashAt` | :heavy_check_mark: |
| `starknet_getClassAt` | :heavy_check_mark: |
| `starknet_getBlockTransactionCount` | :heavy_check_mark: |
| `starknet_call` | :heavy_check_mark: |
| `starknet_estimateFee` | :heavy_check_mark: |
| `starknet_estimateMessageFee` | :heavy_check_mark: |
| `starknet_blockNumber` | :heavy_check_mark: |
| `starknet_blockHashAndNumber` | :heavy_check_mark: |
| `starknet_chainId` | :heavy_check_mark: |
| `starknet_syncing` | :heavy_check_mark: |
| `starknet_getEvents` | :heavy_check_mark: |
| `starknet_getNonce` | :heavy_check_mark: |
| `starknet_addInvokeTransaction` | :heavy_check_mark: |
| `starknet_addDeclareTransaction` | :heavy_check_mark: |
| `starknet_addDeployAccountTransaction` | :heavy_check_mark: |
| `starknet_traceTransaction` | :heavy_check_mark: |
| `starknet_simulateTransaction` | :heavy_check_mark: |
| `starknet_specVersion` | :heavy_check_mark: |
| `starknet_traceBlockTransactions` | :heavy_check_mark: |
| `starknet_getStorageProof` | :heavy_check_mark: |
| `starknet_getMessagesStatus` | :heavy_check_mark: |
| `starknet_getCompiledCasm` | :heavy_check_mark: |

#### WebSocket Methods

| Method | Implemented (*) |
| ------------------------------------------ | ------------------ |
| `starknet_subscribeEvents` | :heavy_check_mark: |
| `starknet_subscribeNewHeads` | :heavy_check_mark: |
| `starknet_subscribePendingTransactions` | :heavy_check_mark: |
| `starknet_subscribeTransactionStatus` | :heavy_check_mark: |

### Run Tests

```go
go test -v ./...
```

### Run RPC Tests

```go
go test -v ./rpc -env [mainnet|devnet|testnet|mock]
```

### Run Benchmarks

```go
go test -bench=.
```

### Compatibility and stability

## ๐Ÿค Contribute

We're always looking for passionate developers to join our community and
contribute to `starknet.go`. Check out our [contributing guide](./docs/CONTRIBUTING.md)
for more information on how to get started.

## ๐Ÿ“– License

This project is licensed under the **MIT license**.

See [LICENSE](LICENSE) for more information.

Happy coding! ๐ŸŽ‰
## Contributors โœจ

Thanks goes to these wonderful people
([emoji key](https://allcontributors.org/docs/en/emoji-key)):



drspacemn
drspacemn

๐Ÿ’ป
Gregory Guillou
Gregory Guillou

๐Ÿ’ป
Tarrence van As
Tarrence van As

๐Ÿ’ป
Alex Sumner
Alex Sumner

๐Ÿ’ป
Yun
Yun

๐Ÿ’ป
Zoraiz Mahmood
Zoraiz Mahmood

๐Ÿ’ป
Lucas @ StarkWare
Lucas @ StarkWare

๐Ÿ’ป


Coburn
Coburn

๐Ÿ’ป
Larko
Larko

๐Ÿ’ป
oxlime
oxlime

๐Ÿ’ป
Blaลพ Hrastnik
Blaลพ Hrastnik

๐Ÿ’ป
Florian
Florian

๐Ÿ’ป
greged93
greged93

๐Ÿ’ป
Jean-Sรฉbastien Ney
Jean-Sรฉbastien Ney

๐Ÿ’ป


Kristijan Rebernisak
Kristijan Rebernisak

๐Ÿ’ป
rianhughes
Rian Hughes

๐Ÿ’ป
Carmen
Carmen Irene Cabrera Rodrรญguez

๐Ÿ’ป
Josh
Josh Klopfenstein

๐Ÿ’ป
Antonio
Antonio Quental

๐Ÿ“–
Jelilat
Jelilat Anofiu

๐Ÿ’ป
JorikSchellekens
Jorik Schellekens

๐Ÿ“–


Akashneelesh
Akashneelesh

๐Ÿ’ก
fico
Fico

๐Ÿ’ป
Bitcoinnoobie
Bitcoinnoobie

๐Ÿ’ป
stranger80
stranger80

๐Ÿ’ป
omahs
omahs

๐Ÿ“–

This project follows the
[all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!