{"id":19270135,"url":"https://github.com/hyperledger-labs/go-perun","last_synced_at":"2025-10-23T23:04:18.907Z","repository":{"id":36961739,"uuid":"283471366","full_name":"hyperledger-labs/go-perun","owner":"hyperledger-labs","description":"🌔 Perun's Blockchain-Agnostic State Channels Framework in Go.","archived":false,"fork":false,"pushed_at":"2025-02-11T13:13:38.000Z","size":3623,"stargazers_count":56,"open_issues_count":46,"forks_count":18,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-31T12:06:30.576Z","etag":null,"topics":["blockchain","go","state-channels"],"latest_commit_sha":null,"homepage":"https://perun.network/","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/hyperledger-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-29T10:41:40.000Z","updated_at":"2025-02-11T12:30:10.000Z","dependencies_parsed_at":"2024-01-15T13:20:36.476Z","dependency_job_id":"0d1d2e1c-f87c-4082-85e9-50a6cd444465","html_url":"https://github.com/hyperledger-labs/go-perun","commit_stats":{"total_commits":1757,"total_committers":16,"mean_commits":109.8125,"dds":0.7649402390438247,"last_synced_commit":"e808977815a76d75f9eaebb72a28ddab7d8f48d3"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fgo-perun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fgo-perun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fgo-perun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fgo-perun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperledger-labs","download_url":"https://codeload.github.com/hyperledger-labs/go-perun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657281,"owners_count":20974345,"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","go","state-channels"],"created_at":"2024-11-09T20:23:28.115Z","updated_at":"2025-10-23T23:04:18.885Z","avatar_url":"https://github.com/hyperledger-labs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003cbr\u003e\n    \u003ca href=\"https://perun.network/\"\u003e\u003cimg src=\".assets/logo.png\" alt=\"Perun\" width=\"196\"\u003e\u003c/a\u003e\n\u003cbr\u003e\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003ePerun Blockchain-Agnostic State Channels Framework\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/hyperledger-labs/go-perun\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/hyperledger-labs/go-perun\" alt=\"Go report: A+\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.apache.org/licenses/LICENSE-2.0.txt\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-Apache%202-blue\" alt=\"License: Apache 2.0\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hyperledger-labs/go-perun/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/hyperledger-labs/go-perun/actions/workflows/ci.yml/badge.svg\" alt=\"TravisCI build status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/perun.network/go-perun?status.svg\"\u003e \u003cimg src=\"https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\" alt=\"pkg.go.dev docs\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://labs.hyperledger.org/perun-doc/\"\u003e \u003cimg src=\".assets/read_the_docs.svg\" alt=\"Read the Docs\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n_go-perun_ is a Go implementation of the [Perun state channel protocols](https://perun.network/) ([introduction paper](https://perun.network/wp-content/uploads/Perun2.0.pdf)).\nThe perun protocols provide payment and general state channel functionality to all existing blockchains that feature smart contracts.\nAs a blockchain scalability solution, payment and state channels reduce transaction costs and increase the system throughput by executing incremental transactions off-chain.\nThe Perun protocols have been proven cryptographically secure in the UC-framework.\nThey are blockchain-agnostic and only rely on a blockchain's capability to execute smart contracts.\n\n## Security Disclaimer\n\nThis software is still under development.\nThe authors take no responsibility for any loss of digital assets or other damage caused by the use of it.\n\n## Getting Started\n\nRunning _go-perun_ requires a working [Go distribution](https://golang.org), see `go.mod` for the required version.\n```sh\n# Clone the repository into a directory of your choice\ngit clone https://github.com/hyperledger-labs/go-perun.git\n# Or directly download it with go\n# go get -d perun.network/go-perun\ncd go-perun\n# Run the unit tests\ngo test ./...\n```\n\nYou can import _go-perun_ in your project like this:\n```go\nimport \"perun.network/go-perun/client\"\n```\n\n_go-perun_ implements the core state channel protocol in a blockchain-agnostic fashion by following the dependency inversion principle.\nFor this reason, a blockchain backend has to be chosen and blockchain-specific initializations need to be executed at program startup.\n\n### Documentation\n\nIn-depth documentation can be found at [perun-doc](https://labs.hyperledger.org/perun-doc/)\nand on [go-perun's pkg.go.dev site](https://pkg.go.dev/perun.network/go-perun).\n\nOur [walkthrough tutorial](http://tutorial.perun.network) describes how _go-perun_ is used to build a simple micro-payment application on top of Ethereum.\n\nA bunch of examples can be found at [perun-examples](https://github.com/perun-network/perun-examples).\n\n## Features\n\n_go-perun_ currently provides two-party channels with the following features:\n* Generalized state channels, including app/sub-channels\n* Dispute watchtower\n* Data persistence\n* Virtual payment channels (direct dispute)\n* Multi-ledger channels\n\nThe following features are planned for future releases:\n* Virtual payment channels (indirect dispute)\n* Virtual state channels\n* Multi-party channels\n* Multi-ledger app/virtual channels\n\n### Backends\n\n _go-perun_ supports multiple **blockchain backends**. A backend is automatically initialized when its top-level package `backend/\u003cname\u003e` is imported.#### Backend Map\n\n| ID  | Backend    | Payment Channel Status | Cross-Chain Status | Repository                                                                           |\n| --- | ---------- | ---------------------- | ------------------ | ------------------------------------------------------------------------------------ |\n| 0   | SimBackend | 🧪 Testing only         | 🧪 Testing only     | Built-in (`backend/sim`) – represents an ideal blockchain backend for simulation     |\n| 1   | Ethereum   | ✅ Supported            | ✅ Supported        | [perun-eth-backend](https://github.com/perun-network/perun-eth-backend/)             |\n| 2   | Stellar    | ✅ Supported            | ✅ Supported        | [perun-stellar-backend](https://github.com/perun-network/perun-stellar-backend)      |\n| 3   | Nervos     | ✅ Supported            | 🚧 In development   | [perun-ckb-backend](https://github.com/perun-network/perun-ckb-backend)              |\n| 4   | Polkadot   | ✅ Supported            | 🚧 In development   | [perun-polkadot-backend](https://github.com/perun-network/perun-polkadot-backend)    |\n| 5   | Dfinity    | ✅ Supported            | 🚧 In development   | [perun-icp-backend](https://github.com/perun-network/perun-icp-backend)              |\n| 6   | Solana     | 🚧 In development       | 🚧 In development   | [perun-solana-backend](https://github.com/perun-network/perun-solana-backend)        |\n| -   | Cosmos     | ✅ Supported            | 🟡 Single-chain     | [perun-cosmwasm-backend](https://github.com/hyperledger-labs/perun-cosmwasm-backend) |\n| -   | Cardano    | ✅ Supported            | 🟡 Single-chain     | [perun-cardano-backend](https://github.com/perun-network/perun-cardano-backend)      |\n| -   | Fabric     | ✅ Supported            | 🟡 Single-chain     | [perun-fabric](https://github.com/perun-network/perun-fabric)                        |\n\n#### Legend\n- ✅ **Supported** – stable and available.  \n- 🚧 **In development** – actively worked on, not fully stable.  \n- 🟡 **Single-chain** – supports only local (non-cross-chain) payment/state channels.  \n- 🧪 **Testing only** – simulation backend, no real blockchain. \n\n**Logging and networking** capabilities can also be injected by the user.\nA default [logrus](https://github.com/sirupsen/logrus) implementation of the `log.Logger` interface can be set using `log/logrus.Set`.\nThe Perun framework relies on a user-injected `wire.Bus` for inter-peer communication.\n_go-perun_ ships with the `wire/net.Bus` implementation for TCP and Unix sockets.\n\n**Data persistence** can be enabled to continuously persist new states and signatures.\nThere are currently three persistence backends provided, namely, a test backend for testing purposes, an in-memory key-value persister and a [LevelDB](https://github.com/syndtr/goleveldb) backend.\n\n## API Primer\n\nIn essence, _go-perun_ provides a state channel network client, akin to ethereum's `ethclient` package, to interact with a state channels network.\nOnce the client has been set up, it can be used to propose channels to other network peers, accept channel proposals, send updates on those channels and eventually settle them.\n\nA minimal, illustrative usage is as follows\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"time\"\n\n\t\"perun.network/go-perun/channel\"\n\t\"perun.network/go-perun/client\"\n\t\"perun.network/go-perun/log\"\n\t\"perun.network/go-perun/peer\"\n\t\"perun.network/go-perun/wallet\"\n\t\"perun.network/go-perun/watcher\"\n\t\"perun.network/go-perun/wire\"\n\t// other imports\n)\n\nfunc main() {\n\t// setup blockchain interaction\n\tvar funder channel.Funder\n\tvar adjudicator channel.Adjudicator\n\t// setup perun network identity\n\tvar perunID wire.Address\n\t// setup communication bus\n\tvar bus wire.Bus\n\t// setup wallet for channel accounts\n\tvar wallet wallet.Wallet\n\t// setup channel watcher\n\tvar watcher watcher.Watcher\n\n\t// create state channel network client\n\tc := client.New(perunID, bus, funder, adjudicator, wallet, watcher)\n\n\t// choose how to react to incoming channel proposals\n\tvar proposalHandler client.ProposalHandler\n\t// choose how to react to incoming channel update requests\n\tvar updateHandler client.UpdateHandler\n\t// start incoming request handler\n\tgo c.Handle(proposalHandler, updateHandler)\n\n\t// propose a new channel\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)\n\tdefer cancel()\n\tch, err := c.ProposeChannel(ctx, client.NewLedgerChannelProposal(\n\t\t// details of channel proposal, like peers, app, initial balances, challenge duration...\n\t))\n\tif err != nil { /* handle error */ }\n\n\t// start watchtower\n\tgo func() {\n\t\terr := ch.Watch()\n\t\tlog.Info(\"Watcher returned with error \", err)\n\t}()\n\n\t// send a channel update request to the other channel peer(s)\n\terr = ch.Update(ctx, func(s *channel.State) {\n\t\t// update state s, e.g., moving funds or changing app data\n\t})\n\tif err != nil { /* handle error */ }\n\n\t// send further updates and finally, settle/close the channel\n\tif err := ch.Settle(ctx); err != nil { /* handle error */ }\n}\n```\n\nFor a full-fledged example, have a look at our CLI Demo [perun-eth-demo](https://github.com/perun-network/perun-eth-demo).\nGo mobile wrappers for \u003cimg src=\"https://developer.android.com/images/brand/Android_Robot.svg?hl=de\" width=\"25\" alt=\"Android\"\u003e and iOS App development can be found at [perun-eth-mobile](https://github.com/perun-network/perun-eth-mobile).\n\n## Funding\n\nThis project has been started at the Chair of Applied Cryptography at Technische Universität Darmstadt, Germany, and is currently developed and maintained by a group of dedicated hackers from PolyCrypt GmbH.\nWe thank the German Federal Ministry of Education and Research (BMBF) for their funding through the StartUpSecure grants program as well as the German Science Foundation (DFG), the Foundation for Polish Science (FNP) and the Ethereum Foundation for their support in the research that preceded this implementation.\n\n## Copyright\n\nCopyright 2022 - See [NOTICE file](NOTICE) for copyright holders.\nUse of the source code is governed by the Apache 2.0 license that can be found in the [LICENSE file](LICENSE).\n\nContact us at [info@perun.network](mailto:info@perun.network).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-labs%2Fgo-perun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperledger-labs%2Fgo-perun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-labs%2Fgo-perun/lists"}