{"id":19423216,"url":"https://github.com/make-software/casper-go-sdk","last_synced_at":"2025-04-24T16:30:48.312Z","repository":{"id":168406575,"uuid":"642383905","full_name":"make-software/casper-go-sdk","owner":"make-software","description":"Go SDK to interact with the Casper Network ","archived":false,"fork":false,"pushed_at":"2025-03-31T16:23:46.000Z","size":6541,"stargazers_count":16,"open_issues_count":5,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T07:21:48.584Z","etag":null,"topics":["blockchain","casper-network","sdk","sdk-go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/make-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-18T12:54:08.000Z","updated_at":"2025-03-31T16:23:56.000Z","dependencies_parsed_at":"2023-12-21T15:47:35.770Z","dependency_job_id":"f1f50ae0-1d38-4298-89c4-595aff508f82","html_url":"https://github.com/make-software/casper-go-sdk","commit_stats":null,"previous_names":["make-software/casper-go-sdk"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fcasper-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fcasper-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fcasper-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fcasper-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/make-software","download_url":"https://codeload.github.com/make-software/casper-go-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250663544,"owners_count":21467366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","casper-network","sdk","sdk-go"],"created_at":"2024-11-10T13:37:27.770Z","updated_at":"2025-04-24T16:30:48.306Z","avatar_url":"https://github.com/make-software.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Casper Go SDK\n[![GitHub version](https://badge.fury.io/gh/make-software%2Fcasper-go-sdk.svg)](https://badge.fury.io/gh/make-software%2Fcasper-go-sdk)\n[![Quality check](https://github.com/make-software/casper-go-sdk/actions/workflows/quality-check.yml/badge.svg)](https://github.com/make-software/casper-go-sdk/actions/workflows/quality-check.yml)\n\nThe Casper Go SDK provides a convenient way to interact with the Casper Network using Go.\n\n## Get started\n\n```shell\ngo get github.com/make-software/casper-go-sdk/v2/\n```\n\n## Base usage\n\n### RPC client\n\nPackage rpc provides access to the exported methods of RPC Client and data structures where the response is serialized.\n[See more details here](rpc/README.md)\n\nExample:\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/make-software/casper-go-sdk/v2/casper\"\n)\n\nfunc main() {\n\thandler := casper.NewRPCHandler(\"http://\u003cNode Address\u003e:7777/rpc\", http.DefaultClient)\n\tclient := casper.NewRPCClient(handler)\n\tdeployHash := \"62972eddc6fdc03b7ec53e52f7da7e24f01add9a74d68e3e21d924051c43f126\"\n\tdeploy, err := client.GetDeploy(context.Background(), deployHash)\n\tif err != nil {\n\t\treturn\n\t}\n\tfmt.Println(deploy.Deploy.Hash)\n}\n```\n\n### SSE\n\nThe SSE package provides basic functionality to work with Casper events that streamed by SSE server.\n[See more details here](sse/README.md)\n\nExample:\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/make-software/casper-go-sdk/v2/sse\"\n)\n\nfunc main() {\n\tclient := sse.NewClient(\"http://\u003cNode Address\u003e:9999/events/main\")\n\tdefer client.Stop()\n\tclient.RegisterHandler(\n\t\tsse.DeployProcessedEventType,\n\t\tfunc(ctx context.Context, rawEvent sse.RawEvent) error {\n\t\t\tdeploy, err := rawEvent.ParseAsDeployProcessedEvent()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tlog.Printf(\"Deploy hash: %s\", deploy.DeployProcessed.DeployHash)\n\t\t\treturn nil\n\t\t})\n\tlastEventID := 1234\n\tclient.Start(context.TODO(), lastEventID)\n}\n```\n\n### Work with Casper types\n\nSDK implements base functionality that allows to work with native Casper types.\n\n* High-level types declaration and the base functions to construct them. [details](types/README.md)\n* Low level types (CLValue) with base functionality [details](types/clvalue/README.md)\n* Identifiers, hashes and related functions [details](types/key/README.md)\n* Cryptography public and private keys functionality [details](types/keypair/README.md)\n\nExample of how to construct a native transfer transaction and push it to the network:\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"math/big\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/make-software/casper-go-sdk/v2/casper\"\n\t\"github.com/make-software/casper-go-sdk/v2/rpc\"\n\t\"github.com/make-software/casper-go-sdk/v2/types\"\n\t\"github.com/make-software/casper-go-sdk/v2/types/clvalue\"\n)\n\nfunc main() {\n\tkeys, _ := casper.NewED25519PrivateKeyFromPEMFile(\"./secret-key.pem\")\n\tpubKey := keys.PublicKey()\n\n\ttarget, _ := casper.NewPublicKey(\"0106ed45915392c02b37136618372ac8dde8e0e3b8ee6190b2ca6db539b354ede4\")\n\n\targs := \u0026types.Args{}\n\targs.AddArgument(\"target\", clvalue.NewCLPublicKey(target)).\n\t\tAddArgument(\"amount\", *clvalue.NewCLUInt512(big.NewInt(2500000000)))\n\n\tpayload, err := types.NewTransactionV1Payload(\n\t\ttypes.InitiatorAddr{\n\t\t\tPublicKey: \u0026pubKey,\n\t\t},\n\t\ttypes.Timestamp(time.Now().UTC()),\n\t\t1800000000000,\n\t\t\"casper-net-1\",\n\t\ttypes.PricingMode{\n\t\t\tLimited: \u0026types.LimitedMode{\n\t\t\t\tGasPriceTolerance: 1,\n\t\t\t\tStandardPayment:   true,\n\t\t\t\tPaymentAmount:     100000000,\n\t\t\t},\n\t\t},\n\t\ttypes.NewNamedArgs(args),\n\t\ttypes.TransactionTarget{\n\t\t\tNative: \u0026struct{}{},\n\t\t},\n\t\ttypes.TransactionEntryPoint{\n\t\t\tTransfer: \u0026struct{}{},\n\t\t},\n\t\ttypes.TransactionScheduling{\n\t\t\tStandard: \u0026struct{}{},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttransaction, err := types.MakeTransactionV1(payload)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = transaction.Sign(keys)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\trpcClient := rpc.NewClient(rpc.NewHttpHandler(\"http://\u003cNode Address\u003e:7777/rpc\", http.DefaultClient))\n\tres, err := rpcClient.PutTransactionV1(context.Background(), *transaction)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.Println(\"TransactionV1 submitted:\", res.TransactionHash.TransactionV1)\n}\n```\n\n## Advanced usage\n\nIt is crucial to have a clear understanding of the SDK structure and its functionalities in order to avoid common mistakes or misuse of functionality. The SDK consists of several packages that have strict dependencies.\n\nIf we were to present the packages in different layers, the structure would be as follows (in ascending order, from low to high):\n\n1. Lowest layer: `cltype` and `keypair`\n2. `key`\n3. `clvalue`\n4. `types`\n5. Services `rpc` and `sse`\n6. The highest level is a facade that provides popular interfaces through the `casper` package\n\nThe Dependency tree can help to visualise:\n\n![package dependency tree](docs/package-dependency-tree.png)\n\nLinks to package documentation and examples:\n1. `cltype` [examples](tests/types/cl_value/cl_type/list_test.go)\n2. `clvalue` [doc](types/clvalue/README.md) | [examples](tests/types/cl_value/example_test.go)\n3. `keypair` [doc](types/keypair/README.md) | [examples](tests/types/keypair/private_key_test.go)\n4. `types` [doc](types/README.md) | [examples](tests/types/deploy_make_test.go)\n5. `rpc` [doc](rpc/README.md) | [examples](tests/rpc/client_example_test.go)\n6. `sse` [doc](sse/README.md) | [examples](tests/sse/example_test.go)\n\n\n### Lint and test\n\nTo install necessary Go tools, use the following commands:\n```shell\ngo install -v github.com/incu6us/goimports-reviser/v3@latest\ngo install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1\n```\n\nRun linters:\n```shell\ngo fmt ./...\ngo vet ./...\ngoimports-reviser ./...\ngolangci-lint run\n```\n\nRun tests:\n```shell\ngo test ./...\n```\n\n## Get Involved\n\nWe hope you find this SDK to be a useful tool for interacting with the Casper Network using Go. We've strived to make it as intuitive and user-friendly as possible, but we understand that there's always room for improvement.\n\nShould you have any questions, issues, or suggestions, please don't hesitate to open an issue in our [GitHub repository](https://github.com/make-software/casper-go-sdk/issues). If you are interested in contributing to the Casper Go SDK, we would be thrilled to welcome you to our community. Please check out the [CONTRIBUTING.md](CONTRIBUTING.md) guide for more information.\n\nRemember, the power of blockchain networks is in their communities. Every question you ask, issue you open, or contribution you make, helps to improve the Casper Go SDK and benefits the entire Casper ecosystem.\n\nThank you for your interest in our project, and we look forward to building the future of the Casper Network together!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmake-software%2Fcasper-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmake-software%2Fcasper-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmake-software%2Fcasper-go-sdk/lists"}