{"id":21162304,"url":"https://github.com/webankblockchain/wecross-go-sdk","last_synced_at":"2026-01-02T02:37:46.363Z","repository":{"id":42040365,"uuid":"481809270","full_name":"WeBankBlockchain/WeCross-Go-SDK","owner":"WeBankBlockchain","description":"The Golang SDK for WeCross","archived":false,"fork":false,"pushed_at":"2022-12-14T10:01:09.000Z","size":102,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"develop-leo","last_synced_at":"2025-01-21T09:48:15.745Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/WeBankBlockchain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-15T02:15:25.000Z","updated_at":"2024-12-09T15:39:23.000Z","dependencies_parsed_at":"2022-07-25T22:47:19.489Z","dependency_job_id":null,"html_url":"https://github.com/WeBankBlockchain/WeCross-Go-SDK","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeBankBlockchain%2FWeCross-Go-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeBankBlockchain%2FWeCross-Go-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeBankBlockchain%2FWeCross-Go-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeBankBlockchain%2FWeCross-Go-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WeBankBlockchain","download_url":"https://codeload.github.com/WeBankBlockchain/WeCross-Go-SDK/tar.gz/refs/heads/develop-leo","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243606960,"owners_count":20318314,"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":[],"created_at":"2024-11-20T13:24:54.065Z","updated_at":"2026-01-02T02:37:46.334Z","avatar_url":"https://github.com/WeBankBlockchain.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# WeCross-Go-SDK\nWeCross Go SDK提供操作跨链资源的Go API，开发者通过SDK可以方便快捷地基于[WeCross](https://github.com/WeBankBlockchain/WeCross)开发自己的跨链应用。\n\n## 引用\n    import \"github.com/WeBankBlockchain/WeCross-Go-SDK\"\n\n## 关键特性\n- 提供了一个简单易用的日志系统方便Go程序开发，用户可自定义配置使用\n- 提供调用WeCross[RPC接口](https://wecross.readthedocs.io/zh_CN/latest/docs/manual/api.html)的Go API\n- 封装了跨链资源操作接口\n\n## 快速开始\n### 配置使用日志系统\n```\nfunc main() {\n\t// 将标准输出添加进日志系统的输出\n\tlogger.AddStdOutLogSystem(logger.Info)\n\t// 自定义一个日志输出系统\n\tlogger.AddNewLogSystem(\"./\", \"test.log\", log.LstdFlags, logger.Debug)\n\n\t// 在你的go程序中定义不同的日志标签\n\ttestLogTag := logger.NewLogger(\"quickStart\")\n\t// 使用这些标签进行日志填写\n\ttestLogTag.Infoln(\"Log here as you wish.\")\n\ttestLogTag.Warnf(\"Use the log level you like, warn level is: %d\", logger.Warn)\n\n\t// 日志消息可能需要等待一定时间才能刷入标准输出， 使用flush可以强制刷新\n\t// 此处为了在标准输出中显示测试结果使用Flush，实际使用时无需用户自己去Flush\n\tlogger.Flush()\n}\n```\n\n### RPC API调用\n```\nfunc main() {\n\t// 首先创建RPC服务并设置存放配置文件的文件目录classpath\n\t// classpath下应该放置application.toml\n\trpcService := service.NewWeCrossRPCService()\n\trpcService.SetClassPath(\"./tomldir\") // 如不配置classpath,默认为当前程序运行目录\n\n\terr := rpcService.Init()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n    // 初始化WeCrossRPC模块绑定RPC服务\n\tweCrossRPC := rpc.NewWeCrossRPCModel(rpcService)\n\t\n\t// 使用WeCrossRPC模块构造不同的RPC命令\n\tcall, err := weCrossRPC.Login(\"username\", \"password\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n    // RPC执行并返回结果\n\tres, err := call.Send()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"The response is: %s\\n\", res.ToString())\n\n\t// 对RPC结果response更加复杂的处理,需要知道不同RPC返回的response data的数据类型\n\t// 更多RPC指令以及所对应的response data类型可查阅官方文档中的WeCross-Go-SDK技术文档\n\tdata, ok := res.Data.(*response.UAReceipt)\n\tif !ok {\n\t\tpanic(\"type is not right\")\n\t}\n\tfmt.Printf(\"Universal Account info: %s\\n\", data.UniversalAccount.ToString())\n}\n```\n\n### 资源操作接口\n\n```\nfunc main() {\n\t// 首先创建RPC服务并设置配置文件的classpath\n\t// classpath下应该放置application.toml\n\trpcService := service.NewWeCrossRPCService()\n\trpcService.SetClassPath(\"./tomldir\") // 如不配置classpath,默认为当前程序运行目录\n\n\terr := rpcService.Init()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tweCrossRPC := rpc.NewWeCrossRPCModel(rpcService)\n\n\t//使用resource前需要先登录\n\tcall, err := weCrossRPC.Login(\"username\", \"password\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = call.Send()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// 使用NewResource绑定resource\n\ttestResource := resource.NewResource(weCrossRPC, \"test.test.test\")\n\n\t// 更多资源相关API请查阅官方文档\n\tif !testResource.IsActive() {\n\t\tpanic(\"the path is not active\")\n\t}\n\n\tres, err := testResource.SendTransaction(\"XXXmethod\", \"arg1\", \"arg...\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t\n\tfmt.Println(\"Result:\")\n\tfmt.Println(res)\n}\n\n```\n\n\n## 环境依赖\n```\nmodule github.com/WeBankBlockchain/WeCross-Go-SDK\n\ngo 1.18\n\nrequire github.com/pelletier/go-toml v1.9.5\n```\n\n\n\n## 贡献说明\n\n欢迎参与WeCross社区的维护和建设：\n\n- 提交代码(Pull requests)，可参考[代码贡献流程](./CONTRIBUTING.md)以及[wiki指南](https://github.com/WeBankBlockchain/WeCross/wiki/贡献代码)\n- [提问和提交BUG](https://github.com/WeBankBlockchain/WeCross-Go-SDK/issues/new)\n\n感谢以下贡献者的付出（此处自动显示所有本项目的代码贡献者）\n\n\u003cimg src=\"https://contrib.rocks/image?repo=WeBankBlockchain/WeCross-Go-SDK\" alt=\"https://github.com/WeBankBlockchain/github.com/WeBankBlockchain/WeCross-Go-SDK/graphs/contributors\" style=\"zoom:100%;\" /\u003e\n\n## 开源社区\n\n参与meetup：[活动日历](https://github.com/WeBankBlockchain/WeCross/wiki#%E6%B4%BB%E5%8A%A8%E6%97%A5%E5%8E%86)\n\n学习知识、讨论方案、开发新特性：[联系微信小助手，加入跨链兴趣小组（CC-SIG）](https://wecross.readthedocs.io/zh_CN/latest/docs/community/cc-sig.html#id3)\n\n## License\n\nWeCross Go SDK的开源协议为Apache License 2.0，详情参考[LICENSE](./LICENSE)。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebankblockchain%2Fwecross-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebankblockchain%2Fwecross-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebankblockchain%2Fwecross-go-sdk/lists"}