{"id":13669726,"url":"https://github.com/onflow/flow-go-sdk","last_synced_at":"2026-01-29T23:16:26.485Z","repository":{"id":37072935,"uuid":"256582205","full_name":"onflow/flow-go-sdk","owner":"onflow","description":"Tools for building Go applications on Flow :ocean:","archived":false,"fork":false,"pushed_at":"2026-01-27T17:17:24.000Z","size":24712,"stargazers_count":212,"open_issues_count":35,"forks_count":83,"subscribers_count":43,"default_branch":"master","last_synced_at":"2026-01-28T03:49:01.091Z","etag":null,"topics":["blockchain","go","onflow","sdk"],"latest_commit_sha":null,"homepage":"https://onflow.org","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/onflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-17T18:38:30.000Z","updated_at":"2026-01-27T17:19:22.000Z","dependencies_parsed_at":"2022-07-08T01:45:10.373Z","dependency_job_id":"43a9b785-bb93-4079-bfe0-55de759b3fe8","html_url":"https://github.com/onflow/flow-go-sdk","commit_stats":{"total_commits":1498,"total_committers":73,"mean_commits":20.52054794520548,"dds":0.7022696929238985,"last_synced_commit":"4e3e26db6e2ff436d44b4e50ef82eeca5ca4e137"},"previous_names":[],"tags_count":195,"template":false,"template_full_name":null,"purl":"pkg:github/onflow/flow-go-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onflow","download_url":"https://codeload.github.com/onflow/flow-go-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-go-sdk/sbom","scorecard":{"id":485098,"data":{"date":"2025-08-11","repo":{"name":"github.com/onflow/flow-go-sdk","commit":"dc0eec937c4b45a6159fb7f93f4fe5489eb076d3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.8,"checks":[{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/add-issues-to-devx-project.yml:1","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/sync-labels.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/add-issues-to-devx-project.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/onflow/flow-go-sdk/add-issues-to-devx-project.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/onflow/flow-go-sdk/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/onflow/flow-go-sdk/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/onflow/flow-go-sdk/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sync-labels.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/onflow/flow-go-sdk/sync-labels.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/sync-labels.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/onflow/flow-go-sdk/sync-labels.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2024-2819 / GHSA-4xc9-8hmq-j652","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2025-3488 / GHSA-6v2p-p543-phr9"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T17:34:05.451Z","repository_id":37072935,"created_at":"2025-08-19T17:34:05.451Z","updated_at":"2025-08-19T17:34:05.451Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28889871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T21:06:44.224Z","status":"ssl_error","status_checked_at":"2026-01-29T21:06:42.160Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","onflow","sdk"],"created_at":"2024-08-02T09:00:20.738Z","updated_at":"2026-01-29T23:16:26.470Z","avatar_url":"https://github.com/onflow.png","language":"Go","funding_links":[],"categories":["Flow区块链","Others"],"sub_categories":["开发工具"],"readme":"# Flow Go SDK\n\n[![GoDoc](https://godoc.org/github.com/onflow/flow-go-sdk?status.svg)](https://godoc.org/github.com/onflow/flow-go-sdk)\n\nThe Flow Go SDK provides a set of packages for Go developers to build applications that interact with the Flow network.\n\n*Note: This SDK is also fully compatible with the [Flow Emulator](https://docs.onflow.org/emulator/) and can be used for local development.*\n\n## [English](#) | [Chinese](/README_zh_CN.md)\n\n## What is Flow?\n\nFlow is a new blockchain for open worlds. Read more about it [here](https://github.com/onflow/flow).\n\n## Table of Contents\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Getting Started](#getting-started)\n  - [Installing](#installing)\n  - [Generating Keys](#generating-keys)\n    - [Supported Curves](#supported-curves)\n  - [Accessing The Flow Network](#accessing-the-flow-network)\n  - [Creating an Account](#creating-an-account)\n  - [Signing a Transaction](#signing-a-transaction)\n    - [How Signatures Work in Flow](#how-signatures-work-in-flow)\n      - [Single party, single signature](#single-party-single-signature)\n      - [Single party, multiple signatures](#single-party-multiple-signatures)\n      - [Multiple parties](#multiple-parties)\n      - [Multiple parties, two authorizers](#multiple-parties-two-authorizers)\n      - [Multiple parties, multiple signatures](#multiple-parties-multiple-signatures)\n  - [Sending a Transaction](#sending-a-transaction)\n  - [Querying Transaction Results](#querying-transaction-results)\n  - [Querying Blocks](#querying-blocks)\n  - [Executing a Script](#executing-a-script)\n  - [Querying Events](#querying-events)\n    - [Event Query Format](#event-query-format)\n    - [Event Results](#event-results)\n  - [Querying Accounts](#querying-accounts)\n  - [Examples](#examples)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# Getting Started\n\n## Installing\n\nTo start using the SDK, install Go 1.13 or above and run go get:\n\n```sh\ngo get github.com/onflow/flow-go-sdk\n```\n\nBuilding and testing Go commands with the SDK require enabling cgo `CGO_ENABLED=1` because of the underlying cryptography library.\nRefer to the [crypto repository build](https://github.com/onflow/crypto?tab=readme-ov-file#build) for more details.\n\nNote that it is possible to build with cgo disabled `CGO_ENABLED=0`, but this requires confirming the choice by using the Go build tag `no-cgo`. This would disable the crypto BLS signature features of the SDK.\nAny call of a BLS tool would result in a panic.\n\n## Generating Keys\n\nFlow uses [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)\nto control access to user accounts. Each key pair can be used in combination with\nthe SHA2-256 or SHA3-256 hashing algorithms.\n\nHere's how to generate an ECDSA private key for the P-256 (secp256r1) curve:\n\n```go\nimport \"github.com/onflow/flow-go-sdk/crypto\"\n\n// deterministic seed phrase\n// note: this is only an example, please use a secure random generator for the key seed\nseed := []byte(\"elephant ears space cowboy octopus rodeo potato cannon pineapple\")\n\nprivateKey, err := crypto.GeneratePrivateKey(crypto.ECDSA_P256, seed)\n```\n\nThe private key can then be encoded as bytes (i.e. for storage):\n\n```go\nencPrivateKey := privateKey.Encode()\n```\n\nA private key has an accompanying public key:\n\n```go\npublicKey := privateKey.PublicKey()\n```\n\n### Supported Curves\n\nThe example above uses an ECDSA key pair on the P-256 (secp256r1) elliptic curve.\nFlow also supports the secp256k1 curve used by Bitcoin and Ethereum.\n\nHere's how to generate an ECDSA private key for the secp256k1 curve:\n\n```go\nprivateKey, err := crypto.GeneratePrivateKey(crypto.ECDSA_secp256k1, seed)\n```\n\nHere's a full list of the supported signature and hash algorithms: [Flow Signature \u0026 Hash Algorithms](https://github.com/onflow/flow/blob/master/docs/content/concepts/accounts-and-keys.md#supported-signature--hash-algorithms)\n\n## Accessing The Flow Network\n\nYou can communicate with any Flow Access Node using the Flow Go SDK. This includes official Access Nodes, nodes you run yourself, and hosted nodes. Flow Go SDK supports both gRPC and HTTP methods of communication with Access Nodes.\n\n\u003e It's strongly recommended to use gRPC with Go SDK since it's more efficient and faster.\n\nHere's how to create a new gRPC client for any network:\n\n```go\n// You can also use grpc.TestnetHost and grpc.EmulatorHost\nflowClient, _ := grpc.NewClient(grpc.MainnetHost)\n```\n\nCheck out the [http_grpc_clients example](/examples/http_grpc_clients/main.go) to learn more.\n\n## Creating an Account\n\nOnce you have [generated a key pair](#generating-keys), you can create a new account\nusing its public key.\n\n```go\nimport (\n    \"github.com/onflow/flow-go-sdk\"\n    \"github.com/onflow/flow-go-sdk/crypto\"\n    \"github.com/onflow/flow-go-sdk/templates\"\n)\n\nctx := context.Background()\n\n// generate a new private key for the account\n// note: this is only an example, please use a secure random generator for the key seed\nseed := []byte(\"elephant ears space cowboy octopus rodeo potato cannon pineapple\")\nprivateKey, _ := crypto.GeneratePrivateKey(crypto.ECDSA_P256, seed)\n\n// get the public key\npublicKey := privateKey.PublicKey()\n\n// construct an account key from the public key\naccountKey := flow.NewAccountKey().\n    SetPublicKey(publicKey).\n    SetHashAlgo(crypto.SHA3_256).             // pair this key with the SHA3_256 hashing algorithm\n    SetWeight(flow.AccountKeyWeightThreshold) // give this key full signing weight\n\n// generate an account creation script\n// this creates an account with a single public key and no code\nscript, _ := templates.CreateAccount([]*flow.AccountKey{accountKey}, nil)\n\n// connect to an emulator running locally\nc, err := client.New(\"localhost:3569\")\nif err != nil {\n    panic(\"failed to connect to emulator\")\n}\n\npayer, payerKey, payerSigner := examples.ServiceAccount(c)\n\ntx := flow.NewTransaction().\n    SetScript(script).\n    SetComputeLimit(100).\n    SetProposalKey(payer, payerKey.Index, payerKey.SequenceNumber).\n    SetPayer(payer)\n\nerr = tx.SignEnvelope(payer, payerKey.Index, payerSigner)\nif err != nil {\n    panic(\"failed to sign transaction\")\n}\n\nerr = c.SendTransaction(ctx, *tx)\nif err != nil {\n    panic(\"failed to send transaction\")\n}\n\nresult, err := c.GetTransactionResult(ctx, tx.ID())\nif err != nil {\n    panic(\"failed to get transaction result\")\n}\n\nvar myAddress flow.Address\n\nif result.Status == flow.TransactionStatusSealed {\n    for _, event := range result.Events {\n        if event.Type == flow.EventAccountCreated {\n            accountCreatedEvent := flow.AccountCreatedEvent(event)\n            myAddress = accountCreatedEvent.Address()\n        }\n\t}\n}\n```\n\n## Signing a Transaction\n\nBelow is a simple example of how to sign a transaction using a `crypto.PrivateKey`.\n\n```go\nimport (\n    \"github.com/onflow/flow-go-sdk\"\n    \"github.com/onflow/flow-go-sdk/crypto\"\n)\n\nvar (\n    myAddress    flow.Address\n    myAccountKey flow.AccountKey\n    myPrivateKey crypto.PrivateKey\n)\n\ntx := flow.NewTransaction().\n    SetScript([]byte(\"transaction { execute { log(\\\"Hello, World!\\\") } }\")).\n    SetComputeLimit(100).\n    SetProposalKey(myAddress, myAccountKey.Index, myAccountKey.SequenceNumber).\n    SetPayer(myAddress)\n```\n\nTransaction signing is done through the `crypto.Signer` interface. The simplest\n(and least secure) implementation of `crypto.Signer` is `crypto.InMemorySigner`.\n\nSignatures can be generated more securely using keys stored in a hardware device such\nas an [HSM](https://en.wikipedia.org/wiki/Hardware_security_module). The `crypto.Signer`\ninterface is intended to be flexible enough to support a variety of signer implementations\nand is not limited to in-memory implementations.\n\n```go\n// construct a signer from your private key and configured hash algorithm\nmySigner, err := crypto.NewInMemorySigner(myPrivateKey, myAccountKey.HashAlgo)\nif err != nil {\n    panic(\"failed to create a signer\")\n}\n\nerr = tx.SignEnvelope(myAddress, myAccountKey.Index, mySigner)\nif err != nil {\n    panic(\"failed to sign transaction\")\n}\n```\n\n### How Signatures Work in Flow\n\nFlow introduces new concepts that allow for more flexibility when creating and signing transactions.\nBefore trying the examples below, we recommend that you read through the [transaction signature documentation](https://github.com/onflow/flow/blob/master/docs/content/concepts/accounts-and-keys.md#signing-a-transaction).\n\n---\n\n#### [Single party, single signature](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#single-party-single-signature)\n\n- Proposer, payer and authorizer are the same account (`0x01`).\n- Only the envelope must be signed.\n- Proposal key must have full signing weight.\n\n| Account   | Key ID | Weight |\n|-----------|--------|--------|\n| `0x01`    | 1      | 1000   |\n\n```go\naccount1, _ := c.GetAccount(ctx, flow.HexToAddress(\"01\"))\n\nkey1 := account1.Keys[0]\n\n// create signer from securely-stored private key\nkey1Signer := getSignerForKey1()\n\ntx := flow.NewTransaction().\n    SetScript([]byte(`\n        transaction {\n            prepare(signer: AuthAccount) { log(signer.address) }\n        }\n    `)).\n    SetComputeLimit(100).\n    SetProposalKey(account1.Address, key1.Index, key1.SequenceNumber).\n    SetPayer(account1.Address).\n    AddAuthorizer(account1.Address)\n\n// account 1 signs the envelope with key 1\nerr := tx.SignEnvelope(account1.Address, key1.Index, key1Signer)\n```\n\n[Full Runnable Example](/examples#single-party-single-signature)\n\n---\n\n#### [Single party, multiple signatures](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#single-party-multiple-signatures)\n\n- Proposer, payer and authorizer are the same account (`0x01`).\n- Only the envelope must be signed.\n- Each key has weight 500, so two signatures are required.\n\n| Account   | Key ID | Weight |\n|-----------|--------|--------|\n| `0x01`    | 1      | 500    |\n| `0x01`    | 2      | 500    |\n\n```go\naccount1, _ := c.GetAccount(ctx, flow.HexToAddress(\"01\"))\n\nkey1 := account1.Keys[0]\nkey2 := account1.Keys[1]\n\n// create signers from securely-stored private keys\nkey1Signer := getSignerForKey1()\nkey2Signer := getSignerForKey2()\n\ntx := flow.NewTransaction().\n    SetScript([]byte(`\n        transaction {\n            prepare(signer: AuthAccount) { log(signer.address) }\n        }\n    `)).\n    SetComputeLimit(100).\n    SetProposalKey(account1.Address, key1.Index, key1.SequenceNumber).\n    SetPayer(account1.Address).\n    AddAuthorizer(account1.Address)\n\n// account 1 signs the envelope with key 1\nerr := tx.SignEnvelope(account1.Address, key1.Index, key1Signer)\n\n// account 1 signs the envelope with key 2\nerr = tx.SignEnvelope(account1.Address, key2.Index, key2Signer)\n```\n\n[Full Runnable Example](/examples#single-party-multiple-signatures)\n\n---\n\n#### [Multiple parties](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties)\n\n- Proposer and authorizer are the same account (`0x01`).\n- Payer is a separate account (`0x02`).\n- Account `0x01` signs the payload.\n- Account `0x02` signs the envelope.\n  - Account `0x02` must sign last since it is the payer.\n\n| Account   | Key ID | Weight |\n|-----------|--------|--------|\n| `0x01`    | 1      | 1000   |\n| `0x02`    | 3      | 1000   |\n\n```go\naccount1, _ := c.GetAccount(ctx, flow.HexToAddress(\"01\"))\naccount2, _ := c.GetAccount(ctx, flow.HexToAddress(\"02\"))\n\nkey1 := account1.Keys[0]\nkey3 := account2.Keys[0]\n\n// create signers from securely-stored private keys\nkey1Signer := getSignerForKey1()\nkey3Signer := getSignerForKey3()\n\ntx := flow.NewTransaction().\n    SetScript([]byte(`\n        transaction {\n            prepare(signer: AuthAccount) { log(signer.address) }\n        }\n    `)).\n    SetComputeLimit(100).\n    SetProposalKey(account1.Address, key1.Index, key1.SequenceNumber).\n    SetPayer(account2.Address).\n    AddAuthorizer(account1.Address)\n\n// account 1 signs the payload with key 1\nerr := tx.SignPayload(account1.Address, key1.Index, key1Signer)\n\n// account 2 signs the envelope with key 3\n// note: payer always signs last\nerr = tx.SignEnvelope(account2.Address, key3.Index, key3Signer)\n```\n\n[Full Runnable Example](/examples#multiple-parties)\n\n---\n#### [Multiple parties, two authorizers](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties)\n\n- Proposer and authorizer are the same account (`0x01`).\n- Payer is a separate account (`0x02`).\n- Account `0x01` signs the payload.\n- Account `0x02` signs the envelope.\n  - Account `0x02` must sign last since it is the payer.\n- Account `0x02` is also an authorizer to show how to include two AuthAccounts into an transaction\n\n| Account   | Key ID | Weight |\n|-----------|--------|--------|\n| `0x01`    | 1      | 1000   |\n| `0x02`    | 3      | 1000   |\n\n```go\naccount1, _ := c.GetAccount(ctx, flow.HexToAddress(\"01\"))\naccount2, _ := c.GetAccount(ctx, flow.HexToAddress(\"02\"))\n\nkey1 := account1.Keys[0]\nkey3 := account2.Keys[0]\n\n// create signers from securely-stored private keys\nkey1Signer := getSignerForKey1()\nkey3Signer := getSignerForKey3()\n\ntx := flow.NewTransaction().\n    SetScript([]byte(`\n        transaction {\n            prepare(signer1: AuthAccount, signer2: AuthAccount) {\n              log(signer.address)\n              log(signer2.address)\n          }\n        }\n    `)).\n    SetComputeLimit(100).\n    SetProposalKey(account1.Address, key1.Index, key1.SequenceNumber).\n    SetPayer(account2.Address).\n    AddAuthorizer(account1.Address).\n    AddAuthorizer(account2.Address)\n\n// account 1 signs the payload with key 1\nerr := tx.SignPayload(account1.Address, key1.Index, key1Signer)\n\n// account 2 signs the envelope with key 3\n// note: payer always signs last\nerr = tx.SignEnvelope(account2.Address, key3.Index, key3Signer)\n```\n\n[Full Runnable Example](/examples#multiple-parties-two-authorizers)\n\n---\n\n#### [Multiple parties, multiple signatures](https://github.com/onflow/flow/blob/master/docs/accounts-and-keys.md#multiple-parties-multiple-signatures)\n\n- Proposer and authorizer are the same account (`0x01`).\n- Payer is a separate account (`0x02`).\n- Account `0x01` signs the payload.\n- Account `0x02` signs the envelope.\n  - Account `0x02` must sign last since it is the payer.\n- Both accounts must sign twice (once with each of their keys).\n\n| Account   | Key ID | Weight |\n|-----------|--------|--------|\n| `0x01`    | 1      | 500    |\n| `0x01`    | 2      | 500    |\n| `0x02`    | 3      | 500    |\n| `0x02`    | 4      | 500    |\n\n```go\naccount1, _ := c.GetAccount(ctx, flow.HexToAddress(\"01\"))\naccount2, _ := c.GetAccount(ctx, flow.HexToAddress(\"02\"))\n\nkey1 := account1.Keys[0]\nkey2 := account1.Keys[1]\nkey3 := account2.Keys[0]\nkey4 := account2.Keys[1]\n\n// create signers from securely-stored private keys\nkey1Signer := getSignerForKey1()\nkey2Signer := getSignerForKey1()\nkey3Signer := getSignerForKey3()\nkey4Signer := getSignerForKey4()\n\ntx := flow.NewTransaction().\n    SetScript([]byte(`\n        transaction {\n            prepare(signer: AuthAccount) { log(signer.address) }\n        }\n    `)).\n    SetComputeLimit(100).\n    SetProposalKey(account1.Address, key1.Index, key1.SequenceNumber).\n    SetPayer(account2.Address).\n    AddAuthorizer(account1.Address)\n\n// account 1 signs the payload with key 1\nerr := tx.SignPayload(account1.Address, key1.Index, key1Signer)\n\n// account 1 signs the payload with key 2\nerr = tx.SignPayload(account1.Address, key2.Index, key2Signer)\n\n// account 2 signs the envelope with key 3\n// note: payer always signs last\nerr = tx.SignEnvelope(account2.Address, key3.Index, key3Signer)\n\n// account 2 signs the envelope with key 4\n// note: payer always signs last\nerr = tx.SignEnvelope(account2.Address, key4.Index, key4Signer)\n```\n\n[Full Runnable Example](/examples#multiple-parties-multiple-signatures)\n\n## Sending a Transaction\n\nYou can submit a transaction to the network using the Access API client.\n\n```go\nimport \"github.com/onflow/flow-go-sdk/access\"\n\n// connect to an emulator running locally\nc, err := client.New(\"localhost:3569\")\nif err != nil {\n    panic(\"failed to connect to emulator\")\n}\n\nctx := context.Background()\n\nerr = c.SendTransaction(ctx, tx)\nif err != nil {\n    panic(\"failed to send transaction\")\n}\n```\n\n## Querying Transaction Results\n\nAfter you have submitted a transaction, you can query its status by ID:\n\n```go\nresult, err := c.GetTransactionResult(ctx, tx.ID())\nif err != nil {\n    panic(\"failed to fetch transaction result\")\n}\n```\n\nThe result includes a `Status` field that will be one of the following values:\n- `UNKNOWN` - The transaction has not yet been seen by the network.\n- `PENDING` - The transaction has not yet been included in a block.\n- `FINALIZED` - The transaction has been included in a block.\n- `EXECUTED` - The transaction has been executed but the result has not yet been sealed.\n- `SEALED` - The transaction has been executed and the result is sealed in a block.\n\n```go\nif result.Status == flow.TransactionStatusSealed {\n  fmt.Println(\"Transaction is sealed!\")\n}\n```\n\nThe result also contains an `Error` that holds the error information for a failed transaction.\n\n```go\nif result.Error != nil {\n    fmt.Printf(\"Transaction failed with error: %v\\n\", result.Error)\n}\n```\n\n## Querying Blocks\n\nYou can use the `GetLatestBlock` method to fetch the latest sealed or unsealed block:\n\n```go\n// fetch the latest sealed block\nisSealed := true\nlatestBlock, err := c.GetLatestBlock(ctx, isSealed)\nif err != nil {\n    panic(\"failed to fetch latest sealed block\")\n}\n\n// fetch the latest unsealed block\nisSealed := false\nlatestBlock, err := c.GetLatestBlock(ctx, isSealed)\nif err != nil {\n    panic(\"failed to fetch latest unsealed block\")\n}\n```\n\nA block contains the following fields:\n\n- `ID` - The ID (hash) of the block.\n- `ParentBlockID` - The ID of the previous block in the chain.\n- `Height` - The height of the block in the chain.\n- `CollectionGuarantees` - The list of collections included in the block.\n\n## Executing a Script\n\nYou can use the `ExecuteScriptAtLatestBlock` method to execute a read-only script against the latest sealed execution state.\n\nThis functionality can be used to read state from the blockchain.\n\nScripts must be in the following form:\n\n- A single `main` function with a single return value\n\nThis is an example of a valid script:\n\n```\nfun main(): Int { return 1 }\n```\n\n```go\nimport \"github.com/onflow/cadence\"\n\nscript := []byte(\"fun main(): Int { return 1 }\")\n\nvalue, err := c.ExecuteScriptAtLatestBlock(ctx, script, nil)\nif err != nil {\n    panic(\"failed to execute script\")\n}\n\nID := value.(cadence.Int)\n\n// convert to Go int type\nmyID := ID.Int()\n```\n\n## Querying Events\n\nYou can query events with the `GetEventsForHeightRange` function:\n\n```go\nimport \"github.com/onflow/flow-go-sdk/access\"\n\nblocks, err := c.GetEventsForHeightRange(ctx, client.EventRangeQuery{\n    Type:       \"flow.AccountCreated\",\n    StartHeight: 10,\n    EndHeight:   15,\n})\nif err != nil {\n    panic(\"failed to query events\")\n}\n```\n\n### Event Query Format\n\nAn event query includes the following fields:\n\n**Type**\n\nThe event type to filter by. Event types are namespaced by the account and contract in which they are declared.\n\nFor example, a `Transfer` event that was defined in the `Token` contract deployed at account `0x55555555555555555555` will have a type of `A.0x55555555555555555555.Token.Transfer`.\n\nRead the [language documentation](https://docs.onflow.org/cadence/language/events/) for more information on how to define and emit events in Cadence.\n\n**StartHeight, EndHeight**\n\nThe blocks to filter by. Events will be returned from blocks in the range `StartHeight` to `EndHeight`, inclusive.\n\n### Event Results\n\nThe `GetEventsForHeightRange` function returns events grouped by block. Each block contains a list of events matching the query in order of execution.\n\n```go\nfor _, block := range blocks {\n    fmt.Printf(\"Events for block %s:\\n\", block.BlockID)\n    for _, event := range block.Events {\n        fmt.Printf(\" - %s\", event)\n    }\n}\n```\n\n\u003c!--\n### Decoding an Event\n\nTODO: example for event decoding\n--\u003e\n\n## Querying Accounts\n\nYou can query the state of an account with the `GetAccount` function:\n\n```go\nimport \"github.com/onflow/flow-go-sdk\"\n\naddress := flow.HexToAddress(\"01\")\n\naccount, err := c.GetAccount(ctx, address)\nif err != nil {\n    panic(\"failed to fetch account\")\n}\n```\n\nA `flow.Account` contains the following fields:\n\n- `Address: flow.Address` - The account address.\n- `Balance: uint64` - The account balance.\n- `Code: []byte` - The code deployed at this account.\n- `Keys: []flow.AccountKey` - A list of the public keys associated with this account.\n\n## Examples\n\nThe [examples](/examples) directory contains code samples that use the SDK to interact with the [Flow Emulator](https://docs.onflow.org/devtools/emulator/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonflow%2Fflow-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonflow%2Fflow-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonflow%2Fflow-go-sdk/lists"}