├── .git-blame-ignore-revs ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── release.yml └── workflows │ ├── ci-pr.yml │ ├── codegen.yml │ ├── create-release-pr.yml │ ├── pr-type-category.yml │ ├── release.yml │ └── reviewdog.yml ├── .gitignore ├── .golangci.yml ├── .test-env ├── CHANGELOG.md ├── CLAUDE.md ├── CODE_OF_CONDUCT.md ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── _examples ├── account.go ├── application │ ├── approval.teal │ ├── approval_refactored.teal │ └── clear.teal ├── apps.go ├── asa.go ├── atc.go ├── atomic_transfer.go ├── calculator │ ├── approval.teal │ ├── clear.teal │ └── contract.json ├── codec.go ├── debug.go ├── indexer.go ├── kmd.go ├── lsig.go ├── lsig │ ├── sample_arg.teal │ └── simple.teal ├── overview.go ├── participation.go └── util.go ├── abi ├── abi.go ├── abi_test.go ├── interactions.go └── interactions_test.go ├── auction └── auction.go ├── client ├── README.md ├── kmd │ ├── common.go │ ├── kmd.go │ ├── requests.go │ ├── responses.go │ └── wrappers.go └── v2 │ ├── algod │ ├── accountApplicationInformation.go │ ├── accountAssetInformation.go │ ├── accountInformation.go │ ├── algod.go │ ├── blockRaw.go │ ├── dryrun.go │ ├── getApplicationBoxByName.go │ ├── getApplicationBoxes.go │ ├── getApplicationByID.go │ ├── getAssetByID.go │ ├── getBlock.go │ ├── getBlockHash.go │ ├── getBlockLogs.go │ ├── getBlockTimeStampOffset.go │ ├── getBlockTxids.go │ ├── getGenesis.go │ ├── getLedgerStateDelta.go │ ├── getLedgerStateDeltaForTransactionGroup.go │ ├── getLightBlockHeaderProof.go │ ├── getPendingTransactions.go │ ├── getPendingTransactionsByAddress.go │ ├── getReady.go │ ├── getStateProof.go │ ├── getStatus.go │ ├── getSupply.go │ ├── getSyncRound.go │ ├── getTransactionGroupLedgerStateDeltasForRound.go │ ├── getTransactionProof.go │ ├── getVersion.go │ ├── healthCheck.go │ ├── pendingTransactionInformation.go │ ├── rawTransaction.go │ ├── setBlockTimeStampOffset.go │ ├── setSyncRound.go │ ├── simulateTransaction.go │ ├── tealCompile.go │ ├── tealDisassemble.go │ ├── tealDryrun.go │ ├── transactionParams.go │ ├── unsetSyncRound.go │ └── waitForBlock.go │ ├── common │ ├── common.go │ ├── common_test.go │ └── models │ │ ├── account.go │ │ ├── account_application_response.go │ │ ├── account_asset_holding.go │ │ ├── account_asset_response.go │ │ ├── account_assets_information_response.go │ │ ├── account_error_response.go │ │ ├── account_participation.go │ │ ├── account_response.go │ │ ├── account_state_delta.go │ │ ├── accounts_response.go │ │ ├── app_call_logs.go │ │ ├── application.go │ │ ├── application_initial_states.go │ │ ├── application_k_v_storage.go │ │ ├── application_local_reference.go │ │ ├── application_local_state.go │ │ ├── application_local_states_response.go │ │ ├── application_log_data.go │ │ ├── application_logs_response.go │ │ ├── application_params.go │ │ ├── application_response.go │ │ ├── application_state_operation.go │ │ ├── application_state_schema.go │ │ ├── applications_response.go │ │ ├── asset.go │ │ ├── asset_balances_response.go │ │ ├── asset_holding.go │ │ ├── asset_holding_reference.go │ │ ├── asset_holdings_response.go │ │ ├── asset_params.go │ │ ├── asset_response.go │ │ ├── assets_response.go │ │ ├── avm_key_value.go │ │ ├── avm_value.go │ │ ├── block.go │ │ ├── block_hash_response.go │ │ ├── block_headers_response.go │ │ ├── block_logs_response.go │ │ ├── block_response.go │ │ ├── block_rewards.go │ │ ├── block_txids_response.go │ │ ├── block_upgrade_state.go │ │ ├── block_upgrade_vote.go │ │ ├── box.go │ │ ├── box_descriptor.go │ │ ├── box_reference.go │ │ ├── boxes_response.go │ │ ├── build_version.go │ │ ├── compile_response.go │ │ ├── disassemble_response.go │ │ ├── dryrun_request.go │ │ ├── dryrun_response.go │ │ ├── dryrun_source.go │ │ ├── dryrun_state.go │ │ ├── dryrun_txn_result.go │ │ ├── error_response.go │ │ ├── eval_delta.go │ │ ├── eval_delta_key_value.go │ │ ├── genesis.go │ │ ├── genesis_allocation.go │ │ ├── get_block_time_stamp_offset_response.go │ │ ├── get_sync_round_response.go │ │ ├── hash_factory.go │ │ ├── hb_proof_fields.go │ │ ├── health_check.go │ │ ├── holding_ref.go │ │ ├── indexer_state_proof_message.go │ │ ├── ledger_state_delta_for_transaction_group.go │ │ ├── light_block_header_proof.go │ │ ├── locals_ref.go │ │ ├── merkle_array_proof.go │ │ ├── mini_asset_holding.go │ │ ├── node_status_response.go │ │ ├── participation_updates.go │ │ ├── pending_transaction_response.go │ │ ├── pending_transactions_response.go │ │ ├── post_transactions_response.go │ │ ├── resource_ref.go │ │ ├── scratch_change.go │ │ ├── shim.go │ │ ├── simulate_initial_states.go │ │ ├── simulate_request.go │ │ ├── simulate_request_transaction_group.go │ │ ├── simulate_response.go │ │ ├── simulate_trace_config.go │ │ ├── simulate_transaction_group_result.go │ │ ├── simulate_transaction_result.go │ │ ├── simulate_unnamed_resources_accessed.go │ │ ├── simulation_eval_overrides.go │ │ ├── simulation_opcode_trace_unit.go │ │ ├── simulation_transaction_exec_trace.go │ │ ├── state_proof.go │ │ ├── state_proof_fields.go │ │ ├── state_proof_message.go │ │ ├── state_proof_participant.go │ │ ├── state_proof_reveal.go │ │ ├── state_proof_sig_slot.go │ │ ├── state_proof_signature.go │ │ ├── state_proof_tracking.go │ │ ├── state_proof_verifier.go │ │ ├── state_schema.go │ │ ├── supply_response.go │ │ ├── teal_key_value.go │ │ ├── teal_value.go │ │ ├── transaction.go │ │ ├── transaction_application.go │ │ ├── transaction_asset_config.go │ │ ├── transaction_asset_freeze.go │ │ ├── transaction_asset_transfer.go │ │ ├── transaction_group_ledger_state_deltas_for_round_response.go │ │ ├── transaction_heartbeat.go │ │ ├── transaction_keyreg.go │ │ ├── transaction_parameters_response.go │ │ ├── transaction_payment.go │ │ ├── transaction_proof.go │ │ ├── transaction_response.go │ │ ├── transaction_signature.go │ │ ├── transaction_signature_logicsig.go │ │ ├── transaction_signature_multisig.go │ │ ├── transaction_signature_multisig_subsignature.go │ │ ├── transaction_state_proof.go │ │ ├── transactions_response.go │ │ └── version.go │ └── indexer │ ├── indexer.go │ ├── lookupAccountAppLocalStates.go │ ├── lookupAccountAssets.go │ ├── lookupAccountByID.go │ ├── lookupAccountCreatedApplications.go │ ├── lookupAccountCreatedAssets.go │ ├── lookupAccountTransactions.go │ ├── lookupApplicationBoxByIDAndName.go │ ├── lookupApplicationByID.go │ ├── lookupApplicationLogsByID.go │ ├── lookupAssetBalances.go │ ├── lookupAssetByID.go │ ├── lookupAssetTransactions.go │ ├── lookupBlock.go │ ├── lookupTransaction.go │ ├── makeHealthCheck.go │ ├── searchForAccounts.go │ ├── searchForApplicationBoxes.go │ ├── searchForApplications.go │ ├── searchForAssets.go │ ├── searchForBlockHeaders.go │ └── searchForTransactions.go ├── crypto ├── account.go ├── account_test.go ├── crypto.go ├── crypto_test.go ├── errors.go ├── msig_delegated.txn └── msig_delegated_other.txn ├── encoding ├── json │ ├── json.go │ └── json_test.go └── msgpack │ ├── msgpack.go │ └── msgpack_test.go ├── examples ├── README.md ├── account │ └── main.go ├── application │ ├── approval.teal │ ├── approval_refactored.teal │ └── clear.teal ├── apps │ └── main.go ├── asa │ └── main.go ├── atc │ └── main.go ├── atomic_transactions │ └── main.go ├── calculator │ ├── approval.teal │ ├── clear.teal │ └── contract.json ├── codec │ └── main.go ├── debug │ └── main.go ├── indexer │ └── main.go ├── kmd │ └── main.go ├── lsig │ ├── main.go │ ├── sample_arg.teal │ └── simple.teal ├── overview │ └── main.go ├── participation │ └── main.go ├── smoke_test.sh └── utils.go ├── go.mod ├── go.sum ├── logic └── source_map.go ├── mnemonic ├── errors.go ├── helpers.go ├── mnemonic.go ├── mnemonic_test.go └── wordlist.go ├── protocol ├── config │ ├── config.go │ └── consensus.go └── consensus.go ├── test-harness.sh ├── test ├── algodclientv2_test.go ├── applications_integration_test.go ├── applications_unit_test.go ├── docker │ └── Dockerfile ├── helpers.go ├── indexer_unit_test.go ├── integration.tags ├── responses_unit_test.go ├── steps_test.go ├── transactions_test.go ├── unit.tags └── utilities.go ├── transaction ├── atomicTransactionComposer.go ├── atomicTransactionComposer_test.go ├── dryrun.go ├── transaction.go ├── transactionSigner.go ├── transactionSigner_test.go ├── transaction_test.go └── waitForConfirmation.go └── types ├── address.go ├── address_test.go ├── applications.go ├── asset.go ├── auction.go ├── basics.go ├── basics_test.go ├── block.go ├── blockhash.go ├── blockhash_test.go ├── errors.go ├── genesis.go ├── genesis_test.go ├── heartbeat.go ├── lightBlockHeader.go ├── overflow.go ├── signature.go ├── statedelta.go ├── stateproof.go ├── test_resource └── mainnet_genesis.json └── transaction.go /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # .git-blame-ignore-revs 2 | # Formatting fixes for transaction/ and abi/ 3 | 09351b56fff3459b5d4701ae681ec45b4b62d945 4 | # Formatting fixes in test/ 5 | 23c3faf0701b0d5c07c57dd7fca4ed77449f3209 6 | # Formatting fixes in logic/ and crypto/ 7 | ebccd4939d84d3233e6fbb5fddb2332549a0f323 8 | # Formatting fixes in types/ 9 | f99ffb34b9955fdaa366326fe97da49e761e9367 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41C Bug report" 3 | about: Report a reproducible bug. 4 | title: '' 5 | labels: new-bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Subject of the issue 11 | 12 | 13 | 14 | ### Your environment 15 | 16 | 22 | 23 | ### Steps to reproduce 24 | 25 | 1. 26 | 2. 27 | 28 | ### Expected behaviour 29 | 30 | ### Actual behaviour 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F514 Feature Request" 3 | about: Suggestions for how we can improve the algorand platform. 4 | title: '' 5 | labels: new-feature-request 6 | assignees: '' 7 | --- 8 | 9 | ## Problem 10 | 11 | 12 | 13 | ## Solution 14 | 15 | 16 | 17 | ## Dependencies 18 | 19 | 20 | 21 | ## Urgency 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - Skip-Release-Notes 5 | categories: 6 | - title: Bugfixes 7 | labels: 8 | - Bug-Fix 9 | - title: New Features 10 | labels: 11 | - New Feature 12 | - title: Enhancements 13 | labels: 14 | - Enhancement 15 | - title: Not Yet Enabled 16 | labels: 17 | - Not-Yet-Enabled 18 | - title: Other 19 | labels: 20 | - "*" 21 | -------------------------------------------------------------------------------- /.github/workflows/ci-pr.yml: -------------------------------------------------------------------------------- 1 | name: Test Suite 2 | 3 | on: 4 | pull_request: 5 | branches: [ main ] 6 | push: 7 | branches: [ main ] 8 | 9 | concurrency: 10 | group: pr-${{ github.event.pull_request.number || github.ref }} 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | test: 15 | name: Run Test Suites 16 | runs-on: ubuntu-24.04 17 | 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@v4 21 | 22 | - name: Set up Go 23 | uses: actions/setup-go@v6 24 | with: 25 | go-version-file: 'go.mod' 26 | 27 | - name: Run Unit Tests 28 | run: make unit 29 | 30 | - name: Run Integration Tests 31 | run: make integration 32 | 33 | - name: Run Smoke Tests 34 | run: make ci-test 35 | -------------------------------------------------------------------------------- /.github/workflows/codegen.yml: -------------------------------------------------------------------------------- 1 | name: "SDK Code Generation" 2 | on: 3 | schedule: 4 | - cron: '20 23 * * *' 5 | permissions: 6 | contents: write 7 | pull-requests: write 8 | jobs: 9 | generate_and_pr: 10 | runs-on: ubuntu-24.04 11 | steps: 12 | - name: Check out repository 13 | uses: actions/checkout@v4 14 | - name: Generate and PR 15 | uses: algorand/generator/.github/actions/sdk-codegen/@master 16 | with: 17 | args: "-k GO" 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | -------------------------------------------------------------------------------- /.github/workflows/pr-type-category.yml: -------------------------------------------------------------------------------- 1 | name: Check PR category and type 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | types: [opened, synchronize, reopened, labeled, unlabeled, edited] 7 | jobs: 8 | check_label: 9 | runs-on: ubuntu-latest 10 | name: Check PR Category and Type 11 | steps: 12 | - name: Checking for correct number of required github pr labels 13 | uses: mheap/github-action-required-labels@v5 14 | with: 15 | mode: exactly 16 | count: 1 17 | labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes" 18 | 19 | - name: "Checking for PR Category in PR title. Should be like ': '." 20 | env: 21 | PR_TITLE: ${{ github.event.pull_request.title }} 22 | run: | 23 | if [[ ! "$PR_TITLE" =~ ^.{2,}\:.{2,} ]]; then 24 | echo "## PR Category is missing from PR title. Please add it like ': '." >> GITHUB_STEP_SUMMARY 25 | exit 1 26 | fi 27 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: "Lint Checks" 2 | on: 3 | pull_request: 4 | jobs: 5 | lint: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Check out code into the Go module directory 9 | uses: actions/checkout@v4 10 | with: 11 | fetch-depth: 0 # required for new-from-rev option in .golangci.yml 12 | - name: Install specific golang 13 | uses: actions/setup-go@v6 14 | with: 15 | go-version-file: 'go.mod' 16 | - name: Check format 17 | run: test -z `go fmt ./...` 18 | - name: Vet 19 | run: go vet ./... 20 | - name: reviewdog-golangci-lint 21 | uses: reviewdog/action-golangci-lint@v2.8 22 | with: 23 | golangci_lint_version: "v2.5.0" 24 | golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners" 25 | go_version_file: "go.mod" 26 | reporter: "github-pr-review" 27 | tool_name: "Lint Errors" 28 | level: "error" 29 | fail_on_error: true 30 | filter_mode: "nofilter" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore cucumber test resources 2 | test-harness/ 3 | test/features/ 4 | test/features/resources/**/*.json 5 | test/features/resources/**/*.base64 6 | test/features/resources/programs/**/*.tok 7 | 8 | # Other misc files 9 | *.log 10 | *.log.archive 11 | *.out 12 | *.prof 13 | coverage.html 14 | 15 | # Exclude GoLand files 16 | .idea/ 17 | 18 | # Ignore vim backup and swap files 19 | *~ 20 | *.swp 21 | *.swo 22 | 23 | .vscode 24 | 25 | # Mac 26 | .DS_Store 27 | 28 | # Testing files 29 | *.feature 30 | temp 31 | 32 | # asdf 33 | .tool-versions 34 | -------------------------------------------------------------------------------- /.test-env: -------------------------------------------------------------------------------- 1 | # Configs for testing repo download: 2 | SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing" 3 | SDK_TESTING_BRANCH="master" 4 | SDK_TESTING_HARNESS="test-harness" 5 | 6 | INSTALL_ONLY=0 7 | 8 | VERBOSE_HARNESS=1 9 | 10 | # WARNING: If set to 1, new features will be LOST when downloading the test harness. 11 | # REGARDLESS: modified features are ALWAYS overwritten. 12 | REMOVE_LOCAL_FEATURES=0 13 | 14 | # WARNING: Be careful when turning on the next variable. 15 | # In that case you'll need to provide all variables expected by `algorand-sdk-testing`'s `.env` 16 | OVERWRITE_TESTING_ENVIRONMENT=0 17 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | digest = "1:659fa237f7089594d4235f8f11b760e21a3eafc3dc3e9c052b4ac3d4e5731618" 7 | name = "github.com/algorand/go-codec" 8 | packages = ["codec"] 9 | pruneopts = "UT" 10 | revision = "269d70b6135dc6554dae9880724d1c8209573c23" 11 | 12 | [[projects]] 13 | digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" 14 | name = "github.com/davecgh/go-spew" 15 | packages = ["spew"] 16 | pruneopts = "UT" 17 | revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" 18 | version = "v1.1.1" 19 | 20 | [[projects]] 21 | digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690" 22 | name = "github.com/google/go-querystring" 23 | packages = ["query"] 24 | pruneopts = "UT" 25 | revision = "44c6ddd0a2342c386950e880b658017258da92fc" 26 | version = "v1.0.0" 27 | 28 | [[projects]] 29 | digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" 30 | name = "github.com/pmezard/go-difflib" 31 | packages = ["difflib"] 32 | pruneopts = "UT" 33 | revision = "792786c7400a136282c1664665ae0a8db921c6c2" 34 | version = "v1.0.0" 35 | 36 | [[projects]] 37 | digest = "1:5da8ce674952566deae4dbc23d07c85caafc6cfa815b0b3e03e41979cedb8750" 38 | name = "github.com/stretchr/testify" 39 | packages = [ 40 | "assert", 41 | "require", 42 | ] 43 | pruneopts = "UT" 44 | revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053" 45 | version = "v1.3.0" 46 | 47 | [[projects]] 48 | branch = "master" 49 | digest = "1:cd7e85fc3687e062714febdee3e8efeb00a413a2a620d28908fd0258261d2353" 50 | name = "golang.org/x/crypto" 51 | packages = [ 52 | "ed25519", 53 | "ed25519/internal/edwards25519", 54 | ] 55 | pruneopts = "UT" 56 | revision = "4def268fd1a49955bfb3dda92fe3db4f924f2285" 57 | 58 | [solve-meta] 59 | analyzer-name = "dep" 60 | analyzer-version = 1 61 | input-imports = [ 62 | "github.com/algorand/go-codec/codec", 63 | "github.com/google/go-querystring/query", 64 | "github.com/stretchr/testify/require", 65 | "golang.org/x/crypto/ed25519", 66 | ] 67 | solver-name = "gps-cdcl" 68 | solver-version = 1 69 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [prune] 29 | go-tests = true 30 | unused-packages = true 31 | 32 | [[constraint]] 33 | name = "github.com/stretchr/testify" 34 | version = "1.3.0" 35 | 36 | [[constraint]] 37 | branch = "master" 38 | name = "github.com/algorand/go-codec" 39 | 40 | [[constraint]] 41 | branch = "master" 42 | name = "golang.org/x/crypto" 43 | 44 | [[constraint]] 45 | name = "github.com/google/go-querystring" 46 | version = "1.0.0" 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Algorand, llc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SRCPATH := $(shell pwd) 2 | TEST_SOURCES := $(shell cd $(SRCPATH) && go list ./...) 3 | TEST_SOURCES_NO_CUCUMBER := $(shell cd $(SRCPATH) && go list ./... | grep -v test) 4 | UNIT_TAGS := "$(shell awk '{print $2}' test/unit.tags | paste -s -d, -)" 5 | INTEGRATIONS_TAGS := "$(shell awk '{print $2}' test/integration.tags | paste -s -d, -)" 6 | GO_IMAGE := golang:$(subst go,,$(shell go version | cut -d' ' -f 3 | cut -d'.' -f 1,2))-bookworm 7 | 8 | lint: 9 | GOTOOLCHAIN=auto go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0 run -c .golangci.yml 10 | go vet ./... 11 | 12 | fmt: 13 | go fmt ./... 14 | 15 | generate: 16 | cd $(SRCPATH) && go generate ./logic 17 | 18 | build: generate 19 | cd $(SRCPATH) && go test -run xxx_phony_test $(TEST_SOURCES) 20 | 21 | test: 22 | go test $(TEST_SOURCES_NO_CUCUMBER) 23 | 24 | unit: 25 | go test $(TEST_SOURCES_NO_CUCUMBER) 26 | cd test && go test -timeout 0s --godog.strict=true --godog.format=pretty --godog.tags=$(UNIT_TAGS) --test.v . 27 | 28 | integration: 29 | go test $(TEST_SOURCES_NO_CUCUMBER) 30 | cd test && go test -timeout 0s --godog.strict=true --godog.format=pretty --godog.tags=$(INTEGRATIONS_TAGS) --test.v . 31 | 32 | display-all-go-steps: 33 | find test -name "*.go" | xargs grep "github.com/cucumber/godog" 2>/dev/null | cut -d: -f1 | sort | uniq | xargs grep -Eo "Step[(].[^\`]+" | awk '{sub(/:Step\(./,":")} 1' | sed -E 's/", [a-zA-Z0-9]+\)//g' 34 | 35 | harness: 36 | ./test-harness.sh up 37 | 38 | harness-down: 39 | ./test-harness.sh down 40 | 41 | docker-gosdk-build: 42 | echo "Building docker image from base $(GO_IMAGE)" 43 | docker build -t go-sdk-testing --build-arg GO_IMAGE="$(GO_IMAGE)" -f test/docker/Dockerfile $(shell pwd) 44 | 45 | docker-gosdk-run: 46 | docker ps -a 47 | docker run -t --network host go-sdk-testing:latest 48 | 49 | smoke-test-examples: 50 | cd "$(SRCPATH)/examples" && bash smoke_test.sh && cd - 51 | 52 | docker-test: harness docker-gosdk-build docker-gosdk-run 53 | 54 | ci-test: harness smoke-test-examples 55 | 56 | .PHONY: test fmt ci-test 57 | -------------------------------------------------------------------------------- /_examples/application/approval.teal: -------------------------------------------------------------------------------- 1 | #pragma version 4 2 | // Handle each possible OnCompletion type. We don't have to worry about 3 | // handling ClearState, because the ClearStateProgram will execute in that 4 | // case, not the ApprovalProgram. 5 | txn ApplicationID 6 | int 0 7 | == 8 | bnz handle_approve 9 | 10 | txn OnCompletion 11 | int NoOp 12 | == 13 | bnz handle_noop 14 | 15 | txn OnCompletion 16 | int OptIn 17 | == 18 | bnz handle_approve 19 | 20 | txn OnCompletion 21 | int CloseOut 22 | == 23 | bnz handle_closeout 24 | 25 | txn OnCompletion 26 | int UpdateApplication 27 | == 28 | bnz handle_updateapp 29 | 30 | txn OnCompletion 31 | int DeleteApplication 32 | == 33 | bnz handle_deleteapp 34 | 35 | // Unexpected OnCompletion value. Should be unreachable. 36 | err 37 | 38 | handle_noop: 39 | // Handle NoOp 40 | 41 | // read global state 42 | byte "counter" 43 | dup 44 | app_global_get 45 | 46 | // increment the value 47 | int 1 48 | + 49 | 50 | // store to scratch space 51 | dup 52 | store 0 53 | 54 | // update global state 55 | app_global_put 56 | 57 | // read local state for sender 58 | int 0 59 | byte "counter" 60 | app_local_get 61 | 62 | // increment the value 63 | int 1 64 | + 65 | store 1 66 | 67 | // update local state for sender 68 | int 0 69 | byte "counter" 70 | load 1 71 | app_local_put 72 | 73 | // load return value as approval 74 | load 0 75 | return 76 | 77 | 78 | handle_closeout: 79 | // Handle CloseOut 80 | //approval 81 | int 1 82 | return 83 | 84 | handle_deleteapp: 85 | // Check for creator 86 | global CreatorAddress 87 | txn Sender 88 | == 89 | return 90 | 91 | handle_updateapp: 92 | // Check for creator 93 | global CreatorAddress 94 | txn Sender 95 | == 96 | return 97 | 98 | handle_approve: 99 | int 1 100 | return 101 | -------------------------------------------------------------------------------- /_examples/application/approval_refactored.teal: -------------------------------------------------------------------------------- 1 | #pragma version 4 2 | // Handle each possible OnCompletion type. We don't have to worry about 3 | // handling ClearState, because the ClearStateProgram will execute in that 4 | // case, not the ApprovalProgram. 5 | 6 | txn ApplicationID 7 | int 0 8 | == 9 | bnz handle_approve 10 | 11 | txn OnCompletion 12 | int NoOp 13 | == 14 | bnz handle_noop 15 | 16 | txn OnCompletion 17 | int OptIn 18 | == 19 | bnz handle_approve 20 | 21 | txn OnCompletion 22 | int CloseOut 23 | == 24 | bnz handle_closeout 25 | 26 | txn OnCompletion 27 | int UpdateApplication 28 | == 29 | bnz handle_updateapp 30 | 31 | txn OnCompletion 32 | int DeleteApplication 33 | == 34 | bnz handle_deleteapp 35 | 36 | // Unexpected OnCompletion value. Should be unreachable. 37 | err 38 | 39 | handle_noop: 40 | // Handle NoOp 41 | 42 | // read global state 43 | byte "counter" 44 | dup 45 | app_global_get 46 | 47 | // increment the value 48 | int 1 49 | + 50 | 51 | // store to scratch space 52 | dup 53 | store 0 54 | 55 | // update global state 56 | app_global_put 57 | 58 | // read local state for sender 59 | int 0 60 | byte "counter" 61 | app_local_get 62 | 63 | // increment the value 64 | int 1 65 | + 66 | store 1 67 | 68 | // update local state for sender 69 | // update "counter" 70 | int 0 71 | byte "counter" 72 | load 1 73 | app_local_put 74 | 75 | // update "timestamp" 76 | int 0 77 | byte "timestamp" 78 | txn ApplicationArgs 0 79 | app_local_put 80 | 81 | // load return value as approval 82 | load 0 83 | return 84 | 85 | handle_closeout: 86 | // Handle CloseOut 87 | //approval 88 | int 1 89 | return 90 | 91 | handle_deleteapp: 92 | // Check for creator 93 | global CreatorAddress 94 | txn Sender 95 | == 96 | return 97 | 98 | handle_updateapp: 99 | // Check for creator 100 | global CreatorAddress 101 | txn Sender 102 | == 103 | return 104 | 105 | handle_approve: 106 | int 1 107 | return -------------------------------------------------------------------------------- /_examples/application/clear.teal: -------------------------------------------------------------------------------- 1 | #pragma version 4 2 | int 1 3 | return -------------------------------------------------------------------------------- /_examples/atomic_transfer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "log" 7 | 8 | "github.com/algorand/go-algorand-sdk/v2/crypto" 9 | "github.com/algorand/go-algorand-sdk/v2/transaction" 10 | "github.com/algorand/go-algorand-sdk/v2/types" 11 | ) 12 | 13 | func main() { 14 | algodClient := getAlgodClient() 15 | accts, err := getSandboxAccounts() 16 | if err != nil { 17 | log.Fatalf("failed to get sandbox accounts: %s", err) 18 | } 19 | 20 | acct1 := accts[0] 21 | acct2 := accts[1] 22 | 23 | // example: ATOMIC_CREATE_TXNS 24 | sp, err := algodClient.SuggestedParams().Do(context.Background()) 25 | if err != nil { 26 | log.Fatalf("failed to get suggested params: %s", err) 27 | } 28 | 29 | tx1, err := transaction.MakePaymentTxn(acct1.Address.String(), acct2.Address.String(), 100000, nil, "", sp) 30 | if err != nil { 31 | log.Fatalf("failed creating transaction: %s", err) 32 | } 33 | 34 | // from account 2 to account 1 35 | tx2, err := transaction.MakePaymentTxn(acct2.Address.String(), acct1.Address.String(), 100000, nil, "", sp) 36 | if err != nil { 37 | log.Fatalf("failed creating transaction: %s", err) 38 | } 39 | // example: ATOMIC_CREATE_TXNS 40 | 41 | // example: ATOMIC_GROUP_TXNS 42 | // compute group id and put it into each transaction 43 | gid, err := crypto.ComputeGroupID([]types.Transaction{tx1, tx2}) 44 | tx1.Group = gid 45 | tx2.Group = gid 46 | // example: ATOMIC_GROUP_TXNS 47 | 48 | // example: ATOMIC_GROUP_SIGN 49 | _, stx1, err := crypto.SignTransaction(acct1.PrivateKey, tx1) 50 | if err != nil { 51 | fmt.Printf("Failed to sign transaction: %s\n", err) 52 | return 53 | } 54 | _, stx2, err := crypto.SignTransaction(acct2.PrivateKey, tx2) 55 | if err != nil { 56 | fmt.Printf("Failed to sign transaction: %s\n", err) 57 | } 58 | // example: ATOMIC_GROUP_SIGN 59 | 60 | // example: ATOMIC_GROUP_ASSEMBLE 61 | var signedGroup []byte 62 | signedGroup = append(signedGroup, stx1...) 63 | signedGroup = append(signedGroup, stx2...) 64 | 65 | // example: ATOMIC_GROUP_ASSEMBLE 66 | 67 | // example: ATOMIC_GROUP_SEND 68 | pendingTxID, err := algodClient.SendRawTransaction(signedGroup).Do(context.Background()) 69 | if err != nil { 70 | fmt.Printf("failed to send transaction: %s\n", err) 71 | return 72 | } 73 | confirmedTxn, err := transaction.WaitForConfirmation(algodClient, pendingTxID, 4, context.Background()) 74 | if err != nil { 75 | fmt.Printf("Error waiting for confirmation on txID: %s\n", pendingTxID) 76 | return 77 | } 78 | fmt.Printf("Confirmed Transaction: %s in Round %d\n", pendingTxID, confirmedTxn.ConfirmedRound) 79 | // example: ATOMIC_GROUP_SEND 80 | 81 | } 82 | -------------------------------------------------------------------------------- /_examples/calculator/clear.teal: -------------------------------------------------------------------------------- 1 | #pragma version 8 2 | pushint 0 // 0 3 | return -------------------------------------------------------------------------------- /_examples/calculator/contract.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Calculator", 3 | "methods": [ 4 | { 5 | "name": "add", 6 | "args": [ 7 | { 8 | "type": "uint64", 9 | "name": "a" 10 | }, 11 | { 12 | "type": "uint64", 13 | "name": "b" 14 | } 15 | ], 16 | "returns": { 17 | "type": "uint64" 18 | }, 19 | "desc": "Add a and b, return the result" 20 | }, 21 | { 22 | "name": "mul", 23 | "args": [ 24 | { 25 | "type": "uint64", 26 | "name": "a" 27 | }, 28 | { 29 | "type": "uint64", 30 | "name": "b" 31 | } 32 | ], 33 | "returns": { 34 | "type": "uint64" 35 | }, 36 | "desc": "Multiply a and b, return the result" 37 | }, 38 | { 39 | "name": "sub", 40 | "args": [ 41 | { 42 | "type": "uint64", 43 | "name": "a" 44 | }, 45 | { 46 | "type": "uint64", 47 | "name": "b" 48 | } 49 | ], 50 | "returns": { 51 | "type": "uint64" 52 | }, 53 | "desc": "Subtract b from a, return the result" 54 | }, 55 | { 56 | "name": "div", 57 | "args": [ 58 | { 59 | "type": "uint64", 60 | "name": "a" 61 | }, 62 | { 63 | "type": "uint64", 64 | "name": "b" 65 | } 66 | ], 67 | "returns": { 68 | "type": "uint64" 69 | }, 70 | "desc": "Divide a by b, return the result" 71 | } 72 | ], 73 | "networks": {} 74 | } -------------------------------------------------------------------------------- /_examples/debug.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log" 6 | "os" 7 | 8 | "github.com/algorand/go-algorand-sdk/v2/crypto" 9 | "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" 10 | "github.com/algorand/go-algorand-sdk/v2/transaction" 11 | "github.com/algorand/go-algorand-sdk/v2/types" 12 | ) 13 | 14 | func main() { 15 | 16 | algodClient := getAlgodClient() 17 | accts, err := getSandboxAccounts() 18 | if err != nil { 19 | log.Fatalf("failed to get sandbox accounts: %s", err) 20 | } 21 | 22 | acct1 := accts[0] 23 | 24 | appID := deployApp(algodClient, acct1) 25 | 26 | // example: DEBUG_DRYRUN_DUMP 27 | var ( 28 | args [][]byte 29 | accounts []string 30 | apps []uint64 31 | assets []uint64 32 | ) 33 | 34 | sp, err := algodClient.SuggestedParams().Do(context.Background()) 35 | if err != nil { 36 | log.Fatalf("failed to get suggested params: %s", err) 37 | } 38 | 39 | appCallTxn, err := transaction.MakeApplicationNoOpTx( 40 | appID, args, accounts, apps, assets, sp, acct1.Address, 41 | nil, types.Digest{}, [32]byte{}, types.Address{}, 42 | ) 43 | if err != nil { 44 | log.Fatalf("Failed to create app call txn: %+v", err) 45 | } 46 | 47 | _, stxn, err := crypto.SignTransaction(acct1.PrivateKey, appCallTxn) 48 | if err != nil { 49 | log.Fatalf("Failed to sign app txn: %+v", err) 50 | } 51 | 52 | signedAppCallTxn := types.SignedTxn{} 53 | msgpack.Decode(stxn, &signedAppCallTxn) 54 | 55 | drr, err := transaction.CreateDryrun(algodClient, []types.SignedTxn{signedAppCallTxn}, nil, context.Background()) 56 | if err != nil { 57 | log.Fatalf("Failed to create dryrun: %+v", err) 58 | } 59 | 60 | os.WriteFile("dryrun.msgp", msgpack.Encode(drr), 0666) 61 | // example: DEBUG_DRYRUN_DUMP 62 | 63 | // example: DEBUG_DRYRUN_SUBMIT 64 | // Create the dryrun request object 65 | drReq, err := transaction.CreateDryrun(algodClient, []types.SignedTxn{signedAppCallTxn}, nil, context.Background()) 66 | if err != nil { 67 | log.Fatalf("Failed to create dryrun: %+v", err) 68 | } 69 | 70 | // Pass dryrun request to algod server 71 | dryrunResponse, err := algodClient.TealDryrun(drReq).Do(context.Background()) 72 | if err != nil { 73 | log.Fatalf("failed to dryrun request: %s", err) 74 | } 75 | 76 | // Inspect the response to check result 77 | for _, txn := range dryrunResponse.Txns { 78 | log.Printf("%+v", txn.AppCallTrace) 79 | } 80 | // example: DEBUG_DRYRUN_SUBMIT 81 | } 82 | -------------------------------------------------------------------------------- /_examples/lsig/sample_arg.teal: -------------------------------------------------------------------------------- 1 | #pragma version 5 2 | arg_0 3 | btoi 4 | int 123 5 | == -------------------------------------------------------------------------------- /_examples/lsig/simple.teal: -------------------------------------------------------------------------------- 1 | #pragma version 5 2 | int 1 3 | return -------------------------------------------------------------------------------- /_examples/overview.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "log" 7 | "strings" 8 | 9 | "github.com/algorand/go-algorand-sdk/v2/client/v2/algod" 10 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 11 | "github.com/algorand/go-algorand-sdk/v2/transaction" 12 | ) 13 | 14 | func main() { 15 | 16 | algodClient := getAlgodClient() 17 | 18 | nodeStatus, err := algodClient.Status().Do(context.Background()) 19 | if err != nil { 20 | fmt.Printf("Failed to get status: %s\n", err) 21 | return 22 | } 23 | 24 | fmt.Printf("Last Round: %d\n", nodeStatus.LastRound) 25 | 26 | // example: SP_MIN_FEE 27 | sp, err := algodClient.SuggestedParams().Do(context.Background()) 28 | if err != nil { 29 | log.Printf("failed to %s", err) 30 | } 31 | // example: SP_MIN_FEE 32 | 33 | // example: CONST_MIN_FEE 34 | log.Printf("Min fee const: %d", transaction.MinTxnFee) 35 | // example: CONST_MIN_FEE 36 | 37 | // example: TRANSACTION_FEE_OVERRIDE 38 | // by using fee pooling and setting our fee to 2x min tx fee 39 | // we can cover the fee for another transaction in the group 40 | sp.Fee = 2 * transaction.MinTxnFee 41 | sp.FlatFee = true 42 | // ... 43 | // example: TRANSACTION_FEE_OVERRIDE 44 | 45 | } 46 | func exampleAlgod() { 47 | // example: ALGOD_CREATE_CLIENT 48 | // Create a new algod client, configured to connect to out local sandbox 49 | var algodAddress = "http://localhost:4001" 50 | var algodToken = strings.Repeat("a", 64) 51 | algodClient, _ := algod.MakeClient( 52 | algodAddress, 53 | algodToken, 54 | ) 55 | 56 | // Or, if necessary, pass alternate headers 57 | 58 | var algodHeader common.Header 59 | algodHeader.Key = "X-API-Key" 60 | algodHeader.Value = algodToken 61 | algodClientWithHeaders, _ := algod.MakeClientWithHeaders( 62 | algodAddress, 63 | algodToken, 64 | []*common.Header{&algodHeader}, 65 | ) 66 | // example: ALGOD_CREATE_CLIENT 67 | 68 | _ = algodClientWithHeaders 69 | _ = algodClient 70 | } 71 | -------------------------------------------------------------------------------- /_examples/participation.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "strings" 7 | 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/algod" 9 | "github.com/algorand/go-algorand-sdk/v2/transaction" 10 | ) 11 | 12 | func main() { 13 | markOnline() 14 | } 15 | 16 | func setupConnection() (c *algod.Client, err error) { 17 | algod_token := strings.Repeat("a", 64) 18 | algod_server := "http://127.0.0.1:4001" 19 | algod_client, err := algod.MakeClient(algod_server, algod_token) 20 | c = (*algod.Client)(algod_client) 21 | return 22 | } 23 | 24 | func markOnline() { 25 | // setup connection 26 | algodClient, err := setupConnection() 27 | if err != nil { 28 | fmt.Printf("error getting suggested tx params: %s\n", err) 29 | return 30 | } 31 | 32 | // get network suggested parameters 33 | sp, err := algodClient.SuggestedParams().Do(context.Background()) 34 | if err != nil { 35 | fmt.Printf("error getting suggested tx params: %s\n", err) 36 | return 37 | } 38 | 39 | // Mark Account as "Online" (participating) 40 | // example: TRANSACTION_KEYREG_ONLINE_CREATE 41 | fromAddr := "MWAPNXBDFFD2V5KWXAHWKBO7FO4JN36VR4CIBDKDDE7WAUAGZIXM3QPJW4" 42 | voteKey := "87iBW46PP4BpTDz6+IEGvxY6JqEaOtV0g+VWcJqoqtc=" 43 | selKey := "1V2BE2lbFvS937H7pJebN0zxkqe1Nrv+aVHDTPbYRlw=" 44 | sProofKey := "f0CYOA4yXovNBFMFX+1I/tYVBaAl7VN6e0Ki5yZA3H6jGqsU/LYHNaBkMQ/rN4M4F3UmNcpaTmbVbq+GgDsrhQ==" 45 | voteFirst := uint64(16532750) 46 | voteLast := uint64(19532750) 47 | keyDilution := uint64(1732) 48 | nonpart := false 49 | tx, err := transaction.MakeKeyRegTxnWithStateProofKey( 50 | fromAddr, 51 | []byte{}, 52 | sp, 53 | voteKey, 54 | selKey, 55 | sProofKey, 56 | voteFirst, 57 | voteLast, 58 | keyDilution, 59 | nonpart, 60 | ) 61 | // example: TRANSACTION_KEYREG_ONLINE_CREATE 62 | if err != nil { 63 | fmt.Printf("Error creating transaction: %s\n", err) 64 | return 65 | } 66 | _ = tx 67 | } 68 | -------------------------------------------------------------------------------- /abi/abi_test.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestImportWorks(t *testing.T) { 10 | // This test is not meant to be exhaustive. It's just a simple test to 11 | // verify importing the ABI package from avm-abi is working 12 | 13 | abiType, err := TypeOf("uint64") 14 | require.NoError(t, err) 15 | 16 | valueToEncode := 10000 17 | expected := []byte{0, 0, 0, 0, 0, 0, 39, 16} 18 | 19 | actual, err := abiType.Encode(valueToEncode) 20 | require.NoError(t, err) 21 | 22 | require.Equal(t, expected, actual) 23 | } 24 | -------------------------------------------------------------------------------- /auction/auction.go: -------------------------------------------------------------------------------- 1 | package auction 2 | 3 | import ( 4 | "github.com/algorand/go-algorand-sdk/v2/types" 5 | ) 6 | 7 | // MakeBid constructs a bid using the passed parameters. `bidderAddress` and 8 | // `auctionAddress` should be checksummed, human-readable addresses 9 | func MakeBid(bidderAddress string, bidAmount, maxPrice, bidID uint64, auctionAddress string, auctionID uint64) (bid types.Bid, err error) { 10 | // Decode from address 11 | bidderAddr, err := types.DecodeAddress(bidderAddress) 12 | if err != nil { 13 | return 14 | } 15 | 16 | // Decode to address 17 | auctionAddr, err := types.DecodeAddress(auctionAddress) 18 | if err != nil { 19 | return 20 | } 21 | 22 | bid = types.Bid{ 23 | BidderKey: bidderAddr, 24 | BidCurrency: bidAmount, 25 | MaxPrice: maxPrice, 26 | BidID: bidID, 27 | AuctionKey: auctionAddr, 28 | AuctionID: auctionID, 29 | } 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/algorand/go-algorand-sdk/4c4c55c71e63808c270374c8439b56a87b614f78/client/README.md -------------------------------------------------------------------------------- /client/kmd/common.go: -------------------------------------------------------------------------------- 1 | package kmd 2 | 3 | import ( 4 | "github.com/algorand/go-algorand-sdk/v2/types" 5 | ) 6 | 7 | // APIV1Wallet is the API's representation of a wallet 8 | type APIV1Wallet struct { 9 | ID string `json:"id"` 10 | Name string `json:"name"` 11 | DriverName string `json:"driver_name"` 12 | DriverVersion uint32 `json:"driver_version"` 13 | SupportsMnemonicUX bool `json:"mnemonic_ux"` 14 | SupportedTransactions []types.TxType `json:"supported_txs"` 15 | } 16 | 17 | // APIV1WalletHandle includes the wallet the handle corresponds to 18 | // and the number of number of seconds to expiration 19 | type APIV1WalletHandle struct { 20 | Wallet APIV1Wallet `json:"wallet"` 21 | ExpiresSeconds int64 `json:"expires_seconds"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/algod/accountApplicationInformation.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // AccountApplicationInformationParams contains all of the query parameters for url serialization. 12 | type AccountApplicationInformationParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | } 18 | 19 | // AccountApplicationInformation given a specific account public key and 20 | // application ID, this call returns the account's application local state and 21 | // global state (AppLocalState and AppParams, if either exists). Global state will 22 | // only be returned if the provided address is the application's creator. 23 | type AccountApplicationInformation struct { 24 | c *Client 25 | 26 | address string 27 | applicationId uint64 28 | 29 | p AccountApplicationInformationParams 30 | } 31 | 32 | // Do performs the HTTP request 33 | func (s *AccountApplicationInformation) Do(ctx context.Context, headers ...*common.Header) (response models.AccountApplicationResponse, err error) { 34 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/accounts/%s/applications/%s", common.EscapeParams(s.address, s.applicationId)...), s.p, headers) 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /client/v2/algod/accountAssetInformation.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // AccountAssetInformationParams contains all of the query parameters for url serialization. 12 | type AccountAssetInformationParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | } 18 | 19 | // AccountAssetInformation given a specific account public key and asset ID, this 20 | // call returns the account's asset holding and asset parameters (if either exist). 21 | // Asset parameters will only be returned if the provided address is the asset's 22 | // creator. 23 | type AccountAssetInformation struct { 24 | c *Client 25 | 26 | address string 27 | assetId uint64 28 | 29 | p AccountAssetInformationParams 30 | } 31 | 32 | // Do performs the HTTP request 33 | func (s *AccountAssetInformation) Do(ctx context.Context, headers ...*common.Header) (response models.AccountAssetResponse, err error) { 34 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/accounts/%s/assets/%s", common.EscapeParams(s.address, s.assetId)...), s.p, headers) 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /client/v2/algod/accountInformation.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // AccountInformationParams contains all of the query parameters for url serialization. 12 | type AccountInformationParams struct { 13 | 14 | // Exclude when set to `all` will exclude asset holdings, application local state, 15 | // created asset parameters, any created application parameters. Defaults to 16 | // `none`. 17 | Exclude string `url:"exclude,omitempty"` 18 | 19 | // Format configures whether the response object is JSON or MessagePack encoded. If 20 | // not provided, defaults to JSON. 21 | Format string `url:"format,omitempty"` 22 | } 23 | 24 | // AccountInformation given a specific account public key, this call returns the 25 | // account's status, balance and spendable amounts 26 | type AccountInformation struct { 27 | c *Client 28 | 29 | address string 30 | 31 | p AccountInformationParams 32 | } 33 | 34 | // Exclude when set to `all` will exclude asset holdings, application local state, 35 | // created asset parameters, any created application parameters. Defaults to 36 | // `none`. 37 | func (s *AccountInformation) Exclude(Exclude string) *AccountInformation { 38 | s.p.Exclude = Exclude 39 | 40 | return s 41 | } 42 | 43 | // Do performs the HTTP request 44 | func (s *AccountInformation) Do(ctx context.Context, headers ...*common.Header) (response models.Account, err error) { 45 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/accounts/%s", common.EscapeParams(s.address)...), s.p, headers) 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /client/v2/algod/blockRaw.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | ) 9 | 10 | // GetBlockParams defines parameters for GetBlock. 11 | type GetBlockParams struct { 12 | // Return raw msgpack block bytes or json 13 | Format string `url:"format,omitempty"` 14 | } 15 | 16 | // BlockRaw contains metadata required to execute a BlockRaw query. 17 | type BlockRaw struct { 18 | c *Client 19 | round uint64 20 | p GetBlockParams 21 | } 22 | 23 | // Do executes the BlockRaw query and gets the results. 24 | func (s *BlockRaw) Do(ctx context.Context, headers ...*common.Header) (result []byte, err error) { 25 | s.p.Format = "msgpack" 26 | return s.c.getRaw(ctx, fmt.Sprintf("/v2/blocks/%d", s.round), s.p, headers) 27 | } 28 | -------------------------------------------------------------------------------- /client/v2/algod/dryrun.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // TealDryRun /v2/teal/dryrun 11 | type TealDryRun struct { 12 | c *Client 13 | rawobj []byte 14 | } 15 | 16 | // Do performs HTTP request 17 | func (s *TealDryRun) Do( 18 | ctx context.Context, 19 | headers ...*common.Header, 20 | ) (response models.DryrunResponse, err error) { 21 | err = s.c.post(ctx, &response, "/v2/teal/dryrun", nil, headers, s.rawobj) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/getApplicationBoxByName.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "encoding/base64" 6 | "fmt" 7 | 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 9 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 10 | ) 11 | 12 | // GetApplicationBoxByNameParams contains all of the query parameters for url serialization. 13 | type GetApplicationBoxByNameParams struct { 14 | 15 | // Name a box name, in the goal app call arg form 'encoding:value'. For ints, use 16 | // the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable 17 | // strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'. 18 | Name string `url:"name,omitempty"` 19 | } 20 | 21 | // GetApplicationBoxByName given an application ID and box name, it returns the 22 | // round, box name, and value (each base64 encoded). Box names must be in the goal 23 | // app call arg encoding form 'encoding:value'. For ints, use the form 'int:1234'. 24 | // For raw bytes, use the form 'b64:A=='. For printable strings, use the form 25 | // 'str:hello'. For addresses, use the form 'addr:XYZ...'. 26 | type GetApplicationBoxByName struct { 27 | c *Client 28 | 29 | applicationId uint64 30 | 31 | p GetApplicationBoxByNameParams 32 | } 33 | 34 | // name a box name, in the goal app call arg form 'encoding:value'. For ints, use 35 | // the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable 36 | // strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'. 37 | func (s *GetApplicationBoxByName) name(name []byte) *GetApplicationBoxByName { 38 | s.p.Name = "b64:" + base64.StdEncoding.EncodeToString(name) 39 | 40 | return s 41 | } 42 | 43 | // Do performs the HTTP request 44 | func (s *GetApplicationBoxByName) Do(ctx context.Context, headers ...*common.Header) (response models.Box, err error) { 45 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/box", common.EscapeParams(s.applicationId)...), s.p, headers) 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /client/v2/algod/getApplicationBoxes.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetApplicationBoxesParams contains all of the query parameters for url serialization. 12 | type GetApplicationBoxesParams struct { 13 | 14 | // Max max number of box names to return. If max is not set, or max == 0, returns 15 | // all box-names. 16 | Max uint64 `url:"max,omitempty"` 17 | } 18 | 19 | // GetApplicationBoxes given an application ID, return all Box names. No particular 20 | // ordering is guaranteed. Request fails when client or server-side configured 21 | // limits prevent returning all Box names. 22 | type GetApplicationBoxes struct { 23 | c *Client 24 | 25 | applicationId uint64 26 | 27 | p GetApplicationBoxesParams 28 | } 29 | 30 | // Max max number of box names to return. If max is not set, or max == 0, returns 31 | // all box-names. 32 | func (s *GetApplicationBoxes) Max(Max uint64) *GetApplicationBoxes { 33 | s.p.Max = Max 34 | 35 | return s 36 | } 37 | 38 | // Do performs the HTTP request 39 | func (s *GetApplicationBoxes) Do(ctx context.Context, headers ...*common.Header) (response models.BoxesResponse, err error) { 40 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/boxes", common.EscapeParams(s.applicationId)...), s.p, headers) 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /client/v2/algod/getApplicationByID.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetApplicationByID given a application ID, it returns application information 12 | // including creator, approval and clear programs, global and local schemas, and 13 | // global state. 14 | type GetApplicationByID struct { 15 | c *Client 16 | 17 | applicationId uint64 18 | } 19 | 20 | // Do performs the HTTP request 21 | func (s *GetApplicationByID) Do(ctx context.Context, headers ...*common.Header) (response models.Application, err error) { 22 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s", common.EscapeParams(s.applicationId)...), nil, headers) 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /client/v2/algod/getAssetByID.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetAssetByID given a asset ID, it returns asset information including creator, 12 | // name, total supply and special addresses. 13 | type GetAssetByID struct { 14 | c *Client 15 | 16 | assetId uint64 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *GetAssetByID) Do(ctx context.Context, headers ...*common.Header) (response models.Asset, err error) { 21 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/assets/%s", common.EscapeParams(s.assetId)...), nil, headers) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/getBlock.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | "github.com/algorand/go-algorand-sdk/v2/types" 10 | ) 11 | 12 | // BlockParams contains all of the query parameters for url serialization. 13 | type BlockParams struct { 14 | 15 | // Format configures whether the response object is JSON or MessagePack encoded. If 16 | // not provided, defaults to JSON. 17 | Format string `url:"format,omitempty"` 18 | 19 | // HeaderOnly if true, only the block header (exclusive of payset or certificate) 20 | // may be included in response. 21 | HeaderOnly bool `url:"header-only,omitempty"` 22 | } 23 | 24 | // Block get the block for the given round. 25 | type Block struct { 26 | c *Client 27 | 28 | round uint64 29 | 30 | p BlockParams 31 | } 32 | 33 | // HeaderOnly if true, only the block header (exclusive of payset or certificate) 34 | // may be included in response. 35 | func (s *Block) HeaderOnly(HeaderOnly bool) *Block { 36 | s.p.HeaderOnly = HeaderOnly 37 | 38 | return s 39 | } 40 | 41 | // Do performs the HTTP request 42 | func (s *Block) Do(ctx context.Context, headers ...*common.Header) (result types.Block, err error) { 43 | var response models.BlockResponse 44 | 45 | s.p.Format = "msgpack" 46 | err = s.c.getMsgpack(ctx, &response, fmt.Sprintf("/v2/blocks/%d", s.round), s.p, headers) 47 | if err != nil { 48 | return 49 | } 50 | 51 | result = response.Block 52 | return 53 | } 54 | -------------------------------------------------------------------------------- /client/v2/algod/getBlockHash.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetBlockHash get the block hash for the block on the given round. 12 | type GetBlockHash struct { 13 | c *Client 14 | 15 | round uint64 16 | } 17 | 18 | // Do performs the HTTP request 19 | func (s *GetBlockHash) Do(ctx context.Context, headers ...*common.Header) (response models.BlockHashResponse, err error) { 20 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/hash", common.EscapeParams(s.round)...), nil, headers) 21 | return 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/algod/getBlockLogs.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetBlockLogs get all of the logs from outer and inner app calls in the given 12 | // round 13 | type GetBlockLogs struct { 14 | c *Client 15 | 16 | round uint64 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *GetBlockLogs) Do(ctx context.Context, headers ...*common.Header) (response models.BlockLogsResponse, err error) { 21 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/logs", common.EscapeParams(s.round)...), nil, headers) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/getBlockTimeStampOffset.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // GetBlockTimeStampOffset gets the current timestamp offset. 11 | type GetBlockTimeStampOffset struct { 12 | c *Client 13 | } 14 | 15 | // Do performs the HTTP request 16 | func (s *GetBlockTimeStampOffset) Do(ctx context.Context, headers ...*common.Header) (response models.GetBlockTimeStampOffsetResponse, err error) { 17 | err = s.c.get(ctx, &response, "/v2/devmode/blocks/offset", nil, headers) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/algod/getBlockTxids.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetBlockTxids get the top level transaction IDs for the block on the given 12 | // round. 13 | type GetBlockTxids struct { 14 | c *Client 15 | 16 | round uint64 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *GetBlockTxids) Do(ctx context.Context, headers ...*common.Header) (response models.BlockTxidsResponse, err error) { 21 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/txids", common.EscapeParams(s.round)...), nil, headers) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/getGenesis.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // GetGenesis returns the entire genesis file in json. 11 | type GetGenesis struct { 12 | c *Client 13 | } 14 | 15 | // Do performs the HTTP request 16 | func (s *GetGenesis) Do(ctx context.Context, headers ...*common.Header) (response models.Genesis, err error) { 17 | err = s.c.get(ctx, &response, "/genesis", nil, headers) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/algod/getLedgerStateDelta.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/types" 9 | ) 10 | 11 | // GetLedgerStateDeltaParams contains all of the query parameters for url serialization. 12 | type GetLedgerStateDeltaParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | } 18 | 19 | // GetLedgerStateDelta get ledger deltas for a round. 20 | type GetLedgerStateDelta struct { 21 | c *Client 22 | 23 | round uint64 24 | 25 | p GetLedgerStateDeltaParams 26 | } 27 | 28 | // Do performs the HTTP request 29 | func (s *GetLedgerStateDelta) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) { 30 | s.p.Format = "msgpack" 31 | err = s.c.getMsgpack(ctx, &response, fmt.Sprintf("/v2/deltas/%s", common.EscapeParams(s.round)...), s.p, headers) 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /client/v2/algod/getLedgerStateDeltaForTransactionGroup.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/types" 9 | ) 10 | 11 | // GetLedgerStateDeltaForTransactionGroupParams contains all of the query parameters for url serialization. 12 | type GetLedgerStateDeltaForTransactionGroupParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | } 18 | 19 | // GetLedgerStateDeltaForTransactionGroup get a ledger delta for a given 20 | // transaction group. 21 | type GetLedgerStateDeltaForTransactionGroup struct { 22 | c *Client 23 | 24 | id string 25 | 26 | p GetLedgerStateDeltaForTransactionGroupParams 27 | } 28 | 29 | // Do performs the HTTP request 30 | func (s *GetLedgerStateDeltaForTransactionGroup) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) { 31 | s.p.Format = "msgpack" 32 | err = s.c.getMsgpack(ctx, &response, fmt.Sprintf("/v2/deltas/txn/group/%s", common.EscapeParams(s.id)...), s.p, headers) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /client/v2/algod/getLightBlockHeaderProof.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetLightBlockHeaderProof gets a proof for a given light block header inside a 12 | // state proof commitment 13 | type GetLightBlockHeaderProof struct { 14 | c *Client 15 | 16 | round uint64 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *GetLightBlockHeaderProof) Do(ctx context.Context, headers ...*common.Header) (response models.LightBlockHeaderProof, err error) { 21 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/lightheader/proof", common.EscapeParams(s.round)...), nil, headers) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/getPendingTransactions.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | "github.com/algorand/go-algorand-sdk/v2/types" 9 | ) 10 | 11 | // PendingTransactionsParams contains all of the query parameters for url serialization. 12 | type PendingTransactionsParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | 18 | // Max truncated number of transactions to display. If max=0, returns all pending 19 | // txns. 20 | Max uint64 `url:"max,omitempty"` 21 | } 22 | 23 | // PendingTransactions get the list of pending transactions, sorted by priority, in 24 | // decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending 25 | // transactions. 26 | type PendingTransactions struct { 27 | c *Client 28 | 29 | p PendingTransactionsParams 30 | } 31 | 32 | // Max truncated number of transactions to display. If max=0, returns all pending 33 | // txns. 34 | func (s *PendingTransactions) Max(Max uint64) *PendingTransactions { 35 | s.p.Max = Max 36 | 37 | return s 38 | } 39 | 40 | // Do performs the HTTP request 41 | func (s *PendingTransactions) Do(ctx context.Context, headers ...*common.Header) (total uint64, topTransactions []types.SignedTxn, err error) { 42 | s.p.Format = "msgpack" 43 | response := models.PendingTransactionsResponse{} 44 | err = s.c.getMsgpack(ctx, &response, "/v2/transactions/pending", s.p, headers) 45 | total = response.TotalTransactions 46 | topTransactions = response.TopTransactions 47 | return 48 | } 49 | -------------------------------------------------------------------------------- /client/v2/algod/getPendingTransactionsByAddress.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | "github.com/algorand/go-algorand-sdk/v2/types" 10 | ) 11 | 12 | // PendingTransactionsByAddressParams contains all of the query parameters for url serialization. 13 | type PendingTransactionsByAddressParams struct { 14 | 15 | // Format configures whether the response object is JSON or MessagePack encoded. If 16 | // not provided, defaults to JSON. 17 | Format string `url:"format,omitempty"` 18 | 19 | // Max truncated number of transactions to display. If max=0, returns all pending 20 | // txns. 21 | Max uint64 `url:"max,omitempty"` 22 | } 23 | 24 | // PendingTransactionsByAddress get the list of pending transactions by address, 25 | // sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 26 | // 0, returns all pending transactions. 27 | type PendingTransactionsByAddress struct { 28 | c *Client 29 | 30 | address string 31 | 32 | p PendingTransactionsByAddressParams 33 | } 34 | 35 | // Max truncated number of transactions to display. If max=0, returns all pending 36 | // txns. 37 | func (s *PendingTransactionsByAddress) Max(Max uint64) *PendingTransactionsByAddress { 38 | s.p.Max = Max 39 | 40 | return s 41 | } 42 | 43 | // Do performs the HTTP request 44 | func (s *PendingTransactionsByAddress) Do(ctx context.Context, headers ...*common.Header) (total uint64, topTransactions []types.SignedTxn, err error) { 45 | s.p.Format = "msgpack" 46 | response := models.PendingTransactionsResponse{} 47 | err = s.c.getMsgpack(ctx, &response, fmt.Sprintf("/v2/accounts/%s/transactions/pending", s.address), s.p, headers) 48 | total = response.TotalTransactions 49 | topTransactions = response.TopTransactions 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /client/v2/algod/getReady.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | ) 8 | 9 | // GetReady returns OK if healthy and fully caught up. 10 | type GetReady struct { 11 | c *Client 12 | } 13 | 14 | // Do performs the HTTP request 15 | func (s *GetReady) Do(ctx context.Context, headers ...*common.Header) (response string, err error) { 16 | err = s.c.get(ctx, &response, "/ready", nil, headers) 17 | return 18 | } 19 | -------------------------------------------------------------------------------- /client/v2/algod/getStateProof.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetStateProof get a state proof that covers a given round 12 | type GetStateProof struct { 13 | c *Client 14 | 15 | round uint64 16 | } 17 | 18 | // Do performs the HTTP request 19 | func (s *GetStateProof) Do(ctx context.Context, headers ...*common.Header) (response models.StateProof, err error) { 20 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/stateproofs/%s", common.EscapeParams(s.round)...), nil, headers) 21 | return 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/algod/getStatus.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // Status gets the current node status. 11 | type Status struct { 12 | c *Client 13 | } 14 | 15 | // Do performs the HTTP request 16 | func (s *Status) Do(ctx context.Context, headers ...*common.Header) (response models.NodeStatus, err error) { 17 | err = s.c.get(ctx, &response, "/v2/status", nil, headers) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/algod/getSupply.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // Supply get the current supply reported by the ledger. 11 | type Supply struct { 12 | c *Client 13 | } 14 | 15 | // Do performs the HTTP request 16 | func (s *Supply) Do(ctx context.Context, headers ...*common.Header) (response models.Supply, err error) { 17 | err = s.c.get(ctx, &response, "/v2/ledger/supply", nil, headers) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/algod/getSyncRound.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // GetSyncRound gets the minimum sync round for the ledger. 11 | type GetSyncRound struct { 12 | c *Client 13 | } 14 | 15 | // Do performs the HTTP request 16 | func (s *GetSyncRound) Do(ctx context.Context, headers ...*common.Header) (response models.GetSyncRoundResponse, err error) { 17 | err = s.c.get(ctx, &response, "/v2/ledger/sync", nil, headers) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetTransactionGroupLedgerStateDeltasForRoundParams contains all of the query parameters for url serialization. 12 | type GetTransactionGroupLedgerStateDeltasForRoundParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | } 18 | 19 | // GetTransactionGroupLedgerStateDeltasForRound get ledger deltas for transaction 20 | // groups in a given round. 21 | type GetTransactionGroupLedgerStateDeltasForRound struct { 22 | c *Client 23 | 24 | round uint64 25 | 26 | p GetTransactionGroupLedgerStateDeltasForRoundParams 27 | } 28 | 29 | // Do performs the HTTP request 30 | func (s *GetTransactionGroupLedgerStateDeltasForRound) Do(ctx context.Context, headers ...*common.Header) (response models.TransactionGroupLedgerStateDeltasForRoundResponse, err error) { 31 | s.p.Format = "msgpack" 32 | err = s.c.getMsgpack(ctx, &response, fmt.Sprintf("/v2/deltas/%s/txn/group", common.EscapeParams(s.round)...), s.p, headers) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /client/v2/algod/getTransactionProof.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // GetTransactionProofParams contains all of the query parameters for url serialization. 12 | type GetTransactionProofParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | 18 | // Hashtype the type of hash function used to create the proof, must be one of: 19 | // * sha512_256 20 | // * sha256 21 | Hashtype string `url:"hashtype,omitempty"` 22 | } 23 | 24 | // GetTransactionProof get a proof for a transaction in a block. 25 | type GetTransactionProof struct { 26 | c *Client 27 | 28 | round uint64 29 | txid string 30 | 31 | p GetTransactionProofParams 32 | } 33 | 34 | // Hashtype the type of hash function used to create the proof, must be one of: 35 | // * sha512_256 36 | // * sha256 37 | func (s *GetTransactionProof) Hashtype(Hashtype string) *GetTransactionProof { 38 | s.p.Hashtype = Hashtype 39 | 40 | return s 41 | } 42 | 43 | // Do performs the HTTP request 44 | func (s *GetTransactionProof) Do(ctx context.Context, headers ...*common.Header) (response models.TransactionProof, err error) { 45 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/transactions/%s/proof", common.EscapeParams(s.round, s.txid)...), s.p, headers) 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /client/v2/algod/getVersion.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // Versions retrieves the supported API versions, binary build versions, and 11 | // genesis information. 12 | type Versions struct { 13 | c *Client 14 | } 15 | 16 | // Do performs the HTTP request 17 | func (s *Versions) Do(ctx context.Context, headers ...*common.Header) (response models.Version, err error) { 18 | err = s.c.get(ctx, &response, "/versions", nil, headers) 19 | return 20 | } 21 | -------------------------------------------------------------------------------- /client/v2/algod/healthCheck.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | ) 8 | 9 | // HealthCheck returns OK if healthy. 10 | type HealthCheck struct { 11 | c *Client 12 | } 13 | 14 | // Do performs the HTTP request 15 | func (s *HealthCheck) Do(ctx context.Context, headers ...*common.Header) error { 16 | return s.c.get(ctx, nil, "/health", nil, headers) 17 | } 18 | -------------------------------------------------------------------------------- /client/v2/algod/pendingTransactionInformation.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | "github.com/algorand/go-algorand-sdk/v2/types" 10 | ) 11 | 12 | // PendingTransactionInformationParams contains all of the query parameters for url serialization. 13 | type PendingTransactionInformationParams struct { 14 | 15 | // Format configures whether the response object is JSON or MessagePack encoded. If 16 | // not provided, defaults to JSON. 17 | Format string `url:"format,omitempty"` 18 | } 19 | 20 | // PendingTransactionInformation given a transaction ID of a recently submitted 21 | // transaction, it returns information about it. There are several cases when this 22 | // might succeed: 23 | // - transaction committed (committed round > 0) 24 | // - transaction still in the pool (committed round = 0, pool error = "") 25 | // - transaction removed from pool due to error (committed round = 0, pool error != 26 | // "") 27 | // Or the transaction may have happened sufficiently long ago that the node no 28 | // longer remembers it, and this will return an error. 29 | type PendingTransactionInformation struct { 30 | c *Client 31 | 32 | txid string 33 | 34 | p PendingTransactionInformationParams 35 | } 36 | 37 | // Do performs the HTTP request 38 | func (s *PendingTransactionInformation) Do(ctx context.Context, headers ...*common.Header) (response models.PendingTransactionInfoResponse, stxn types.SignedTxn, err error) { 39 | s.p.Format = "msgpack" 40 | err = s.c.getMsgpack(ctx, &response, fmt.Sprintf("/v2/transactions/pending/%s", s.txid), s.p, headers) 41 | stxn = response.Transaction 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /client/v2/algod/rawTransaction.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "strings" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // SendRawTransaction broadcasts a raw transaction or transaction group to the 12 | // network. 13 | type SendRawTransaction struct { 14 | c *Client 15 | 16 | rawtxn []byte 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *SendRawTransaction) Do(ctx context.Context, headers ...*common.Header) (txid string, err error) { 21 | var response models.PostTransactionsResponse 22 | // Set default Content-Type, if the user didn't specify it. 23 | addContentType := true 24 | for _, header := range headers { 25 | if strings.ToLower(header.Key) == "content-type" { 26 | addContentType = false 27 | break 28 | } 29 | } 30 | if addContentType { 31 | headers = append(headers, &common.Header{Key: "Content-Type", Value: "application/x-binary"}) 32 | } 33 | err = s.c.post(ctx, &response, "/v2/transactions", nil, headers, s.rawtxn) 34 | txid = response.Txid 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /client/v2/algod/setBlockTimeStampOffset.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | ) 9 | 10 | // SetBlockTimeStampOffset sets the timestamp offset (seconds) for blocks in dev 11 | // mode. Providing an offset of 0 will unset this value and try to use the real 12 | // clock for the timestamp. 13 | type SetBlockTimeStampOffset struct { 14 | c *Client 15 | 16 | offset uint64 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *SetBlockTimeStampOffset) Do(ctx context.Context, headers ...*common.Header) (response string, err error) { 21 | err = s.c.post(ctx, &response, fmt.Sprintf("/v2/devmode/blocks/offset/%s", common.EscapeParams(s.offset)...), nil, headers, nil) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/setSyncRound.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | ) 9 | 10 | // SetSyncRound sets the minimum sync round on the ledger. 11 | type SetSyncRound struct { 12 | c *Client 13 | 14 | round uint64 15 | } 16 | 17 | // Do performs the HTTP request 18 | func (s *SetSyncRound) Do(ctx context.Context, headers ...*common.Header) (response string, err error) { 19 | err = s.c.post(ctx, &response, fmt.Sprintf("/v2/ledger/sync/%s", common.EscapeParams(s.round)...), nil, headers, nil) 20 | return 21 | } 22 | -------------------------------------------------------------------------------- /client/v2/algod/simulateTransaction.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" 9 | ) 10 | 11 | // SimulateTransactionParams contains all of the query parameters for url serialization. 12 | type SimulateTransactionParams struct { 13 | 14 | // Format configures whether the response object is JSON or MessagePack encoded. If 15 | // not provided, defaults to JSON. 16 | Format string `url:"format,omitempty"` 17 | } 18 | 19 | // SimulateTransaction simulates a raw transaction or transaction group as it would 20 | // be evaluated on the network. The simulation will use blockchain state from the 21 | // latest committed round. 22 | type SimulateTransaction struct { 23 | c *Client 24 | 25 | request models.SimulateRequest 26 | 27 | p SimulateTransactionParams 28 | } 29 | 30 | // Do performs the HTTP request 31 | func (s *SimulateTransaction) Do(ctx context.Context, headers ...*common.Header) (response models.SimulateResponse, err error) { 32 | err = s.c.post(ctx, &response, "/v2/transactions/simulate", s.p, headers, msgpack.Encode(&s.request)) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /client/v2/algod/tealCompile.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // TealCompileParams contains all of the query parameters for url serialization. 11 | type TealCompileParams struct { 12 | 13 | // Sourcemap when set to `true`, returns the source map of the program as a JSON. 14 | // Defaults to `false`. 15 | Sourcemap bool `url:"sourcemap,omitempty"` 16 | } 17 | 18 | // TealCompile given TEAL source code in plain text, return base64 encoded program 19 | // bytes and base32 SHA512_256 hash of program bytes (Address style). This endpoint 20 | // is only enabled when a node's configuration file sets EnableDeveloperAPI to 21 | // true. 22 | type TealCompile struct { 23 | c *Client 24 | 25 | source []byte 26 | 27 | p TealCompileParams 28 | } 29 | 30 | // Sourcemap when set to `true`, returns the source map of the program as a JSON. 31 | // Defaults to `false`. 32 | func (s *TealCompile) Sourcemap(Sourcemap bool) *TealCompile { 33 | s.p.Sourcemap = Sourcemap 34 | 35 | return s 36 | } 37 | 38 | // Do performs the HTTP request 39 | func (s *TealCompile) Do(ctx context.Context, headers ...*common.Header) (response models.CompileResponse, err error) { 40 | err = s.c.post(ctx, &response, "/v2/teal/compile", s.p, headers, s.source) 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /client/v2/algod/tealDisassemble.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // TealDisassemble given the program bytes, return the TEAL source code in plain 11 | // text. This endpoint is only enabled when a node's configuration file sets 12 | // EnableDeveloperAPI to true. 13 | type TealDisassemble struct { 14 | c *Client 15 | 16 | source []byte 17 | } 18 | 19 | // Do performs the HTTP request 20 | func (s *TealDisassemble) Do(ctx context.Context, headers ...*common.Header) (response models.DisassembleResponse, err error) { 21 | err = s.c.post(ctx, &response, "/v2/teal/disassemble", nil, headers, s.source) 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/algod/tealDryrun.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" 9 | ) 10 | 11 | // TealDryrun executes TEAL program(s) in context and returns debugging information 12 | // about the execution. This endpoint is only enabled when a node's configuration 13 | // file sets EnableDeveloperAPI to true. 14 | type TealDryrun struct { 15 | c *Client 16 | 17 | request models.DryrunRequest 18 | } 19 | 20 | // Do performs the HTTP request 21 | func (s *TealDryrun) Do(ctx context.Context, headers ...*common.Header) (response models.DryrunResponse, err error) { 22 | err = s.c.post(ctx, &response, "/v2/teal/dryrun", nil, headers, msgpack.Encode(&s.request)) 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /client/v2/algod/transactionParams.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | "github.com/algorand/go-algorand-sdk/v2/types" 9 | ) 10 | 11 | // SuggestedParams get parameters for constructing a new transaction 12 | type SuggestedParams struct { 13 | c *Client 14 | } 15 | 16 | // Do performs the HTTP request 17 | func (s *SuggestedParams) Do(ctx context.Context, headers ...*common.Header) (params types.SuggestedParams, err error) { 18 | var response models.TransactionParametersResponse 19 | err = s.c.get(ctx, &response, "/v2/transactions/params", nil, headers) 20 | params = types.SuggestedParams{ 21 | Fee: types.MicroAlgos(response.Fee), 22 | GenesisID: response.GenesisId, 23 | GenesisHash: response.GenesisHash, 24 | FirstRoundValid: types.Round(response.LastRound), 25 | LastRoundValid: types.Round(response.LastRound + 1000), 26 | ConsensusVersion: response.ConsensusVersion, 27 | MinFee: response.MinFee, 28 | } 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /client/v2/algod/unsetSyncRound.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | ) 8 | 9 | // UnsetSyncRound unset the ledger sync round. 10 | type UnsetSyncRound struct { 11 | c *Client 12 | } 13 | 14 | // Do performs the HTTP request 15 | func (s *UnsetSyncRound) Do(ctx context.Context, headers ...*common.Header) (response string, err error) { 16 | err = s.c.delete(ctx, &response, "/v2/ledger/sync", nil, headers) 17 | return 18 | } 19 | -------------------------------------------------------------------------------- /client/v2/algod/waitForBlock.go: -------------------------------------------------------------------------------- 1 | package algod 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // StatusAfterBlock waits for a block to appear after round {round} and returns the 12 | // node's status at the time. There is a 1 minute timeout, when reached the current 13 | // status is returned regardless of whether or not it is the round after the given 14 | // round. 15 | type StatusAfterBlock struct { 16 | c *Client 17 | 18 | round uint64 19 | } 20 | 21 | // Do performs the HTTP request 22 | func (s *StatusAfterBlock) Do(ctx context.Context, headers ...*common.Header) (response models.NodeStatus, err error) { 23 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/status/wait-for-block-after/%s", common.EscapeParams(s.round)...), nil, headers) 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /client/v2/common/models/account_application_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountApplicationResponse accountApplicationResponse describes the account's 4 | // application local state and global state (AppLocalState and AppParams, if either 5 | // exists) for a specific application ID. Global state will only be returned if the 6 | // provided address is the application's creator. 7 | type AccountApplicationResponse struct { 8 | // AppLocalState (appl) the application local data stored in this account. 9 | // The raw account uses `AppLocalState` for this type. 10 | AppLocalState ApplicationLocalState `json:"app-local-state,omitempty"` 11 | 12 | // CreatedApp (appp) parameters of the application created by this account 13 | // including app global data. 14 | // The raw account uses `AppParams` for this type. 15 | CreatedApp ApplicationParams `json:"created-app,omitempty"` 16 | 17 | // Round the round for which this information is relevant. 18 | Round uint64 `json:"round"` 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/common/models/account_asset_holding.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountAssetHolding accountAssetHolding describes the account's asset holding 4 | // and asset parameters (if either exist) for a specific asset ID. 5 | type AccountAssetHolding struct { 6 | // AssetHolding (asset) Details about the asset held by this account. 7 | // The raw account uses `AssetHolding` for this type. 8 | AssetHolding AssetHolding `json:"asset-holding"` 9 | 10 | // AssetParams (apar) parameters of the asset held by this account. 11 | // The raw account uses `AssetParams` for this type. 12 | AssetParams AssetParams `json:"asset-params,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/account_asset_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountAssetResponse accountAssetResponse describes the account's asset holding 4 | // and asset parameters (if either exist) for a specific asset ID. Asset parameters 5 | // will only be returned if the provided address is the asset's creator. 6 | type AccountAssetResponse struct { 7 | // AssetHolding (asset) Details about the asset held by this account. 8 | // The raw account uses `AssetHolding` for this type. 9 | AssetHolding AssetHolding `json:"asset-holding,omitempty"` 10 | 11 | // CreatedAsset (apar) parameters of the asset created by this account. 12 | // The raw account uses `AssetParams` for this type. 13 | CreatedAsset AssetParams `json:"created-asset,omitempty"` 14 | 15 | // Round the round for which this information is relevant. 16 | Round uint64 `json:"round"` 17 | } 18 | -------------------------------------------------------------------------------- /client/v2/common/models/account_assets_information_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountAssetsInformationResponse accountAssetsInformationResponse contains a 4 | // list of assets held by an account. 5 | type AccountAssetsInformationResponse struct { 6 | // AssetHoldings 7 | AssetHoldings []AccountAssetHolding `json:"asset-holdings,omitempty"` 8 | 9 | // NextToken used for pagination, when making another request provide this token 10 | // with the next parameter. 11 | NextToken string `json:"next-token,omitempty"` 12 | 13 | // Round the round for which this information is relevant. 14 | Round uint64 `json:"round"` 15 | } 16 | -------------------------------------------------------------------------------- /client/v2/common/models/account_error_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountErrorResponse an error response for the AccountInformation endpoint, with 4 | // optional information about limits that were exceeded. 5 | type AccountErrorResponse struct { 6 | // Data 7 | Data string `json:"data,omitempty"` 8 | 9 | // MaxResults 10 | MaxResults uint64 `json:"max-results,omitempty"` 11 | 12 | // Message 13 | Message string `json:"message"` 14 | 15 | // TotalAppsLocalState 16 | TotalAppsLocalState uint64 `json:"total-apps-local-state,omitempty"` 17 | 18 | // TotalAssets 19 | TotalAssets uint64 `json:"total-assets,omitempty"` 20 | 21 | // TotalCreatedApps 22 | TotalCreatedApps uint64 `json:"total-created-apps,omitempty"` 23 | 24 | // TotalCreatedAssets 25 | TotalCreatedAssets uint64 `json:"total-created-assets,omitempty"` 26 | } 27 | -------------------------------------------------------------------------------- /client/v2/common/models/account_participation.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountParticipation accountParticipation describes the parameters used by this 4 | // account in consensus protocol. 5 | type AccountParticipation struct { 6 | // SelectionParticipationKey selection public key (if any) currently registered for 7 | // this round. 8 | SelectionParticipationKey []byte `json:"selection-participation-key"` 9 | 10 | // StateProofKey root of the state proof key (if any) 11 | StateProofKey []byte `json:"state-proof-key,omitempty"` 12 | 13 | // VoteFirstValid first round for which this participation is valid. 14 | VoteFirstValid uint64 `json:"vote-first-valid"` 15 | 16 | // VoteKeyDilution number of subkeys in each batch of participation keys. 17 | VoteKeyDilution uint64 `json:"vote-key-dilution"` 18 | 19 | // VoteLastValid last round for which this participation is valid. 20 | VoteLastValid uint64 `json:"vote-last-valid"` 21 | 22 | // VoteParticipationKey root participation public key (if any) currently registered 23 | // for this round. 24 | VoteParticipationKey []byte `json:"vote-participation-key"` 25 | } 26 | -------------------------------------------------------------------------------- /client/v2/common/models/account_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountResponse 4 | type AccountResponse struct { 5 | // Account account information at a given round. 6 | // Definition: 7 | // data/basics/userBalance.go : AccountData 8 | Account Account `json:"account"` 9 | 10 | // CurrentRound round at which the results were computed. 11 | CurrentRound uint64 `json:"current-round"` 12 | } 13 | -------------------------------------------------------------------------------- /client/v2/common/models/account_state_delta.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountStateDelta application state delta. 4 | type AccountStateDelta struct { 5 | // Address 6 | Address string `json:"address"` 7 | 8 | // Delta application state delta. 9 | Delta []EvalDeltaKeyValue `json:"delta"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/accounts_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AccountsResponse 4 | type AccountsResponse struct { 5 | // Accounts 6 | Accounts []Account `json:"accounts"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/app_call_logs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AppCallLogs the logged messages from an app call along with the app ID and outer 4 | // transaction ID. Logs appear in the same order that they were emitted. 5 | type AppCallLogs struct { 6 | // ApplicationIndex the application from which the logs were generated 7 | ApplicationIndex uint64 `json:"application-index"` 8 | 9 | // Logs an array of logs 10 | Logs [][]byte `json:"logs"` 11 | 12 | // Txid the transaction ID of the outer app call that lead to these logs 13 | Txid string `json:"txId"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/application.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // Application application index and its parameters 4 | type Application struct { 5 | // CreatedAtRound round when this application was created. 6 | CreatedAtRound uint64 `json:"created-at-round,omitempty"` 7 | 8 | // Deleted whether or not this application is currently deleted. 9 | Deleted bool `json:"deleted,omitempty"` 10 | 11 | // DeletedAtRound round when this application was deleted. 12 | DeletedAtRound uint64 `json:"deleted-at-round,omitempty"` 13 | 14 | // Id application index. 15 | Id uint64 `json:"id"` 16 | 17 | // Params application parameters. 18 | Params ApplicationParams `json:"params"` 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/common/models/application_initial_states.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationInitialStates an application's initial global/local/box states that 4 | // were accessed during simulation. 5 | type ApplicationInitialStates struct { 6 | // AppBoxes an application's global/local/box state. 7 | AppBoxes ApplicationKVStorage `json:"app-boxes,omitempty"` 8 | 9 | // AppGlobals an application's global/local/box state. 10 | AppGlobals ApplicationKVStorage `json:"app-globals,omitempty"` 11 | 12 | // AppLocals an application's initial local states tied to different accounts. 13 | AppLocals []ApplicationKVStorage `json:"app-locals,omitempty"` 14 | 15 | // Id application index. 16 | Id uint64 `json:"id"` 17 | } 18 | -------------------------------------------------------------------------------- /client/v2/common/models/application_k_v_storage.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationKVStorage an application's global/local/box state. 4 | type ApplicationKVStorage struct { 5 | // Account the address of the account associated with the local state. 6 | Account string `json:"account,omitempty"` 7 | 8 | // Kvs key-Value pairs representing application states. 9 | Kvs []AvmKeyValue `json:"kvs"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/application_local_reference.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationLocalReference references an account's local state for an 4 | // application. 5 | type ApplicationLocalReference struct { 6 | // Account address of the account with the local state. 7 | Account string `json:"account"` 8 | 9 | // App application ID of the local state application. 10 | App uint64 `json:"app"` 11 | } 12 | -------------------------------------------------------------------------------- /client/v2/common/models/application_local_state.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationLocalState stores local state associated with an application. 4 | type ApplicationLocalState struct { 5 | // ClosedOutAtRound round when account closed out of the application. 6 | ClosedOutAtRound uint64 `json:"closed-out-at-round,omitempty"` 7 | 8 | // Deleted whether or not the application local state is currently deleted from its 9 | // account. 10 | Deleted bool `json:"deleted,omitempty"` 11 | 12 | // Id the application which this local state is for. 13 | Id uint64 `json:"id"` 14 | 15 | // KeyValue storage. 16 | KeyValue []TealKeyValue `json:"key-value,omitempty"` 17 | 18 | // OptedInAtRound round when the account opted into the application. 19 | OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` 20 | 21 | // Schema schema. 22 | Schema ApplicationStateSchema `json:"schema"` 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/common/models/application_local_states_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationLocalStatesResponse 4 | type ApplicationLocalStatesResponse struct { 5 | // AppsLocalStates 6 | AppsLocalStates []ApplicationLocalState `json:"apps-local-states"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/application_log_data.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationLogData stores the global information associated with an application. 4 | type ApplicationLogData struct { 5 | // Logs logs for the application being executed by the transaction. 6 | Logs [][]byte `json:"logs"` 7 | 8 | // Txid transaction ID 9 | Txid string `json:"txid"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/application_logs_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationLogsResponse 4 | type ApplicationLogsResponse struct { 5 | // ApplicationId (appidx) application index. 6 | ApplicationId uint64 `json:"application-id"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // LogData 12 | LogData []ApplicationLogData `json:"log-data,omitempty"` 13 | 14 | // NextToken used for pagination, when making another request provide this token 15 | // with the next parameter. 16 | NextToken string `json:"next-token,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /client/v2/common/models/application_params.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationParams stores the global information associated with an application. 4 | type ApplicationParams struct { 5 | // ApprovalProgram approval program. 6 | ApprovalProgram []byte `json:"approval-program"` 7 | 8 | // ClearStateProgram clear state program. 9 | ClearStateProgram []byte `json:"clear-state-program"` 10 | 11 | // Creator the address that created this application. This is the address where the 12 | // parameters and global state for this application can be found. 13 | Creator string `json:"creator,omitempty"` 14 | 15 | // ExtraProgramPages the number of extra program pages available to this app. 16 | ExtraProgramPages uint64 `json:"extra-program-pages,omitempty"` 17 | 18 | // GlobalState global state 19 | GlobalState []TealKeyValue `json:"global-state,omitempty"` 20 | 21 | // GlobalStateSchema global schema 22 | GlobalStateSchema ApplicationStateSchema `json:"global-state-schema,omitempty"` 23 | 24 | // LocalStateSchema local schema 25 | LocalStateSchema ApplicationStateSchema `json:"local-state-schema,omitempty"` 26 | 27 | // Version the number of updates to the application programs 28 | Version uint64 `json:"version,omitempty"` 29 | } 30 | -------------------------------------------------------------------------------- /client/v2/common/models/application_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationResponse 4 | type ApplicationResponse struct { 5 | // Application application index and its parameters 6 | Application Application `json:"application,omitempty"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/application_state_operation.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationStateOperation an operation against an application's global/local/box 4 | // state. 5 | type ApplicationStateOperation struct { 6 | // Account for local state changes, the address of the account associated with the 7 | // local state. 8 | Account string `json:"account,omitempty"` 9 | 10 | // AppStateType type of application state. Value `g` is **global state**, `l` is 11 | // **local state**, `b` is **boxes**. 12 | AppStateType string `json:"app-state-type"` 13 | 14 | // Key the key (name) of the global/local/box state. 15 | Key []byte `json:"key"` 16 | 17 | // NewValue represents an AVM value. 18 | NewValue AvmValue `json:"new-value,omitempty"` 19 | 20 | // Operation operation type. Value `w` is **write**, `d` is **delete**. 21 | Operation string `json:"operation"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/application_state_schema.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationStateSchema specifies maximums on the number of each type that may be 4 | // stored. 5 | type ApplicationStateSchema struct { 6 | // NumByteSlice number of byte slices. 7 | NumByteSlice uint64 `json:"num-byte-slice"` 8 | 9 | // NumUint number of uints. 10 | NumUint uint64 `json:"num-uint"` 11 | } 12 | -------------------------------------------------------------------------------- /client/v2/common/models/applications_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ApplicationsResponse 4 | type ApplicationsResponse struct { 5 | // Applications 6 | Applications []Application `json:"applications"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/asset.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // Asset specifies both the unique identifier and the parameters for an asset 4 | type Asset struct { 5 | // CreatedAtRound round during which this asset was created. 6 | CreatedAtRound uint64 `json:"created-at-round,omitempty"` 7 | 8 | // Deleted whether or not this asset is currently deleted. 9 | Deleted bool `json:"deleted,omitempty"` 10 | 11 | // DestroyedAtRound round during which this asset was destroyed. 12 | DestroyedAtRound uint64 `json:"destroyed-at-round,omitempty"` 13 | 14 | // Index unique asset identifier 15 | Index uint64 `json:"index"` 16 | 17 | // Params assetParams specifies the parameters for an asset. 18 | // (apar) when part of an AssetConfig transaction. 19 | // Definition: 20 | // data/transactions/asset.go : AssetParams 21 | Params AssetParams `json:"params"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/asset_balances_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AssetBalancesResponse 4 | type AssetBalancesResponse struct { 5 | // Balances 6 | Balances []MiniAssetHolding `json:"balances"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/asset_holding.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AssetHolding describes an asset held by an account. 4 | // Definition: 5 | // data/basics/userBalance.go : AssetHolding 6 | type AssetHolding struct { 7 | // Amount number of units held. 8 | Amount uint64 `json:"amount"` 9 | 10 | // AssetId asset ID of the holding. 11 | AssetId uint64 `json:"asset-id"` 12 | 13 | // Deleted whether or not the asset holding is currently deleted from its account. 14 | Deleted bool `json:"deleted,omitempty"` 15 | 16 | // IsFrozen whether or not the holding is frozen. 17 | IsFrozen bool `json:"is-frozen"` 18 | 19 | // OptedInAtRound round during which the account opted into this asset holding. 20 | OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` 21 | 22 | // OptedOutAtRound round during which the account opted out of this asset holding. 23 | OptedOutAtRound uint64 `json:"opted-out-at-round,omitempty"` 24 | } 25 | -------------------------------------------------------------------------------- /client/v2/common/models/asset_holding_reference.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AssetHoldingReference references an asset held by an account. 4 | type AssetHoldingReference struct { 5 | // Account address of the account holding the asset. 6 | Account string `json:"account"` 7 | 8 | // Asset asset ID of the holding. 9 | Asset uint64 `json:"asset"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/asset_holdings_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AssetHoldingsResponse 4 | type AssetHoldingsResponse struct { 5 | // Assets 6 | Assets []AssetHolding `json:"assets"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/asset_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AssetResponse 4 | type AssetResponse struct { 5 | // Asset specifies both the unique identifier and the parameters for an asset 6 | Asset Asset `json:"asset"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/assets_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AssetsResponse 4 | type AssetsResponse struct { 5 | // Assets 6 | Assets []Asset `json:"assets"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/avm_key_value.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AvmKeyValue represents an AVM key-value pair in an application store. 4 | type AvmKeyValue struct { 5 | // Key 6 | Key []byte `json:"key"` 7 | 8 | // Value represents an AVM value. 9 | Value AvmValue `json:"value"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/avm_value.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // AvmValue represents an AVM value. 4 | type AvmValue struct { 5 | // Bytes bytes value. 6 | Bytes []byte `json:"bytes,omitempty"` 7 | 8 | // Type value type. Value `1` refers to **bytes**, value `2` refers to **uint64** 9 | Type uint64 `json:"type"` 10 | 11 | // Uint uint value. 12 | Uint uint64 `json:"uint,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/block_hash_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockHashResponse hash of a block header. 4 | type BlockHashResponse struct { 5 | // Blockhash block header hash. 6 | Blockhash string `json:"blockHash"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/block_headers_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockHeadersResponse 4 | type BlockHeadersResponse struct { 5 | // Blocks 6 | Blocks []Block `json:"blocks"` 7 | 8 | // CurrentRound round at which the results were computed. 9 | CurrentRound uint64 `json:"current-round"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/block_logs_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockLogsResponse all logs emitted in the given round. Each app call, whether 4 | // top-level or inner, that contains logs results in a separate AppCallLogs object. 5 | // Therefore there may be multiple AppCallLogs with the same application ID and 6 | // outer transaction ID in the event of multiple inner app calls to the same app. 7 | // App calls with no logs are not included in the response. AppCallLogs are 8 | // returned in the same order that their corresponding app call appeared in the 9 | // block (pre-order traversal of inner app calls) 10 | type BlockLogsResponse struct { 11 | // Logs 12 | Logs []AppCallLogs `json:"logs"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/block_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "github.com/algorand/go-algorand-sdk/v2/types" 4 | 5 | // BlockResponse encoded block object. 6 | type BlockResponse struct { 7 | // Block block header data. 8 | Block types.Block `json:"block"` 9 | 10 | // Cert optional certificate object. This is only included when the format is set 11 | // to message pack. 12 | Cert *map[string]interface{} `json:"cert,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/block_rewards.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockRewards fields relating to rewards, 4 | type BlockRewards struct { 5 | // FeeSink (fees) accepts transaction fees, it can only spend to the incentive 6 | // pool. 7 | FeeSink string `json:"fee-sink"` 8 | 9 | // RewardsCalculationRound (rwcalr) number of leftover MicroAlgos after the 10 | // distribution of rewards-rate MicroAlgos for every reward unit in the next round. 11 | RewardsCalculationRound uint64 `json:"rewards-calculation-round"` 12 | 13 | // RewardsLevel (earn) How many rewards, in MicroAlgos, have been distributed to 14 | // each RewardUnit of MicroAlgos since genesis. 15 | RewardsLevel uint64 `json:"rewards-level"` 16 | 17 | // RewardsPool (rwd) accepts periodic injections from the fee-sink and continually 18 | // redistributes them as rewards. 19 | RewardsPool string `json:"rewards-pool"` 20 | 21 | // RewardsRate (rate) Number of new MicroAlgos added to the participation stake 22 | // from rewards at the next round. 23 | RewardsRate uint64 `json:"rewards-rate"` 24 | 25 | // RewardsResidue (frac) Number of leftover MicroAlgos after the distribution of 26 | // RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round. 27 | RewardsResidue uint64 `json:"rewards-residue"` 28 | } 29 | -------------------------------------------------------------------------------- /client/v2/common/models/block_txids_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockTxidsResponse top level transaction IDs in a block. 4 | type BlockTxidsResponse struct { 5 | // Blocktxids block transaction IDs. 6 | Blocktxids []string `json:"blockTxids"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/block_upgrade_state.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockUpgradeState fields relating to a protocol upgrade. 4 | type BlockUpgradeState struct { 5 | // CurrentProtocol (proto) The current protocol version. 6 | CurrentProtocol string `json:"current-protocol"` 7 | 8 | // NextProtocol (nextproto) The next proposed protocol version. 9 | NextProtocol string `json:"next-protocol,omitempty"` 10 | 11 | // NextProtocolApprovals (nextyes) Number of blocks which approved the protocol 12 | // upgrade. 13 | NextProtocolApprovals uint64 `json:"next-protocol-approvals,omitempty"` 14 | 15 | // NextProtocolSwitchOn (nextswitch) Round on which the protocol upgrade will take 16 | // effect. 17 | NextProtocolSwitchOn uint64 `json:"next-protocol-switch-on,omitempty"` 18 | 19 | // NextProtocolVoteBefore (nextbefore) Deadline round for this protocol upgrade (No 20 | // votes will be consider after this round). 21 | NextProtocolVoteBefore uint64 `json:"next-protocol-vote-before,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/block_upgrade_vote.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BlockUpgradeVote fields relating to voting for a protocol upgrade. 4 | type BlockUpgradeVote struct { 5 | // UpgradeApprove (upgradeyes) Indicates a yes vote for the current proposal. 6 | UpgradeApprove bool `json:"upgrade-approve,omitempty"` 7 | 8 | // UpgradeDelay (upgradedelay) Indicates the time between acceptance and execution. 9 | UpgradeDelay uint64 `json:"upgrade-delay,omitempty"` 10 | 11 | // UpgradePropose (upgradeprop) Indicates a proposed upgrade. 12 | UpgradePropose string `json:"upgrade-propose,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/box.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // Box box name and its content. 4 | type Box struct { 5 | // Name (name) box name, base64 encoded 6 | Name []byte `json:"name"` 7 | 8 | // Round the round for which this information is relevant 9 | Round uint64 `json:"round"` 10 | 11 | // Value (value) box value, base64 encoded. 12 | Value []byte `json:"value"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/box_descriptor.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BoxDescriptor box descriptor describes an app box without a value. 4 | type BoxDescriptor struct { 5 | // Name base64 encoded box name 6 | Name []byte `json:"name"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/box_reference.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BoxReference boxReference names a box by its name and the application ID it 4 | // belongs to. 5 | type BoxReference struct { 6 | // App application ID to which the box belongs, or zero if referring to the called 7 | // application. 8 | App uint64 `json:"app"` 9 | 10 | // Name base64 encoded box name 11 | Name []byte `json:"name"` 12 | } 13 | -------------------------------------------------------------------------------- /client/v2/common/models/boxes_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BoxesResponse box names of an application 4 | type BoxesResponse struct { 5 | // ApplicationId (appidx) application index. 6 | ApplicationId uint64 `json:"application-id"` 7 | 8 | // Boxes 9 | Boxes []BoxDescriptor `json:"boxes"` 10 | 11 | // NextToken used for pagination, when making another request provide this token 12 | // with the next parameter. 13 | NextToken string `json:"next-token,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/build_version.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // BuildVersion defines a model for BuildVersion. 4 | type BuildVersion struct { 5 | // Branch 6 | Branch string `json:"branch"` 7 | 8 | // BuildNumber 9 | BuildNumber uint64 `json:"build_number"` 10 | 11 | // Channel 12 | Channel string `json:"channel"` 13 | 14 | // CommitHash 15 | CommitHash string `json:"commit_hash"` 16 | 17 | // Major 18 | Major uint64 `json:"major"` 19 | 20 | // Minor 21 | Minor uint64 `json:"minor"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/compile_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // CompileResponse teal compile Result 4 | type CompileResponse struct { 5 | // Hash base32 SHA512_256 of program bytes (Address style) 6 | Hash string `json:"hash"` 7 | 8 | // Result base64 encoded program bytes 9 | Result string `json:"result"` 10 | 11 | // Sourcemap jSON of the source map 12 | Sourcemap *map[string]interface{} `json:"sourcemap,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/disassemble_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // DisassembleResponse teal disassembly Result 4 | type DisassembleResponse struct { 5 | // Result disassembled Teal code 6 | Result string `json:"result"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/dryrun_request.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "github.com/algorand/go-algorand-sdk/v2/types" 4 | 5 | // DryrunRequest request data type for dryrun endpoint. Given the Transactions and 6 | // simulated ledger state upload, run TEAL scripts and return debugging 7 | // information. 8 | type DryrunRequest struct { 9 | // Accounts 10 | Accounts []Account `json:"accounts"` 11 | 12 | // Apps 13 | Apps []Application `json:"apps"` 14 | 15 | // LatestTimestamp latestTimestamp is available to some TEAL scripts. Defaults to 16 | // the latest confirmed timestamp this algod is attached to. 17 | LatestTimestamp uint64 `json:"latest-timestamp"` 18 | 19 | // ProtocolVersion protocolVersion specifies a specific version string to operate 20 | // under, otherwise whatever the current protocol of the network this algod is 21 | // running in. 22 | ProtocolVersion string `json:"protocol-version"` 23 | 24 | // Round round is available to some TEAL scripts. Defaults to the current round on 25 | // the network this algod is attached to. 26 | Round uint64 `json:"round"` 27 | 28 | // Sources 29 | Sources []DryrunSource `json:"sources"` 30 | 31 | // Txns 32 | Txns []types.SignedTxn `json:"txns"` 33 | } 34 | -------------------------------------------------------------------------------- /client/v2/common/models/dryrun_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // DryrunResponse dryrunResponse contains per-txn debug information from a dryrun. 4 | type DryrunResponse struct { 5 | // Error 6 | Error string `json:"error"` 7 | 8 | // ProtocolVersion protocol version is the protocol version Dryrun was operated 9 | // under. 10 | ProtocolVersion string `json:"protocol-version"` 11 | 12 | // Txns 13 | Txns []DryrunTxnResult `json:"txns"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/dryrun_source.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // DryrunSource dryrunSource is TEAL source text that gets uploaded, compiled, and 4 | // inserted into transactions or application state. 5 | type DryrunSource struct { 6 | // AppIndex 7 | AppIndex uint64 `json:"app-index"` 8 | 9 | // FieldName fieldName is what kind of sources this is. If lsig then it goes into 10 | // the transactions[this.TxnIndex].LogicSig. If approv or clearp it goes into the 11 | // Approval Program or Clear State Program of application[this.AppIndex]. 12 | FieldName string `json:"field-name"` 13 | 14 | // Source 15 | Source string `json:"source"` 16 | 17 | // TxnIndex 18 | TxnIndex uint64 `json:"txn-index"` 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/common/models/dryrun_state.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // DryrunState stores the TEAL eval step data 4 | type DryrunState struct { 5 | // Error evaluation error if any 6 | Error string `json:"error,omitempty"` 7 | 8 | // Line line number 9 | Line uint64 `json:"line"` 10 | 11 | // Pc program counter 12 | Pc uint64 `json:"pc"` 13 | 14 | // Scratch 15 | Scratch []TealValue `json:"scratch,omitempty"` 16 | 17 | // Stack 18 | Stack []TealValue `json:"stack"` 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/common/models/dryrun_txn_result.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // DryrunTxnResult dryrunTxnResult contains any LogicSig or ApplicationCall program 4 | // debug information and state updates from a dryrun. 5 | type DryrunTxnResult struct { 6 | // AppCallMessages 7 | AppCallMessages []string `json:"app-call-messages,omitempty"` 8 | 9 | // AppCallTrace 10 | AppCallTrace []DryrunState `json:"app-call-trace,omitempty"` 11 | 12 | // BudgetAdded budget added during execution of app call transaction. 13 | BudgetAdded uint64 `json:"budget-added,omitempty"` 14 | 15 | // BudgetConsumed budget consumed during execution of app call transaction. 16 | BudgetConsumed uint64 `json:"budget-consumed,omitempty"` 17 | 18 | // Disassembly disassembled program line by line. 19 | Disassembly []string `json:"disassembly"` 20 | 21 | // GlobalDelta application state delta. 22 | GlobalDelta []EvalDeltaKeyValue `json:"global-delta,omitempty"` 23 | 24 | // LocalDeltas 25 | LocalDeltas []AccountStateDelta `json:"local-deltas,omitempty"` 26 | 27 | // LogicSigDisassembly disassembled lsig program line by line. 28 | LogicSigDisassembly []string `json:"logic-sig-disassembly,omitempty"` 29 | 30 | // LogicSigMessages 31 | LogicSigMessages []string `json:"logic-sig-messages,omitempty"` 32 | 33 | // LogicSigTrace 34 | LogicSigTrace []DryrunState `json:"logic-sig-trace,omitempty"` 35 | 36 | // Logs 37 | Logs [][]byte `json:"logs,omitempty"` 38 | } 39 | -------------------------------------------------------------------------------- /client/v2/common/models/error_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ErrorResponse response for errors 4 | type ErrorResponse struct { 5 | // Data 6 | Data *map[string]interface{} `json:"data,omitempty"` 7 | 8 | // Message 9 | Message string `json:"message"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/eval_delta.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // EvalDelta represents a TEAL value delta. 4 | type EvalDelta struct { 5 | // Action (at) delta action. 6 | Action uint64 `json:"action"` 7 | 8 | // Bytes (bs) bytes value. 9 | Bytes string `json:"bytes,omitempty"` 10 | 11 | // Uint (ui) uint value. 12 | Uint uint64 `json:"uint,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/eval_delta_key_value.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // EvalDeltaKeyValue key-value pairs for StateDelta. 4 | type EvalDeltaKeyValue struct { 5 | // Key 6 | Key string `json:"key"` 7 | 8 | // Value represents a TEAL value delta. 9 | Value EvalDelta `json:"value"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/genesis.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // Genesis defines a model for Genesis. 4 | type Genesis struct { 5 | // Alloc 6 | Alloc []GenesisAllocation `json:"alloc"` 7 | 8 | // Comment 9 | Comment string `json:"comment,omitempty"` 10 | 11 | // Devmode 12 | Devmode bool `json:"devmode,omitempty"` 13 | 14 | // Fees 15 | Fees string `json:"fees"` 16 | 17 | // Id 18 | Id string `json:"id"` 19 | 20 | // Network 21 | Network string `json:"network"` 22 | 23 | // Proto 24 | Proto string `json:"proto"` 25 | 26 | // Rwd 27 | Rwd string `json:"rwd"` 28 | 29 | // Timestamp 30 | Timestamp uint64 `json:"timestamp"` 31 | } 32 | -------------------------------------------------------------------------------- /client/v2/common/models/genesis_allocation.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // GenesisAllocation defines a model for GenesisAllocation. 4 | type GenesisAllocation struct { 5 | // Addr 6 | Addr string `json:"addr"` 7 | 8 | // Comment 9 | Comment string `json:"comment"` 10 | 11 | // State 12 | State *map[string]interface{} `json:"state"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/get_block_time_stamp_offset_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // GetBlockTimeStampOffsetResponse response containing the timestamp offset in 4 | // seconds 5 | type GetBlockTimeStampOffsetResponse struct { 6 | // Offset timestamp offset in seconds. 7 | Offset uint64 `json:"offset"` 8 | } 9 | -------------------------------------------------------------------------------- /client/v2/common/models/get_sync_round_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // GetSyncRoundResponse response containing the ledger's minimum sync round 4 | type GetSyncRoundResponse struct { 5 | // Round the minimum sync round for the ledger. 6 | Round uint64 `json:"round"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/hash_factory.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // HashFactory defines a model for HashFactory. 4 | type HashFactory struct { 5 | // HashType (t) 6 | HashType uint64 `json:"hash-type,omitempty"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/hb_proof_fields.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // HbProofFields (hbprf) HbProof is a signature using HeartbeatAddress's partkey, 4 | // thereby showing it is online. 5 | type HbProofFields struct { 6 | // HbPk (p) Public key of the heartbeat message. 7 | HbPk []byte `json:"hb-pk,omitempty"` 8 | 9 | // HbPk1sig (p1s) Signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) 10 | // under the key PK2. 11 | HbPk1sig []byte `json:"hb-pk1sig,omitempty"` 12 | 13 | // HbPk2 (p2) Key for new-style two-level ephemeral signature. 14 | HbPk2 []byte `json:"hb-pk2,omitempty"` 15 | 16 | // HbPk2sig (p2s) Signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the 17 | // master key (OneTimeSignatureVerifier). 18 | HbPk2sig []byte `json:"hb-pk2sig,omitempty"` 19 | 20 | // HbSig (s) Signature of the heartbeat message. 21 | HbSig []byte `json:"hb-sig,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/health_check.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // HealthCheck a health check response. 4 | type HealthCheck struct { 5 | // Data 6 | Data *map[string]interface{} `json:"data,omitempty"` 7 | 8 | // DbAvailable 9 | DbAvailable bool `json:"db-available"` 10 | 11 | // Errors 12 | Errors []string `json:"errors,omitempty"` 13 | 14 | // IsMigrating 15 | IsMigrating bool `json:"is-migrating"` 16 | 17 | // Message 18 | Message string `json:"message"` 19 | 20 | // Round 21 | Round uint64 `json:"round"` 22 | 23 | // Version current version. 24 | Version string `json:"version"` 25 | } 26 | -------------------------------------------------------------------------------- /client/v2/common/models/holding_ref.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // HoldingRef holdingRef names a holding by referring to an Address and Asset it 4 | // belongs to. 5 | type HoldingRef struct { 6 | // Address (d) Address in access list, or the sender of the transaction. 7 | Address string `json:"address"` 8 | 9 | // Asset (s) Asset ID for asset in access list. 10 | Asset uint64 `json:"asset"` 11 | } 12 | -------------------------------------------------------------------------------- /client/v2/common/models/indexer_state_proof_message.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // IndexerStateProofMessage defines a model for IndexerStateProofMessage. 4 | type IndexerStateProofMessage struct { 5 | // BlockHeadersCommitment (b) 6 | BlockHeadersCommitment []byte `json:"block-headers-commitment,omitempty"` 7 | 8 | // FirstAttestedRound (f) 9 | FirstAttestedRound uint64 `json:"first-attested-round,omitempty"` 10 | 11 | // LatestAttestedRound (l) 12 | LatestAttestedRound uint64 `json:"latest-attested-round,omitempty"` 13 | 14 | // LnProvenWeight (P) 15 | LnProvenWeight uint64 `json:"ln-proven-weight,omitempty"` 16 | 17 | // VotersCommitment (v) 18 | VotersCommitment []byte `json:"voters-commitment,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/common/models/ledger_state_delta_for_transaction_group.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // LedgerStateDeltaForTransactionGroup contains a ledger delta for a single 4 | // transaction group 5 | type LedgerStateDeltaForTransactionGroup struct { 6 | // Delta ledger StateDelta object 7 | Delta *map[string]interface{} `json:"Delta"` 8 | 9 | // Ids 10 | Ids []string `json:"Ids"` 11 | } 12 | -------------------------------------------------------------------------------- /client/v2/common/models/light_block_header_proof.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // LightBlockHeaderProof proof of membership and position of a light block header. 4 | type LightBlockHeaderProof struct { 5 | // Index the index of the light block header in the vector commitment tree 6 | Index uint64 `json:"index"` 7 | 8 | // Proof the encoded proof. 9 | Proof []byte `json:"proof"` 10 | 11 | // Treedepth represents the depth of the tree that is being proven, i.e. the number 12 | // of edges from a leaf to the root. 13 | Treedepth uint64 `json:"treedepth"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/locals_ref.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // LocalsRef localsRef names a local state by referring to an Address and App it 4 | // belongs to. 5 | type LocalsRef struct { 6 | // Address (d) Address in access list, or the sender of the transaction. 7 | Address string `json:"address"` 8 | 9 | // App (p) Application ID for app in access list, or zero if referring to the 10 | // called application. 11 | App uint64 `json:"app"` 12 | } 13 | -------------------------------------------------------------------------------- /client/v2/common/models/merkle_array_proof.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // MerkleArrayProof defines a model for MerkleArrayProof. 4 | type MerkleArrayProof struct { 5 | // HashFactory 6 | HashFactory HashFactory `json:"hash-factory,omitempty"` 7 | 8 | // Path (pth) 9 | Path [][]byte `json:"path,omitempty"` 10 | 11 | // TreeDepth (td) 12 | TreeDepth uint64 `json:"tree-depth,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/mini_asset_holding.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // MiniAssetHolding a simplified version of AssetHolding 4 | type MiniAssetHolding struct { 5 | // Address 6 | Address string `json:"address"` 7 | 8 | // Amount 9 | Amount uint64 `json:"amount"` 10 | 11 | // Deleted whether or not this asset holding is currently deleted from its account. 12 | Deleted bool `json:"deleted,omitempty"` 13 | 14 | // IsFrozen 15 | IsFrozen bool `json:"is-frozen"` 16 | 17 | // OptedInAtRound round during which the account opted into the asset. 18 | OptedInAtRound uint64 `json:"opted-in-at-round,omitempty"` 19 | 20 | // OptedOutAtRound round during which the account opted out of the asset. 21 | OptedOutAtRound uint64 `json:"opted-out-at-round,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/participation_updates.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ParticipationUpdates participation account data that needs to be checked/acted 4 | // on by the network. 5 | type ParticipationUpdates struct { 6 | // AbsentParticipationAccounts (partupabs) a list of online accounts that need to 7 | // be suspended. 8 | AbsentParticipationAccounts []string `json:"absent-participation-accounts,omitempty"` 9 | 10 | // ExpiredParticipationAccounts (partupdrmv) a list of online accounts that needs 11 | // to be converted to offline since their participation key expired. 12 | ExpiredParticipationAccounts []string `json:"expired-participation-accounts,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/pending_transactions_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "github.com/algorand/go-algorand-sdk/v2/types" 4 | 5 | // PendingTransactionsResponse a potentially truncated list of transactions 6 | // currently in the node's transaction pool. You can compute whether or not the 7 | // list is truncated if the number of elements in the **top-transactions** array is 8 | // fewer than **total-transactions**. 9 | type PendingTransactionsResponse struct { 10 | // TopTransactions an array of signed transaction objects. 11 | TopTransactions []types.SignedTxn `json:"top-transactions"` 12 | 13 | // TotalTransactions total number of transactions in the pool. 14 | TotalTransactions uint64 `json:"total-transactions"` 15 | } 16 | -------------------------------------------------------------------------------- /client/v2/common/models/post_transactions_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // PostTransactionsResponse transaction ID of the submission. 4 | type PostTransactionsResponse struct { 5 | // Txid encoding of the transaction hash. 6 | Txid string `json:"txId"` 7 | } 8 | -------------------------------------------------------------------------------- /client/v2/common/models/resource_ref.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ResourceRef resourceRef names a single resource. Only one of the fields should 4 | // be set. 5 | type ResourceRef struct { 6 | // Address (d) Account whose balance record is accessible by the executing 7 | // ApprovalProgram or ClearStateProgram. 8 | Address string `json:"address,omitempty"` 9 | 10 | // ApplicationId (p) Application id whose GlobalState may be read by the executing 11 | // ApprovalProgram or ClearStateProgram. 12 | ApplicationId uint64 `json:"application-id,omitempty"` 13 | 14 | // AssetId (s) Asset whose AssetParams may be read by the executing 15 | // ApprovalProgram or ClearStateProgram. 16 | AssetId uint64 `json:"asset-id,omitempty"` 17 | 18 | // Box boxReference names a box by its name and the application ID it belongs to. 19 | Box BoxReference `json:"box,omitempty"` 20 | 21 | // Holding holdingRef names a holding by referring to an Address and Asset it 22 | // belongs to. 23 | Holding HoldingRef `json:"holding,omitempty"` 24 | 25 | // Local localsRef names a local state by referring to an Address and App it 26 | // belongs to. 27 | Local LocalsRef `json:"local,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /client/v2/common/models/scratch_change.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // ScratchChange a write operation into a scratch slot. 4 | type ScratchChange struct { 5 | // NewValue represents an AVM value. 6 | NewValue AvmValue `json:"new-value"` 7 | 8 | // Slot the scratch slot written. 9 | Slot uint64 `json:"slot"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/shim.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // Types in this file are used to help convert between hand written code 4 | // that doesn't quite match the spec, and code generated from the spec. 5 | 6 | // NodeStatus is the algod status report. 7 | type NodeStatus NodeStatusResponse 8 | 9 | // PendingTransactionInfoResponse is the single pending transaction response. 10 | type PendingTransactionInfoResponse PendingTransactionResponse 11 | 12 | // HealthCheckResponse defines model for HealthCheckResponse. 13 | type HealthCheckResponse HealthCheck 14 | 15 | // Supply 16 | type Supply SupplyResponse 17 | 18 | // VersionBuild 19 | type VersionBuild BuildVersion 20 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_initial_states.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateInitialStates initial states of resources that were accessed during 4 | // simulation. 5 | type SimulateInitialStates struct { 6 | // AppInitialStates the initial states of accessed application before simulation. 7 | // The order of this array is arbitrary. 8 | AppInitialStates []ApplicationInitialStates `json:"app-initial-states,omitempty"` 9 | } 10 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_request.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateRequest request type for simulation endpoint. 4 | type SimulateRequest struct { 5 | // AllowEmptySignatures allows transactions without signatures to be simulated as 6 | // if they had correct signatures. 7 | AllowEmptySignatures bool `json:"allow-empty-signatures,omitempty"` 8 | 9 | // AllowMoreLogging lifts limits on log opcode usage during simulation. 10 | AllowMoreLogging bool `json:"allow-more-logging,omitempty"` 11 | 12 | // AllowUnnamedResources allows access to unnamed resources during simulation. 13 | AllowUnnamedResources bool `json:"allow-unnamed-resources,omitempty"` 14 | 15 | // ExecTraceConfig an object that configures simulation execution trace. 16 | ExecTraceConfig SimulateTraceConfig `json:"exec-trace-config,omitempty"` 17 | 18 | // ExtraOpcodeBudget applies extra opcode budget during simulation for each 19 | // transaction group. 20 | ExtraOpcodeBudget uint64 `json:"extra-opcode-budget,omitempty"` 21 | 22 | // FixSigners if true, signers for transactions that are missing signatures will be 23 | // fixed during evaluation. 24 | FixSigners bool `json:"fix-signers,omitempty"` 25 | 26 | // Round if provided, specifies the round preceding the simulation. State changes 27 | // through this round will be used to run this simulation. Usually only the 4 most 28 | // recent rounds will be available (controlled by the node config value 29 | // MaxAcctLookback). If not specified, defaults to the latest available round. 30 | Round uint64 `json:"round,omitempty"` 31 | 32 | // TxnGroups the transaction groups to simulate. 33 | TxnGroups []SimulateRequestTransactionGroup `json:"txn-groups"` 34 | } 35 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_request_transaction_group.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "github.com/algorand/go-algorand-sdk/v2/types" 4 | 5 | // SimulateRequestTransactionGroup a transaction group to simulate. 6 | type SimulateRequestTransactionGroup struct { 7 | // Txns an atomic transaction group. 8 | Txns []types.SignedTxn `json:"txns"` 9 | } 10 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateResponse result of a transaction group simulation. 4 | type SimulateResponse struct { 5 | // EvalOverrides the set of parameters and limits override during simulation. If 6 | // this set of parameters is present, then evaluation parameters may differ from 7 | // standard evaluation in certain ways. 8 | EvalOverrides SimulationEvalOverrides `json:"eval-overrides,omitempty"` 9 | 10 | // ExecTraceConfig an object that configures simulation execution trace. 11 | ExecTraceConfig SimulateTraceConfig `json:"exec-trace-config,omitempty"` 12 | 13 | // InitialStates initial states of resources that were accessed during simulation. 14 | InitialStates SimulateInitialStates `json:"initial-states,omitempty"` 15 | 16 | // LastRound the round immediately preceding this simulation. State changes through 17 | // this round were used to run this simulation. 18 | LastRound uint64 `json:"last-round"` 19 | 20 | // TxnGroups a result object for each transaction group that was simulated. 21 | TxnGroups []SimulateTransactionGroupResult `json:"txn-groups"` 22 | 23 | // Version the version of this response object. 24 | Version uint64 `json:"version"` 25 | } 26 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_trace_config.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateTraceConfig an object that configures simulation execution trace. 4 | type SimulateTraceConfig struct { 5 | // Enable a boolean option for opting in execution trace features simulation 6 | // endpoint. 7 | Enable bool `json:"enable,omitempty"` 8 | 9 | // ScratchChange a boolean option enabling returning scratch slot changes together 10 | // with execution trace during simulation. 11 | ScratchChange bool `json:"scratch-change,omitempty"` 12 | 13 | // StackChange a boolean option enabling returning stack changes together with 14 | // execution trace during simulation. 15 | StackChange bool `json:"stack-change,omitempty"` 16 | 17 | // StateChange a boolean option enabling returning application state changes 18 | // (global, local, and box changes) with the execution trace during simulation. 19 | StateChange bool `json:"state-change,omitempty"` 20 | } 21 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_transaction_group_result.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateTransactionGroupResult simulation result for an atomic transaction group 4 | type SimulateTransactionGroupResult struct { 5 | // AppBudgetAdded total budget added during execution of app calls in the 6 | // transaction group. 7 | AppBudgetAdded uint64 `json:"app-budget-added,omitempty"` 8 | 9 | // AppBudgetConsumed total budget consumed during execution of app calls in the 10 | // transaction group. 11 | AppBudgetConsumed uint64 `json:"app-budget-consumed,omitempty"` 12 | 13 | // FailedAt if present, indicates which transaction in this group caused the 14 | // failure. This array represents the path to the failing transaction. Indexes are 15 | // zero based, the first element indicates the top-level transaction, and 16 | // successive elements indicate deeper inner transactions. 17 | FailedAt []uint64 `json:"failed-at,omitempty"` 18 | 19 | // FailureMessage if present, indicates that the transaction group failed and 20 | // specifies why that happened 21 | FailureMessage string `json:"failure-message,omitempty"` 22 | 23 | // TxnResults simulation result for individual transactions 24 | TxnResults []SimulateTransactionResult `json:"txn-results"` 25 | 26 | // UnnamedResourcesAccessed these are resources that were accessed by this group 27 | // that would normally have caused failure, but were allowed in simulation. 28 | // Depending on where this object is in the response, the unnamed resources it 29 | // contains may or may not qualify for group resource sharing. If this is a field 30 | // in SimulateTransactionGroupResult, the resources do qualify, but if this is a 31 | // field in SimulateTransactionResult, they do not qualify. In order to make this 32 | // group valid for actual submission, resources that qualify for group sharing can 33 | // be made available by any transaction of the group; otherwise, resources must be 34 | // placed in the same transaction which accessed them. 35 | UnnamedResourcesAccessed SimulateUnnamedResourcesAccessed `json:"unnamed-resources-accessed,omitempty"` 36 | } 37 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_transaction_result.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateTransactionResult simulation result for an individual transaction 4 | type SimulateTransactionResult struct { 5 | // AppBudgetConsumed budget used during execution of an app call transaction. This 6 | // value includes budged used by inner app calls spawned by this transaction. 7 | AppBudgetConsumed uint64 `json:"app-budget-consumed,omitempty"` 8 | 9 | // ExecTrace the execution trace of calling an app or a logic sig, containing the 10 | // inner app call trace in a recursive way. 11 | ExecTrace SimulationTransactionExecTrace `json:"exec-trace,omitempty"` 12 | 13 | // FixedSigner the account that needed to sign this transaction when no signature 14 | // was provided and the provided signer was incorrect. 15 | FixedSigner string `json:"fixed-signer,omitempty"` 16 | 17 | // LogicSigBudgetConsumed budget used during execution of a logic sig transaction. 18 | LogicSigBudgetConsumed uint64 `json:"logic-sig-budget-consumed,omitempty"` 19 | 20 | // TxnResult details about a pending transaction. If the transaction was recently 21 | // confirmed, includes confirmation details like the round and reward details. 22 | TxnResult PendingTransactionResponse `json:"txn-result"` 23 | 24 | // UnnamedResourcesAccessed these are resources that were accessed by this group 25 | // that would normally have caused failure, but were allowed in simulation. 26 | // Depending on where this object is in the response, the unnamed resources it 27 | // contains may or may not qualify for group resource sharing. If this is a field 28 | // in SimulateTransactionGroupResult, the resources do qualify, but if this is a 29 | // field in SimulateTransactionResult, they do not qualify. In order to make this 30 | // group valid for actual submission, resources that qualify for group sharing can 31 | // be made available by any transaction of the group; otherwise, resources must be 32 | // placed in the same transaction which accessed them. 33 | UnnamedResourcesAccessed SimulateUnnamedResourcesAccessed `json:"unnamed-resources-accessed,omitempty"` 34 | } 35 | -------------------------------------------------------------------------------- /client/v2/common/models/simulate_unnamed_resources_accessed.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulateUnnamedResourcesAccessed these are resources that were accessed by this 4 | // group that would normally have caused failure, but were allowed in simulation. 5 | // Depending on where this object is in the response, the unnamed resources it 6 | // contains may or may not qualify for group resource sharing. If this is a field 7 | // in SimulateTransactionGroupResult, the resources do qualify, but if this is a 8 | // field in SimulateTransactionResult, they do not qualify. In order to make this 9 | // group valid for actual submission, resources that qualify for group sharing can 10 | // be made available by any transaction of the group; otherwise, resources must be 11 | // placed in the same transaction which accessed them. 12 | type SimulateUnnamedResourcesAccessed struct { 13 | // Accounts the unnamed accounts that were referenced. The order of this array is 14 | // arbitrary. 15 | Accounts []string `json:"accounts,omitempty"` 16 | 17 | // AppLocals the unnamed application local states that were referenced. The order 18 | // of this array is arbitrary. 19 | AppLocals []ApplicationLocalReference `json:"app-locals,omitempty"` 20 | 21 | // Apps the unnamed applications that were referenced. The order of this array is 22 | // arbitrary. 23 | Apps []uint64 `json:"apps,omitempty"` 24 | 25 | // AssetHoldings the unnamed asset holdings that were referenced. The order of this 26 | // array is arbitrary. 27 | AssetHoldings []AssetHoldingReference `json:"asset-holdings,omitempty"` 28 | 29 | // Assets the unnamed assets that were referenced. The order of this array is 30 | // arbitrary. 31 | Assets []uint64 `json:"assets,omitempty"` 32 | 33 | // Boxes the unnamed boxes that were referenced. The order of this array is 34 | // arbitrary. 35 | Boxes []BoxReference `json:"boxes,omitempty"` 36 | 37 | // ExtraBoxRefs the number of extra box references used to increase the IO budget. 38 | // This is in addition to the references defined in the input transaction group and 39 | // any referenced to unnamed boxes. 40 | ExtraBoxRefs uint64 `json:"extra-box-refs,omitempty"` 41 | } 42 | -------------------------------------------------------------------------------- /client/v2/common/models/simulation_eval_overrides.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulationEvalOverrides the set of parameters and limits override during 4 | // simulation. If this set of parameters is present, then evaluation parameters may 5 | // differ from standard evaluation in certain ways. 6 | type SimulationEvalOverrides struct { 7 | // AllowEmptySignatures if true, transactions without signatures are allowed and 8 | // simulated as if they were properly signed. 9 | AllowEmptySignatures bool `json:"allow-empty-signatures,omitempty"` 10 | 11 | // AllowUnnamedResources if true, allows access to unnamed resources during 12 | // simulation. 13 | AllowUnnamedResources bool `json:"allow-unnamed-resources,omitempty"` 14 | 15 | // ExtraOpcodeBudget the extra opcode budget added to each transaction group during 16 | // simulation 17 | ExtraOpcodeBudget uint64 `json:"extra-opcode-budget,omitempty"` 18 | 19 | // FixSigners if true, signers for transactions that are missing signatures will be 20 | // fixed during evaluation. 21 | FixSigners bool `json:"fix-signers,omitempty"` 22 | 23 | // MaxLogCalls the maximum log calls one can make during simulation 24 | MaxLogCalls uint64 `json:"max-log-calls,omitempty"` 25 | 26 | // MaxLogSize the maximum byte number to log during simulation 27 | MaxLogSize uint64 `json:"max-log-size,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /client/v2/common/models/simulation_opcode_trace_unit.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulationOpcodeTraceUnit the set of trace information and effect from 4 | // evaluating a single opcode. 5 | type SimulationOpcodeTraceUnit struct { 6 | // Pc the program counter of the current opcode being evaluated. 7 | Pc uint64 `json:"pc"` 8 | 9 | // ScratchChanges the writes into scratch slots. 10 | ScratchChanges []ScratchChange `json:"scratch-changes,omitempty"` 11 | 12 | // SpawnedInners the indexes of the traces for inner transactions spawned by this 13 | // opcode, if any. 14 | SpawnedInners []uint64 `json:"spawned-inners,omitempty"` 15 | 16 | // StackAdditions the values added by this opcode to the stack. 17 | StackAdditions []AvmValue `json:"stack-additions,omitempty"` 18 | 19 | // StackPopCount the number of deleted stack values by this opcode. 20 | StackPopCount uint64 `json:"stack-pop-count,omitempty"` 21 | 22 | // StateChanges the operations against the current application's states. 23 | StateChanges []ApplicationStateOperation `json:"state-changes,omitempty"` 24 | } 25 | -------------------------------------------------------------------------------- /client/v2/common/models/simulation_transaction_exec_trace.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SimulationTransactionExecTrace the execution trace of calling an app or a logic 4 | // sig, containing the inner app call trace in a recursive way. 5 | type SimulationTransactionExecTrace struct { 6 | // ApprovalProgramHash sHA512_256 hash digest of the approval program executed in 7 | // transaction. 8 | ApprovalProgramHash []byte `json:"approval-program-hash,omitempty"` 9 | 10 | // ApprovalProgramTrace program trace that contains a trace of opcode effects in an 11 | // approval program. 12 | ApprovalProgramTrace []SimulationOpcodeTraceUnit `json:"approval-program-trace,omitempty"` 13 | 14 | // ClearStateProgramHash sHA512_256 hash digest of the clear state program executed 15 | // in transaction. 16 | ClearStateProgramHash []byte `json:"clear-state-program-hash,omitempty"` 17 | 18 | // ClearStateProgramTrace program trace that contains a trace of opcode effects in 19 | // a clear state program. 20 | ClearStateProgramTrace []SimulationOpcodeTraceUnit `json:"clear-state-program-trace,omitempty"` 21 | 22 | // ClearStateRollback if true, indicates that the clear state program failed and 23 | // any persistent state changes it produced should be reverted once the program 24 | // exits. 25 | ClearStateRollback bool `json:"clear-state-rollback,omitempty"` 26 | 27 | // ClearStateRollbackError the error message explaining why the clear state program 28 | // failed. This field will only be populated if clear-state-rollback is true and 29 | // the failure was due to an execution error. 30 | ClearStateRollbackError string `json:"clear-state-rollback-error,omitempty"` 31 | 32 | // InnerTrace an array of SimulationTransactionExecTrace representing the execution 33 | // trace of any inner transactions executed. 34 | InnerTrace []SimulationTransactionExecTrace `json:"inner-trace,omitempty"` 35 | 36 | // LogicSigHash sHA512_256 hash digest of the logic sig executed in transaction. 37 | LogicSigHash []byte `json:"logic-sig-hash,omitempty"` 38 | 39 | // LogicSigTrace program trace that contains a trace of opcode effects in a logic 40 | // sig. 41 | LogicSigTrace []SimulationOpcodeTraceUnit `json:"logic-sig-trace,omitempty"` 42 | } 43 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProof represents a state proof and its corresponding message 4 | type StateProof struct { 5 | // Message represents the message that the state proofs are attesting to. 6 | Message StateProofMessage `json:"Message"` 7 | 8 | // Stateproof the encoded StateProof for the message. 9 | Stateproof []byte `json:"StateProof"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_fields.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofFields (sp) represents a state proof. 4 | // Definition: 5 | // crypto/stateproof/structs.go : StateProof 6 | type StateProofFields struct { 7 | // PartProofs (P) 8 | PartProofs MerkleArrayProof `json:"part-proofs,omitempty"` 9 | 10 | // PositionsToReveal (pr) Sequence of reveal positions. 11 | PositionsToReveal []uint64 `json:"positions-to-reveal,omitempty"` 12 | 13 | // Reveals (r) Note that this is actually stored as a map[uint64] - Reveal in the 14 | // actual msgp 15 | Reveals []StateProofReveal `json:"reveals,omitempty"` 16 | 17 | // SaltVersion (v) Salt version of the merkle signature. 18 | SaltVersion uint64 `json:"salt-version,omitempty"` 19 | 20 | // SigCommit (c) 21 | SigCommit []byte `json:"sig-commit,omitempty"` 22 | 23 | // SigProofs (S) 24 | SigProofs MerkleArrayProof `json:"sig-proofs,omitempty"` 25 | 26 | // SignedWeight (w) 27 | SignedWeight uint64 `json:"signed-weight,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_message.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofMessage represents the message that the state proofs are attesting to. 4 | type StateProofMessage struct { 5 | // Blockheaderscommitment the vector commitment root on all light block headers 6 | // within a state proof interval. 7 | Blockheaderscommitment []byte `json:"BlockHeadersCommitment"` 8 | 9 | // Firstattestedround the first round the message attests to. 10 | Firstattestedround uint64 `json:"FirstAttestedRound"` 11 | 12 | // Lastattestedround the last round the message attests to. 13 | Lastattestedround uint64 `json:"LastAttestedRound"` 14 | 15 | // Lnprovenweight an integer value representing the natural log of the proven 16 | // weight with 16 bits of precision. This value would be used to verify the next 17 | // state proof. 18 | Lnprovenweight uint64 `json:"LnProvenWeight"` 19 | 20 | // Voterscommitment the vector commitment root of the top N accounts to sign the 21 | // next StateProof. 22 | Voterscommitment []byte `json:"VotersCommitment"` 23 | } 24 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_participant.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofParticipant defines a model for StateProofParticipant. 4 | type StateProofParticipant struct { 5 | // Verifier (p) 6 | Verifier StateProofVerifier `json:"verifier,omitempty"` 7 | 8 | // Weight (w) 9 | Weight uint64 `json:"weight,omitempty"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_reveal.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofReveal defines a model for StateProofReveal. 4 | type StateProofReveal struct { 5 | // Participant (p) 6 | Participant StateProofParticipant `json:"participant,omitempty"` 7 | 8 | // Position the position in the signature and participants arrays corresponding to 9 | // this entry. 10 | Position uint64 `json:"position,omitempty"` 11 | 12 | // SigSlot (s) 13 | SigSlot StateProofSigSlot `json:"sig-slot,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_sig_slot.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofSigSlot defines a model for StateProofSigSlot. 4 | type StateProofSigSlot struct { 5 | // LowerSigWeight (l) The total weight of signatures in the lower-numbered slots. 6 | LowerSigWeight uint64 `json:"lower-sig-weight,omitempty"` 7 | 8 | // Signature 9 | Signature StateProofSignature `json:"signature,omitempty"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_signature.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofSignature defines a model for StateProofSignature. 4 | type StateProofSignature struct { 5 | // FalconSignature 6 | FalconSignature []byte `json:"falcon-signature,omitempty"` 7 | 8 | // MerkleArrayIndex 9 | MerkleArrayIndex uint64 `json:"merkle-array-index,omitempty"` 10 | 11 | // Proof 12 | Proof MerkleArrayProof `json:"proof,omitempty"` 13 | 14 | // VerifyingKey (vkey) 15 | VerifyingKey []byte `json:"verifying-key,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_tracking.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofTracking defines a model for StateProofTracking. 4 | type StateProofTracking struct { 5 | // NextRound (n) Next round for which we will accept a state proof transaction. 6 | NextRound uint64 `json:"next-round,omitempty"` 7 | 8 | // OnlineTotalWeight (t) The total number of microalgos held by the online accounts 9 | // during the StateProof round. 10 | OnlineTotalWeight uint64 `json:"online-total-weight,omitempty"` 11 | 12 | // Type state Proof Type. Note the raw object uses map with this as key. 13 | Type uint64 `json:"type,omitempty"` 14 | 15 | // VotersCommitment (v) Root of a vector commitment containing online accounts that 16 | // will help sign the proof. 17 | VotersCommitment []byte `json:"voters-commitment,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /client/v2/common/models/state_proof_verifier.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateProofVerifier defines a model for StateProofVerifier. 4 | type StateProofVerifier struct { 5 | // Commitment (cmt) Represents the root of the vector commitment tree. 6 | Commitment []byte `json:"commitment,omitempty"` 7 | 8 | // KeyLifetime (lf) Key lifetime. 9 | KeyLifetime uint64 `json:"key-lifetime,omitempty"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/state_schema.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // StateSchema represents a (apls) local-state or (apgs) global-state schema. These 4 | // schemas determine how much storage may be used in a local-state or global-state 5 | // for an application. The more space used, the larger minimum balance must be 6 | // maintained in the account holding the data. 7 | type StateSchema struct { 8 | // NumByteSlice maximum number of TEAL byte slices that may be stored in the 9 | // key/value store. 10 | NumByteSlice uint64 `json:"num-byte-slice"` 11 | 12 | // NumUint maximum number of TEAL uints that may be stored in the key/value store. 13 | NumUint uint64 `json:"num-uint"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/supply_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // SupplyResponse supply represents the current supply of MicroAlgos in the system. 4 | type SupplyResponse struct { 5 | // Current_round round 6 | Current_round uint64 `json:"current_round"` 7 | 8 | // OnlineMoney onlineMoney 9 | OnlineMoney uint64 `json:"online-money"` 10 | 11 | // TotalMoney totalMoney 12 | TotalMoney uint64 `json:"total-money"` 13 | } 14 | -------------------------------------------------------------------------------- /client/v2/common/models/teal_key_value.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TealKeyValue represents a key-value pair in an application store. 4 | type TealKeyValue struct { 5 | // Key 6 | Key string `json:"key"` 7 | 8 | // Value represents a TEAL value. 9 | Value TealValue `json:"value"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/teal_value.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TealValue represents a TEAL value. 4 | type TealValue struct { 5 | // Bytes bytes value. 6 | Bytes string `json:"bytes"` 7 | 8 | // Type type of the value. Value `1` refers to **bytes**, value `2` refers to 9 | // **uint** 10 | Type uint64 `json:"type"` 11 | 12 | // Uint uint value. 13 | Uint uint64 `json:"uint"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_asset_config.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionAssetConfig fields for asset allocation, re-configuration, and 4 | // destruction. 5 | // A zero value for asset-id indicates asset creation. 6 | // A zero value for the params indicates asset destruction. 7 | // Definition: 8 | // data/transactions/asset.go : AssetConfigTxnFields 9 | type TransactionAssetConfig struct { 10 | // AssetId (xaid) ID of the asset being configured or empty if creating. 11 | AssetId uint64 `json:"asset-id,omitempty"` 12 | 13 | // Params assetParams specifies the parameters for an asset. 14 | // (apar) when part of an AssetConfig transaction. 15 | // Definition: 16 | // data/transactions/asset.go : AssetParams 17 | Params AssetParams `json:"params,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_asset_freeze.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionAssetFreeze fields for an asset freeze transaction. 4 | // Definition: 5 | // data/transactions/asset.go : AssetFreezeTxnFields 6 | type TransactionAssetFreeze struct { 7 | // Address (fadd) Address of the account whose asset is being frozen or thawed. 8 | Address string `json:"address"` 9 | 10 | // AssetId (faid) ID of the asset being frozen or thawed. 11 | AssetId uint64 `json:"asset-id"` 12 | 13 | // NewFreezeStatus (afrz) The new freeze status. 14 | NewFreezeStatus bool `json:"new-freeze-status"` 15 | } 16 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_asset_transfer.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionAssetTransfer fields for an asset transfer transaction. 4 | // Definition: 5 | // data/transactions/asset.go : AssetTransferTxnFields 6 | type TransactionAssetTransfer struct { 7 | // Amount (aamt) Amount of asset to transfer. A zero amount transferred to self 8 | // allocates that asset in the account's Assets map. 9 | Amount uint64 `json:"amount"` 10 | 11 | // AssetId (xaid) ID of the asset being transferred. 12 | AssetId uint64 `json:"asset-id"` 13 | 14 | // CloseAmount number of assets transferred to the close-to account as part of the 15 | // transaction. 16 | CloseAmount uint64 `json:"close-amount,omitempty"` 17 | 18 | // CloseTo (aclose) Indicates that the asset should be removed from the account's 19 | // Assets map, and specifies where the remaining asset holdings should be 20 | // transferred. It's always valid to transfer remaining asset holdings to the 21 | // creator account. 22 | CloseTo string `json:"close-to,omitempty"` 23 | 24 | // Receiver (arcv) Recipient address of the transfer. 25 | Receiver string `json:"receiver"` 26 | 27 | // Sender (asnd) The effective sender during a clawback transactions. If this is 28 | // not a zero value, the real transaction sender must be the Clawback address from 29 | // the AssetParams. 30 | Sender string `json:"sender,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_group_ledger_state_deltas_for_round_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionGroupLedgerStateDeltasForRoundResponse response containing all ledger 4 | // state deltas for transaction groups, with their associated Ids, in a single 5 | // round. 6 | type TransactionGroupLedgerStateDeltasForRoundResponse struct { 7 | // Deltas 8 | Deltas []LedgerStateDeltaForTransactionGroup `json:"Deltas"` 9 | } 10 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_heartbeat.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionHeartbeat fields for a heartbeat transaction. 4 | // Definition: 5 | // data/transactions/heartbeat.go : HeartbeatTxnFields 6 | type TransactionHeartbeat struct { 7 | // HbAddress (hbad) HbAddress is the account this txn is proving onlineness for. 8 | HbAddress string `json:"hb-address"` 9 | 10 | // HbKeyDilution (hbkd) HbKeyDilution must match HbAddress account's current 11 | // KeyDilution. 12 | HbKeyDilution uint64 `json:"hb-key-dilution"` 13 | 14 | // HbProof (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby 15 | // showing it is online. 16 | HbProof HbProofFields `json:"hb-proof"` 17 | 18 | // HbSeed (hbsd) HbSeed must be the block seed for the this transaction's 19 | // firstValid block. 20 | HbSeed []byte `json:"hb-seed"` 21 | 22 | // HbVoteId (hbvid) HbVoteID must match the HbAddress account's current VoteID. 23 | HbVoteId []byte `json:"hb-vote-id"` 24 | } 25 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_keyreg.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionKeyreg fields for a keyreg transaction. 4 | // Definition: 5 | // data/transactions/keyreg.go : KeyregTxnFields 6 | type TransactionKeyreg struct { 7 | // NonParticipation (nonpart) Mark the account as participating or 8 | // non-participating. 9 | NonParticipation bool `json:"non-participation,omitempty"` 10 | 11 | // SelectionParticipationKey (selkey) Public key used with the Verified Random 12 | // Function (VRF) result during committee selection. 13 | SelectionParticipationKey []byte `json:"selection-participation-key,omitempty"` 14 | 15 | // StateProofKey (sprfkey) State proof key used in key registration transactions. 16 | StateProofKey []byte `json:"state-proof-key,omitempty"` 17 | 18 | // VoteFirstValid (votefst) First round this participation key is valid. 19 | VoteFirstValid uint64 `json:"vote-first-valid,omitempty"` 20 | 21 | // VoteKeyDilution (votekd) Number of subkeys in each batch of participation keys. 22 | VoteKeyDilution uint64 `json:"vote-key-dilution,omitempty"` 23 | 24 | // VoteLastValid (votelst) Last round this participation key is valid. 25 | VoteLastValid uint64 `json:"vote-last-valid,omitempty"` 26 | 27 | // VoteParticipationKey (votekey) Participation public key used in key registration 28 | // transactions. 29 | VoteParticipationKey []byte `json:"vote-participation-key,omitempty"` 30 | } 31 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_parameters_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionParametersResponse transactionParams contains the parameters that 4 | // help a client construct a new transaction. 5 | type TransactionParametersResponse struct { 6 | // ConsensusVersion consensusVersion indicates the consensus protocol version 7 | // as of LastRound. 8 | ConsensusVersion string `json:"consensus-version"` 9 | 10 | // Fee fee is the suggested transaction fee 11 | // Fee is in units of micro-Algos per byte. 12 | // Fee may fall to zero but transactions must still have a fee of 13 | // at least MinTxnFee for the current network protocol. 14 | Fee uint64 `json:"fee"` 15 | 16 | // GenesisHash genesisHash is the hash of the genesis block. 17 | GenesisHash []byte `json:"genesis-hash"` 18 | 19 | // GenesisId genesisID is an ID listed in the genesis block. 20 | GenesisId string `json:"genesis-id"` 21 | 22 | // LastRound lastRound indicates the last round seen 23 | LastRound uint64 `json:"last-round"` 24 | 25 | // MinFee the minimum transaction fee (not per byte) required for the 26 | // txn to validate for the current network protocol. 27 | MinFee uint64 `json:"min-fee"` 28 | } 29 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_payment.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionPayment fields for a payment transaction. 4 | // Definition: 5 | // data/transactions/payment.go : PaymentTxnFields 6 | type TransactionPayment struct { 7 | // Amount (amt) number of MicroAlgos intended to be transferred. 8 | Amount uint64 `json:"amount"` 9 | 10 | // CloseAmount number of MicroAlgos that were sent to the close-remainder-to 11 | // address when closing the sender account. 12 | CloseAmount uint64 `json:"close-amount,omitempty"` 13 | 14 | // CloseRemainderTo (close) when set, indicates that the sending account should be 15 | // closed and all remaining funds be transferred to this address. 16 | CloseRemainderTo string `json:"close-remainder-to,omitempty"` 17 | 18 | // Receiver (rcv) receiver's address. 19 | Receiver string `json:"receiver"` 20 | } 21 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_proof.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionProof proof of transaction in a block. 4 | type TransactionProof struct { 5 | // Hashtype the type of hash function used to create the proof, must be one of: 6 | // * sha512_256 7 | // * sha256 8 | Hashtype string `json:"hashtype,omitempty"` 9 | 10 | // Idx index of the transaction in the block's payset. 11 | Idx uint64 `json:"idx"` 12 | 13 | // Proof proof of transaction membership. 14 | Proof []byte `json:"proof"` 15 | 16 | // Stibhash hash of SignedTxnInBlock for verifying proof. 17 | Stibhash []byte `json:"stibhash"` 18 | 19 | // Treedepth represents the depth of the tree that is being proven, i.e. the number 20 | // of edges from a leaf to the root. 21 | Treedepth uint64 `json:"treedepth"` 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionResponse 4 | type TransactionResponse struct { 5 | // CurrentRound round at which the results were computed. 6 | CurrentRound uint64 `json:"current-round"` 7 | 8 | // Transaction contains all fields common to all transactions and serves as an 9 | // envelope to all transactions type. Represents both regular and inner 10 | // transactions. 11 | // Definition: 12 | // data/transactions/signedtxn.go : SignedTxn 13 | // data/transactions/transaction.go : Transaction 14 | Transaction Transaction `json:"transaction"` 15 | } 16 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_signature.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionSignature validation signature associated with some data. Only one of 4 | // the signatures should be provided. 5 | type TransactionSignature struct { 6 | // Logicsig (lsig) Programatic transaction signature. 7 | // Definition: 8 | // data/transactions/logicsig.go 9 | Logicsig TransactionSignatureLogicsig `json:"logicsig,omitempty"` 10 | 11 | // Multisig structure holding multiple subsignatures. 12 | // Definition: 13 | // crypto/multisig.go : MultisigSig 14 | Multisig TransactionSignatureMultisig `json:"multisig,omitempty"` 15 | 16 | // Sig (sig) Standard ed25519 signature. 17 | Sig []byte `json:"sig,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_signature_logicsig.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionSignatureLogicsig (lsig) Programatic transaction signature. 4 | // Definition: 5 | // data/transactions/logicsig.go 6 | type TransactionSignatureLogicsig struct { 7 | // Args (arg) Logic arguments, base64 encoded. 8 | Args [][]byte `json:"args,omitempty"` 9 | 10 | // Logic (l) Program signed by a signature or multi signature, or hashed to be the 11 | // address of ana ccount. Base64 encoded TEAL program. 12 | Logic []byte `json:"logic"` 13 | 14 | // LogicMultisigSignature structure holding multiple subsignatures. 15 | // Definition: 16 | // crypto/multisig.go : MultisigSig 17 | LogicMultisigSignature TransactionSignatureMultisig `json:"logic-multisig-signature,omitempty"` 18 | 19 | // MultisigSignature structure holding multiple subsignatures. 20 | // Definition: 21 | // crypto/multisig.go : MultisigSig 22 | MultisigSignature TransactionSignatureMultisig `json:"multisig-signature,omitempty"` 23 | 24 | // Signature (sig) ed25519 signature. 25 | Signature []byte `json:"signature,omitempty"` 26 | } 27 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_signature_multisig.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionSignatureMultisig structure holding multiple subsignatures. 4 | // Definition: 5 | // crypto/multisig.go : MultisigSig 6 | type TransactionSignatureMultisig struct { 7 | // Subsignature (subsig) holds pairs of public key and signatures. 8 | Subsignature []TransactionSignatureMultisigSubsignature `json:"subsignature,omitempty"` 9 | 10 | // Threshold (thr) 11 | Threshold uint64 `json:"threshold,omitempty"` 12 | 13 | // Version (v) 14 | Version uint64 `json:"version,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_signature_multisig_subsignature.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionSignatureMultisigSubsignature defines a model for TransactionSignatureMultisigSubsignature. 4 | type TransactionSignatureMultisigSubsignature struct { 5 | // PublicKey (pk) 6 | PublicKey []byte `json:"public-key,omitempty"` 7 | 8 | // Signature (s) 9 | Signature []byte `json:"signature,omitempty"` 10 | } 11 | -------------------------------------------------------------------------------- /client/v2/common/models/transaction_state_proof.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionStateProof fields for a state proof transaction. 4 | // Definition: 5 | // data/transactions/stateproof.go : StateProofTxnFields 6 | type TransactionStateProof struct { 7 | // Message (spmsg) 8 | Message IndexerStateProofMessage `json:"message,omitempty"` 9 | 10 | // StateProof (sp) represents a state proof. 11 | // Definition: 12 | // crypto/stateproof/structs.go : StateProof 13 | StateProof StateProofFields `json:"state-proof,omitempty"` 14 | 15 | // StateProofType (sptype) Type of the state proof. Integer representing an entry 16 | // defined in protocol/stateproof.go 17 | StateProofType uint64 `json:"state-proof-type,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /client/v2/common/models/transactions_response.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // TransactionsResponse 4 | type TransactionsResponse struct { 5 | // CurrentRound round at which the results were computed. 6 | CurrentRound uint64 `json:"current-round"` 7 | 8 | // NextToken used for pagination, when making another request provide this token 9 | // with the next parameter. 10 | NextToken string `json:"next-token,omitempty"` 11 | 12 | // Transactions 13 | Transactions []Transaction `json:"transactions"` 14 | } 15 | -------------------------------------------------------------------------------- /client/v2/common/models/version.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // Version algod version information. 4 | type Version struct { 5 | // Build 6 | Build BuildVersion `json:"build"` 7 | 8 | // GenesisHash 9 | GenesisHash []byte `json:"genesis_hash_b64"` 10 | 11 | // GenesisID 12 | GenesisID string `json:"genesis_id"` 13 | 14 | // Versions 15 | Versions []string `json:"versions"` 16 | } 17 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupAccountAssets.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // LookupAccountAssetsParams contains all of the query parameters for url serialization. 12 | type LookupAccountAssetsParams struct { 13 | 14 | // AssetID asset ID 15 | AssetID uint64 `url:"asset-id,omitempty"` 16 | 17 | // IncludeAll include all items including closed accounts, deleted applications, 18 | // destroyed assets, opted-out asset holdings, and closed-out application 19 | // localstates. 20 | IncludeAll bool `url:"include-all,omitempty"` 21 | 22 | // Limit maximum number of results to return. There could be additional pages even 23 | // if the limit is not reached. 24 | Limit uint64 `url:"limit,omitempty"` 25 | 26 | // Next the next page of results. Use the next token provided by the previous 27 | // results. 28 | Next string `url:"next,omitempty"` 29 | } 30 | 31 | // LookupAccountAssets lookup an account's asset holdings, optionally for a 32 | // specific ID. 33 | type LookupAccountAssets struct { 34 | c *Client 35 | 36 | accountId string 37 | 38 | p LookupAccountAssetsParams 39 | } 40 | 41 | // AssetID asset ID 42 | func (s *LookupAccountAssets) AssetID(AssetID uint64) *LookupAccountAssets { 43 | s.p.AssetID = AssetID 44 | 45 | return s 46 | } 47 | 48 | // IncludeAll include all items including closed accounts, deleted applications, 49 | // destroyed assets, opted-out asset holdings, and closed-out application 50 | // localstates. 51 | func (s *LookupAccountAssets) IncludeAll(IncludeAll bool) *LookupAccountAssets { 52 | s.p.IncludeAll = IncludeAll 53 | 54 | return s 55 | } 56 | 57 | // Limit maximum number of results to return. There could be additional pages even 58 | // if the limit is not reached. 59 | func (s *LookupAccountAssets) Limit(Limit uint64) *LookupAccountAssets { 60 | s.p.Limit = Limit 61 | 62 | return s 63 | } 64 | 65 | // Next the next page of results. Use the next token provided by the previous 66 | // results. 67 | func (s *LookupAccountAssets) Next(Next string) *LookupAccountAssets { 68 | s.p.Next = Next 69 | 70 | return s 71 | } 72 | 73 | // Do performs the HTTP request 74 | func (s *LookupAccountAssets) Do(ctx context.Context, headers ...*common.Header) (response models.AssetHoldingsResponse, err error) { 75 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/accounts/%s/assets", common.EscapeParams(s.accountId)...), s.p, headers) 76 | return 77 | } 78 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupAccountByID.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // LookupAccountByIDParams contains all of the query parameters for url serialization. 12 | type LookupAccountByIDParams struct { 13 | 14 | // Exclude exclude additional items such as asset holdings, application local data 15 | // stored for this account, asset parameters created by this account, and 16 | // application parameters created by this account. 17 | Exclude []string `url:"exclude,omitempty,comma"` 18 | 19 | // IncludeAll include all items including closed accounts, deleted applications, 20 | // destroyed assets, opted-out asset holdings, and closed-out application 21 | // localstates. 22 | IncludeAll bool `url:"include-all,omitempty"` 23 | 24 | // Round include results for the specified round. 25 | Round uint64 `url:"round,omitempty"` 26 | } 27 | 28 | // LookupAccountByID lookup account information. 29 | type LookupAccountByID struct { 30 | c *Client 31 | 32 | accountId string 33 | 34 | p LookupAccountByIDParams 35 | } 36 | 37 | // Exclude exclude additional items such as asset holdings, application local data 38 | // stored for this account, asset parameters created by this account, and 39 | // application parameters created by this account. 40 | func (s *LookupAccountByID) Exclude(Exclude []string) *LookupAccountByID { 41 | s.p.Exclude = Exclude 42 | 43 | return s 44 | } 45 | 46 | // IncludeAll include all items including closed accounts, deleted applications, 47 | // destroyed assets, opted-out asset holdings, and closed-out application 48 | // localstates. 49 | func (s *LookupAccountByID) IncludeAll(IncludeAll bool) *LookupAccountByID { 50 | s.p.IncludeAll = IncludeAll 51 | 52 | return s 53 | } 54 | 55 | // Round include results for the specified round. 56 | func (s *LookupAccountByID) Round(Round uint64) *LookupAccountByID { 57 | s.p.Round = Round 58 | 59 | return s 60 | } 61 | 62 | // Do performs the HTTP request 63 | func (s *LookupAccountByID) Do(ctx context.Context, headers ...*common.Header) (validRound uint64, result models.Account, err error) { 64 | response := models.AccountResponse{} 65 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/accounts/%s", s.accountId), s.p, headers) 66 | validRound = response.CurrentRound 67 | result = response.Account 68 | return 69 | } 70 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupApplicationBoxByIDAndName.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "encoding/base64" 6 | "fmt" 7 | 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 9 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 10 | ) 11 | 12 | // LookupApplicationBoxByIDAndNameParams contains all of the query parameters for url serialization. 13 | type LookupApplicationBoxByIDAndNameParams struct { 14 | 15 | // Name a box name in goal-arg form 'encoding:value'. For ints, use the form 16 | // 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable strings, use 17 | // the form 'str:hello'. For addresses, use the form 'addr:XYZ...'. 18 | Name string `url:"name,omitempty"` 19 | } 20 | 21 | // LookupApplicationBoxByIDAndName given an application ID and box name, returns 22 | // base64 encoded box name and value. Box names must be in the goal app call arg 23 | // form 'encoding:value'. For ints, use the form 'int:1234'. For raw bytes, encode 24 | // base 64 and use 'b64' prefix as in 'b64:A=='. For printable strings, use the 25 | // form 'str:hello'. For addresses, use the form 'addr:XYZ...'. 26 | type LookupApplicationBoxByIDAndName struct { 27 | c *Client 28 | 29 | applicationId uint64 30 | 31 | p LookupApplicationBoxByIDAndNameParams 32 | } 33 | 34 | // name a box name in goal-arg form 'encoding:value'. For ints, use the form 35 | // 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable strings, use 36 | // the form 'str:hello'. For addresses, use the form 'addr:XYZ...'. 37 | func (s *LookupApplicationBoxByIDAndName) name(name []byte) *LookupApplicationBoxByIDAndName { 38 | s.p.Name = "b64:" + base64.StdEncoding.EncodeToString(name) 39 | 40 | return s 41 | } 42 | 43 | // Do performs the HTTP request 44 | func (s *LookupApplicationBoxByIDAndName) Do(ctx context.Context, headers ...*common.Header) (response models.Box, err error) { 45 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/box", common.EscapeParams(s.applicationId)...), s.p, headers) 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupApplicationByID.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // LookupApplicationByIDParams contains all of the query parameters for url serialization. 12 | type LookupApplicationByIDParams struct { 13 | 14 | // IncludeAll include all items including closed accounts, deleted applications, 15 | // destroyed assets, opted-out asset holdings, and closed-out application 16 | // localstates. 17 | IncludeAll bool `url:"include-all,omitempty"` 18 | } 19 | 20 | // LookupApplicationByID lookup application. 21 | type LookupApplicationByID struct { 22 | c *Client 23 | 24 | applicationId uint64 25 | 26 | p LookupApplicationByIDParams 27 | } 28 | 29 | // IncludeAll include all items including closed accounts, deleted applications, 30 | // destroyed assets, opted-out asset holdings, and closed-out application 31 | // localstates. 32 | func (s *LookupApplicationByID) IncludeAll(IncludeAll bool) *LookupApplicationByID { 33 | s.p.IncludeAll = IncludeAll 34 | 35 | return s 36 | } 37 | 38 | // Do performs the HTTP request 39 | func (s *LookupApplicationByID) Do(ctx context.Context, headers ...*common.Header) (response models.ApplicationResponse, err error) { 40 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s", common.EscapeParams(s.applicationId)...), s.p, headers) 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupAssetByID.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // LookupAssetByIDParams contains all of the query parameters for url serialization. 12 | type LookupAssetByIDParams struct { 13 | 14 | // IncludeAll include all items including closed accounts, deleted applications, 15 | // destroyed assets, opted-out asset holdings, and closed-out application 16 | // localstates. 17 | IncludeAll bool `url:"include-all,omitempty"` 18 | } 19 | 20 | // LookupAssetByID lookup asset information. 21 | type LookupAssetByID struct { 22 | c *Client 23 | 24 | assetId uint64 25 | 26 | p LookupAssetByIDParams 27 | } 28 | 29 | // IncludeAll include all items including closed accounts, deleted applications, 30 | // destroyed assets, opted-out asset holdings, and closed-out application 31 | // localstates. 32 | func (s *LookupAssetByID) IncludeAll(IncludeAll bool) *LookupAssetByID { 33 | s.p.IncludeAll = IncludeAll 34 | 35 | return s 36 | } 37 | 38 | // Do performs the HTTP request 39 | func (s *LookupAssetByID) Do(ctx context.Context, headers ...*common.Header) (validRound uint64, result models.Asset, err error) { 40 | response := models.AssetResponse{} 41 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/assets/%d", s.assetId), s.p, headers) 42 | validRound = response.CurrentRound 43 | result = response.Asset 44 | return 45 | } 46 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupBlock.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // LookupBlockParams contains all of the query parameters for url serialization. 12 | type LookupBlockParams struct { 13 | 14 | // HeaderOnly header only flag. When this is set to true, returned block does not 15 | // contain the transactions 16 | HeaderOnly bool `url:"header-only,omitempty"` 17 | } 18 | 19 | // LookupBlock lookup block. 20 | type LookupBlock struct { 21 | c *Client 22 | 23 | roundNumber uint64 24 | 25 | p LookupBlockParams 26 | } 27 | 28 | // HeaderOnly header only flag. When this is set to true, returned block does not 29 | // contain the transactions 30 | func (s *LookupBlock) HeaderOnly(HeaderOnly bool) *LookupBlock { 31 | s.p.HeaderOnly = HeaderOnly 32 | 33 | return s 34 | } 35 | 36 | // Do performs the HTTP request 37 | func (s *LookupBlock) Do(ctx context.Context, headers ...*common.Header) (response models.Block, err error) { 38 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s", common.EscapeParams(s.roundNumber)...), s.p, headers) 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /client/v2/indexer/lookupTransaction.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // LookupTransaction lookup a single transaction. 12 | type LookupTransaction struct { 13 | c *Client 14 | 15 | txid string 16 | } 17 | 18 | // Do performs the HTTP request 19 | func (s *LookupTransaction) Do(ctx context.Context, headers ...*common.Header) (response models.TransactionResponse, err error) { 20 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/transactions/%s", common.EscapeParams(s.txid)...), nil, headers) 21 | return 22 | } 23 | -------------------------------------------------------------------------------- /client/v2/indexer/makeHealthCheck.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 8 | ) 9 | 10 | // HealthCheck returns 200 if healthy. 11 | type HealthCheck struct { 12 | c *Client 13 | } 14 | 15 | // Do performs the HTTP request 16 | func (s *HealthCheck) Do(ctx context.Context, headers ...*common.Header) (response models.HealthCheckResponse, err error) { 17 | err = s.c.get(ctx, &response, "/health", nil, headers) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /client/v2/indexer/searchForApplicationBoxes.go: -------------------------------------------------------------------------------- 1 | package indexer 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 9 | ) 10 | 11 | // SearchForApplicationBoxesParams contains all of the query parameters for url serialization. 12 | type SearchForApplicationBoxesParams struct { 13 | 14 | // Limit maximum number of results to return. There could be additional pages even 15 | // if the limit is not reached. 16 | Limit uint64 `url:"limit,omitempty"` 17 | 18 | // Next the next page of results. Use the next token provided by the previous 19 | // results. 20 | Next string `url:"next,omitempty"` 21 | } 22 | 23 | // SearchForApplicationBoxes given an application ID, returns the box names of that 24 | // application sorted lexicographically. 25 | type SearchForApplicationBoxes struct { 26 | c *Client 27 | 28 | applicationId uint64 29 | 30 | p SearchForApplicationBoxesParams 31 | } 32 | 33 | // Limit maximum number of results to return. There could be additional pages even 34 | // if the limit is not reached. 35 | func (s *SearchForApplicationBoxes) Limit(Limit uint64) *SearchForApplicationBoxes { 36 | s.p.Limit = Limit 37 | 38 | return s 39 | } 40 | 41 | // Next the next page of results. Use the next token provided by the previous 42 | // results. 43 | func (s *SearchForApplicationBoxes) Next(Next string) *SearchForApplicationBoxes { 44 | s.p.Next = Next 45 | 46 | return s 47 | } 48 | 49 | // Do performs the HTTP request 50 | func (s *SearchForApplicationBoxes) Do(ctx context.Context, headers ...*common.Header) (response models.BoxesResponse, err error) { 51 | err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/boxes", common.EscapeParams(s.applicationId)...), s.p, headers) 52 | return 53 | } 54 | -------------------------------------------------------------------------------- /crypto/errors.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var errInvalidSignatureReturned = errors.New("ed25519 library returned an invalid signature") 8 | var errInvalidPrivateKey = errors.New("invalid private key") 9 | var errMsigUnknownVersion = errors.New("unknown version != 1") 10 | var errMsigInvalidThreshold = errors.New("invalid threshold") 11 | var errMsigInvalidSecretKey = errors.New("secret key has no corresponding public identity in multisig preimage") 12 | var errMsigMergeLessThanTwo = errors.New("cannot merge fewer than two multisig transactions") 13 | var errMsigMergeKeysMismatch = errors.New("multisig parameters do not match") 14 | var errMsigMergeInvalidDups = errors.New("mismatched duplicate signatures") 15 | var errMsigMergeAuthAddrMismatch = errors.New("mismatched AuthAddrs") 16 | var errLsigTooManySignatures = errors.New("logicsig has too many signatures, at most one of Sig or Msig may be defined") 17 | var errLsigInvalidSignature = errors.New("invalid logicsig signature") 18 | var errLsigNoPublicKey = errors.New("missing public key of delegated logicsig") 19 | var errLsigInvalidPublicKey = errors.New("public key does not match logicsig signature") 20 | var errLsigEmptyMsig = errors.New("empty multisig in logicsig") 21 | var errLsigAccountPublicKeyNotNeeded = errors.New("a public key for the signer was provided when none was expected") 22 | -------------------------------------------------------------------------------- /crypto/msig_delegated.txn: -------------------------------------------------------------------------------- 1 | { 2 | "lsig": { 3 | "arg:b64": [ 4 | "AQ==", 5 | "AgM=" 6 | ], 7 | "l:b64": "ASABASI=", 8 | "lmsig": { 9 | "subsig": [ 10 | { 11 | "pk:b64": "G37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXg=", 12 | "s:b64": "jDNlxLHRE3DyP3DXd0af4dlHeb9NjWSBdkk173hMzHZXbMDg7+nBRvpgdtr6zlXumvMbdo68MrTsGiyMPcBnBg==" 13 | }, 14 | { 15 | "pk:b64": "CWMyCVNzifB1ZxF3OZHH0D4bc8jE9Sv2r/Aaolz5wnE=", 16 | "s:b64": "T1bUfdnAsWoV9Yhk6edD1TEJH/evbLKB3zQNFTojbqXZF3PZ/5dljvfqY/A3aM3+KL6KxoJ683Gt2YSnOOrlDQ==" 17 | }, 18 | { 19 | "pk:b64": "5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKE=" 20 | } 21 | ], 22 | "thr": 2, 23 | "v": 1 24 | } 25 | }, 26 | "txn": { 27 | "amt": 5000, 28 | "fee": 217000, 29 | "fv": 972508, 30 | "gen": "testnet-v31.0", 31 | "lv": 973508, 32 | "note:b64": "tFF5Ofz60nE=", 33 | "rcv:b64": "tMYiaKTDNVD1im3UuMojnJ8dELNBqn4aNuPOYfv8+Yo=", 34 | "snd:b64": "jZK0iZABc6BN+kNZo2ZqavzqLEKgXdnB9z7rpUeAN+k=", 35 | "type": "pay" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /crypto/msig_delegated_other.txn: -------------------------------------------------------------------------------- 1 | { 2 | "lsig": { 3 | "arg:b64": [ 4 | "AQ==", 5 | "AgM=" 6 | ], 7 | "l:b64": "ASABASI=", 8 | "lmsig": { 9 | "subsig": [ 10 | { 11 | "pk:b64": "G37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXg=", 12 | "s:b64": "jDNlxLHRE3DyP3DXd0af4dlHeb9NjWSBdkk173hMzHZXbMDg7+nBRvpgdtr6zlXumvMbdo68MrTsGiyMPcBnBg==" 13 | }, 14 | { 15 | "pk:b64": "CWMyCVNzifB1ZxF3OZHH0D4bc8jE9Sv2r/Aaolz5wnE=", 16 | "s:b64": "T1bUfdnAsWoV9Yhk6edD1TEJH/evbLKB3zQNFTojbqXZF3PZ/5dljvfqY/A3aM3+KL6KxoJ683Gt2YSnOOrlDQ==" 17 | }, 18 | { 19 | "pk:b64": "5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKE=" 20 | } 21 | ], 22 | "thr": 2, 23 | "v": 1 24 | } 25 | }, 26 | "sgnr:b64": "jZK0iZABc6BN+kNZo2ZqavzqLEKgXdnB9z7rpUeAN+k=", 27 | "txn": { 28 | "amt": 5000, 29 | "fee": 217000, 30 | "fv": 972508, 31 | "gen": "testnet-v31.0", 32 | "lv": 973508, 33 | "note:b64": "tFF5Ofz60nE=", 34 | "rcv:b64": "tMYiaKTDNVD1im3UuMojnJ8dELNBqn4aNuPOYfv8+Yo=", 35 | "snd:b64": "tMYiaKTDNVD1im3UuMojnJ8dELNBqn4aNuPOYfv8+Yo=", 36 | "type": "pay" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /encoding/msgpack/msgpack.go: -------------------------------------------------------------------------------- 1 | package msgpack 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/algorand/go-codec/codec" 7 | ) 8 | 9 | // CodecHandle is used to instantiate msgpack encoders and decoders 10 | // with our settings (canonical, paranoid about decoding errors) 11 | var CodecHandle *codec.MsgpackHandle 12 | 13 | // LenientCodecHandle is used to instantiate msgpack encoders for the REST API. 14 | var LenientCodecHandle *codec.MsgpackHandle 15 | 16 | // init configures our msgpack encoder and decoder 17 | func init() { 18 | CodecHandle = new(codec.MsgpackHandle) 19 | CodecHandle.ErrorIfNoField = true 20 | CodecHandle.ErrorIfNoArrayExpand = true 21 | CodecHandle.Canonical = true 22 | CodecHandle.RecursiveEmptyCheck = true 23 | CodecHandle.WriteExt = true 24 | CodecHandle.PositiveIntUnsigned = true 25 | 26 | LenientCodecHandle = new(codec.MsgpackHandle) 27 | // allow unknown fields to ensure forward compatibility. 28 | LenientCodecHandle.ErrorIfNoField = false 29 | LenientCodecHandle.ErrorIfNoArrayExpand = true 30 | LenientCodecHandle.Canonical = true 31 | LenientCodecHandle.RecursiveEmptyCheck = true 32 | LenientCodecHandle.WriteExt = true 33 | LenientCodecHandle.PositiveIntUnsigned = true 34 | } 35 | 36 | // Encode returns a msgpack-encoded byte buffer for a given object 37 | func Encode(obj interface{}) []byte { 38 | var b []byte 39 | enc := codec.NewEncoderBytes(&b, CodecHandle) 40 | enc.MustEncode(obj) 41 | return b 42 | } 43 | 44 | // Decode attempts to decode a msgpack-encoded byte buffer into an 45 | // object instance pointed to by objptr 46 | func Decode(b []byte, objptr interface{}) error { 47 | dec := codec.NewDecoderBytes(b, CodecHandle) 48 | err := dec.Decode(objptr) 49 | if err != nil { 50 | return err 51 | } 52 | return nil 53 | } 54 | 55 | // NewDecoder returns a msgpack decoder 56 | func NewDecoder(r io.Reader) *codec.Decoder { 57 | return codec.NewDecoder(r, CodecHandle) 58 | } 59 | 60 | // NewLenientDecoder returns a msgpack decoder 61 | func NewLenientDecoder(r io.Reader) *codec.Decoder { 62 | return codec.NewDecoder(r, LenientCodecHandle) 63 | } 64 | -------------------------------------------------------------------------------- /encoding/msgpack/msgpack_test.go: -------------------------------------------------------------------------------- 1 | package msgpack 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | type object struct { 11 | subsetObject 12 | Name string `codec:"name"` 13 | } 14 | 15 | type subsetObject struct { 16 | Data string `codec:"data"` 17 | } 18 | 19 | func TestDecode(t *testing.T) { 20 | obj := object{ 21 | subsetObject: subsetObject{Data: "data"}, 22 | Name: "name", 23 | } 24 | encodedOb := Encode(obj) 25 | 26 | t.Run("basic encode/decode test", func(t *testing.T) { 27 | // basic encode/decode test. 28 | var decoded object 29 | err := Decode(encodedOb, &decoded) 30 | assert.NoError(t, err) 31 | assert.Equal(t, obj, decoded) 32 | }) 33 | 34 | t.Run("strict decode, pass", func(t *testing.T) { 35 | // strict decode test 36 | decoder := NewDecoder(bytes.NewReader(encodedOb)) 37 | var decoded object 38 | err := decoder.Decode(&decoded) 39 | assert.NoError(t, err) 40 | assert.Equal(t, obj, decoded) 41 | }) 42 | 43 | t.Run("strict decode subset, fail", func(t *testing.T) { 44 | // strict decode test 45 | decoder := NewDecoder(bytes.NewReader(encodedOb)) 46 | var decoded subsetObject 47 | err := decoder.Decode(&decoded) 48 | assert.Error(t, err) 49 | assert.Contains(t, err.Error(), "no matching struct field found when decoding stream map with key name") 50 | }) 51 | 52 | t.Run("lenient decode subset, pass", func(t *testing.T) { 53 | // strict decode test 54 | decoder := NewLenientDecoder(bytes.NewReader(encodedOb)) 55 | var decoded subsetObject 56 | err := decoder.Decode(&decoded) 57 | assert.NoError(t, err) 58 | assert.Equal(t, obj.subsetObject, decoded) 59 | }) 60 | } 61 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Algorand Go SDK Examples 2 | ----------------------- 3 | 4 | This directory contains examples of how to use the Algorand Go SDK. 5 | 6 | Assuming a sandbox node is running locally, any example can be run with the following command: 7 | 8 | ```sh 9 | go run /main.go 10 | ``` 11 | -------------------------------------------------------------------------------- /examples/application/approval.teal: -------------------------------------------------------------------------------- 1 | #pragma version 4 2 | // Handle each possible OnCompletion type. We don't have to worry about 3 | // handling ClearState, because the ClearStateProgram will execute in that 4 | // case, not the ApprovalProgram. 5 | txn ApplicationID 6 | int 0 7 | == 8 | bnz handle_approve 9 | 10 | txn OnCompletion 11 | int NoOp 12 | == 13 | bnz handle_noop 14 | 15 | txn OnCompletion 16 | int OptIn 17 | == 18 | bnz handle_approve 19 | 20 | txn OnCompletion 21 | int CloseOut 22 | == 23 | bnz handle_closeout 24 | 25 | txn OnCompletion 26 | int UpdateApplication 27 | == 28 | bnz handle_updateapp 29 | 30 | txn OnCompletion 31 | int DeleteApplication 32 | == 33 | bnz handle_deleteapp 34 | 35 | // Unexpected OnCompletion value. Should be unreachable. 36 | err 37 | 38 | handle_noop: 39 | // Handle NoOp 40 | 41 | // read global state 42 | byte "counter" 43 | dup 44 | app_global_get 45 | 46 | // increment the value 47 | int 1 48 | + 49 | 50 | // store to scratch space 51 | dup 52 | store 0 53 | 54 | // update global state 55 | app_global_put 56 | 57 | // read local state for sender 58 | int 0 59 | byte "counter" 60 | app_local_get 61 | 62 | // increment the value 63 | int 1 64 | + 65 | store 1 66 | 67 | // update local state for sender 68 | int 0 69 | byte "counter" 70 | load 1 71 | app_local_put 72 | 73 | // load return value as approval 74 | load 0 75 | return 76 | 77 | 78 | handle_closeout: 79 | // Handle CloseOut 80 | //approval 81 | int 1 82 | return 83 | 84 | handle_deleteapp: 85 | // Check for creator 86 | global CreatorAddress 87 | txn Sender 88 | == 89 | return 90 | 91 | handle_updateapp: 92 | // Check for creator 93 | global CreatorAddress 94 | txn Sender 95 | == 96 | return 97 | 98 | handle_approve: 99 | int 1 100 | return 101 | -------------------------------------------------------------------------------- /examples/application/approval_refactored.teal: -------------------------------------------------------------------------------- 1 | #pragma version 4 2 | // Handle each possible OnCompletion type. We don't have to worry about 3 | // handling ClearState, because the ClearStateProgram will execute in that 4 | // case, not the ApprovalProgram. 5 | 6 | txn ApplicationID 7 | int 0 8 | == 9 | bnz handle_approve 10 | 11 | txn OnCompletion 12 | int NoOp 13 | == 14 | bnz handle_noop 15 | 16 | txn OnCompletion 17 | int OptIn 18 | == 19 | bnz handle_approve 20 | 21 | txn OnCompletion 22 | int CloseOut 23 | == 24 | bnz handle_closeout 25 | 26 | txn OnCompletion 27 | int UpdateApplication 28 | == 29 | bnz handle_updateapp 30 | 31 | txn OnCompletion 32 | int DeleteApplication 33 | == 34 | bnz handle_deleteapp 35 | 36 | // Unexpected OnCompletion value. Should be unreachable. 37 | err 38 | 39 | handle_noop: 40 | // Handle NoOp 41 | 42 | // read global state 43 | byte "counter" 44 | dup 45 | app_global_get 46 | 47 | // increment the value 48 | int 1 49 | + 50 | 51 | // store to scratch space 52 | dup 53 | store 0 54 | 55 | // update global state 56 | app_global_put 57 | 58 | // read local state for sender 59 | int 0 60 | byte "counter" 61 | app_local_get 62 | 63 | // increment the value 64 | int 1 65 | + 66 | store 1 67 | 68 | // update local state for sender 69 | // update "counter" 70 | int 0 71 | byte "counter" 72 | load 1 73 | app_local_put 74 | 75 | // update "timestamp" 76 | int 0 77 | byte "timestamp" 78 | txn ApplicationArgs 0 79 | app_local_put 80 | 81 | // load return value as approval 82 | load 0 83 | return 84 | 85 | handle_closeout: 86 | // Handle CloseOut 87 | //approval 88 | int 1 89 | return 90 | 91 | handle_deleteapp: 92 | // Check for creator 93 | global CreatorAddress 94 | txn Sender 95 | == 96 | return 97 | 98 | handle_updateapp: 99 | // Check for creator 100 | global CreatorAddress 101 | txn Sender 102 | == 103 | return 104 | 105 | handle_approve: 106 | int 1 107 | return -------------------------------------------------------------------------------- /examples/application/clear.teal: -------------------------------------------------------------------------------- 1 | #pragma version 4 2 | int 1 3 | return -------------------------------------------------------------------------------- /examples/calculator/clear.teal: -------------------------------------------------------------------------------- 1 | #pragma version 8 2 | pushint 0 // 0 3 | return -------------------------------------------------------------------------------- /examples/calculator/contract.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Calculator", 3 | "methods": [ 4 | { 5 | "name": "add", 6 | "args": [ 7 | { 8 | "type": "uint64", 9 | "name": "a" 10 | }, 11 | { 12 | "type": "uint64", 13 | "name": "b" 14 | } 15 | ], 16 | "returns": { 17 | "type": "uint64" 18 | }, 19 | "desc": "Add a and b, return the result" 20 | }, 21 | { 22 | "name": "mul", 23 | "args": [ 24 | { 25 | "type": "uint64", 26 | "name": "a" 27 | }, 28 | { 29 | "type": "uint64", 30 | "name": "b" 31 | } 32 | ], 33 | "returns": { 34 | "type": "uint64" 35 | }, 36 | "desc": "Multiply a and b, return the result" 37 | }, 38 | { 39 | "name": "sub", 40 | "args": [ 41 | { 42 | "type": "uint64", 43 | "name": "a" 44 | }, 45 | { 46 | "type": "uint64", 47 | "name": "b" 48 | } 49 | ], 50 | "returns": { 51 | "type": "uint64" 52 | }, 53 | "desc": "Subtract b from a, return the result" 54 | }, 55 | { 56 | "name": "div", 57 | "args": [ 58 | { 59 | "type": "uint64", 60 | "name": "a" 61 | }, 62 | { 63 | "type": "uint64", 64 | "name": "b" 65 | } 66 | ], 67 | "returns": { 68 | "type": "uint64" 69 | }, 70 | "desc": "Divide a by b, return the result" 71 | } 72 | ], 73 | "networks": {} 74 | } -------------------------------------------------------------------------------- /examples/debug/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log" 6 | "os" 7 | 8 | "github.com/algorand/go-algorand-sdk/v2/crypto" 9 | "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" 10 | "github.com/algorand/go-algorand-sdk/v2/examples" 11 | "github.com/algorand/go-algorand-sdk/v2/transaction" 12 | "github.com/algorand/go-algorand-sdk/v2/types" 13 | ) 14 | 15 | func main() { 16 | 17 | algodClient := examples.GetAlgodClient() 18 | accts, err := examples.GetSandboxAccounts() 19 | if err != nil { 20 | log.Fatalf("failed to get sandbox accounts: %s", err) 21 | } 22 | 23 | acct1 := accts[0] 24 | 25 | appID := examples.DeployApp(algodClient, acct1) 26 | 27 | // example: DEBUG_DRYRUN_DUMP 28 | var ( 29 | args [][]byte 30 | accounts []string 31 | apps []uint64 32 | assets []uint64 33 | ) 34 | 35 | sp, err := algodClient.SuggestedParams().Do(context.Background()) 36 | if err != nil { 37 | log.Fatalf("failed to get suggested params: %s", err) 38 | } 39 | 40 | appCallTxn, err := transaction.MakeApplicationNoOpTx( 41 | appID, args, accounts, apps, assets, sp, acct1.Address, 42 | nil, types.Digest{}, [32]byte{}, types.Address{}, 43 | ) 44 | if err != nil { 45 | log.Fatalf("Failed to create app call txn: %+v", err) 46 | } 47 | 48 | _, stxn, err := crypto.SignTransaction(acct1.PrivateKey, appCallTxn) 49 | if err != nil { 50 | log.Fatalf("Failed to sign app txn: %+v", err) 51 | } 52 | 53 | signedAppCallTxn := types.SignedTxn{} 54 | msgpack.Decode(stxn, &signedAppCallTxn) 55 | 56 | drr, err := transaction.CreateDryrun(algodClient, []types.SignedTxn{signedAppCallTxn}, nil, context.Background()) 57 | if err != nil { 58 | log.Fatalf("Failed to create dryrun: %+v", err) 59 | } 60 | 61 | os.WriteFile("dryrun.msgp", msgpack.Encode(drr), 0666) 62 | // example: DEBUG_DRYRUN_DUMP 63 | 64 | // example: DEBUG_DRYRUN_SUBMIT 65 | // Create the dryrun request object 66 | drReq, err := transaction.CreateDryrun(algodClient, []types.SignedTxn{signedAppCallTxn}, nil, context.Background()) 67 | if err != nil { 68 | log.Fatalf("Failed to create dryrun: %+v", err) 69 | } 70 | 71 | // Pass dryrun request to algod server 72 | dryrunResponse, err := algodClient.TealDryrun(drReq).Do(context.Background()) 73 | if err != nil { 74 | log.Fatalf("failed to dryrun request: %s", err) 75 | } 76 | 77 | // Inspect the response to check result 78 | for _, txn := range dryrunResponse.Txns { 79 | log.Printf("%+v", txn.AppCallTrace) 80 | } 81 | // example: DEBUG_DRYRUN_SUBMIT 82 | os.Remove("dryrun.msgp") 83 | } 84 | -------------------------------------------------------------------------------- /examples/lsig/sample_arg.teal: -------------------------------------------------------------------------------- 1 | #pragma version 5 2 | arg_0 3 | btoi 4 | int 123 5 | == -------------------------------------------------------------------------------- /examples/lsig/simple.teal: -------------------------------------------------------------------------------- 1 | #pragma version 5 2 | int 1 3 | return -------------------------------------------------------------------------------- /examples/participation/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/examples" 8 | "github.com/algorand/go-algorand-sdk/v2/transaction" 9 | ) 10 | 11 | func main() { 12 | markOnline() 13 | } 14 | 15 | func markOnline() { 16 | // setup connection 17 | algodClient := examples.GetAlgodClient() 18 | 19 | // get network suggested parameters 20 | sp, err := algodClient.SuggestedParams().Do(context.Background()) 21 | if err != nil { 22 | fmt.Printf("error getting suggested tx params: %s\n", err) 23 | return 24 | } 25 | 26 | // Mark Account as "Online" (participating) 27 | // example: TRANSACTION_KEYREG_ONLINE_CREATE 28 | fromAddr := "MWAPNXBDFFD2V5KWXAHWKBO7FO4JN36VR4CIBDKDDE7WAUAGZIXM3QPJW4" 29 | voteKey := "87iBW46PP4BpTDz6+IEGvxY6JqEaOtV0g+VWcJqoqtc=" 30 | selKey := "1V2BE2lbFvS937H7pJebN0zxkqe1Nrv+aVHDTPbYRlw=" 31 | sProofKey := "f0CYOA4yXovNBFMFX+1I/tYVBaAl7VN6e0Ki5yZA3H6jGqsU/LYHNaBkMQ/rN4M4F3UmNcpaTmbVbq+GgDsrhQ==" 32 | voteFirst := uint64(16532750) 33 | voteLast := uint64(19532750) 34 | keyDilution := uint64(1732) 35 | nonpart := false 36 | tx, err := transaction.MakeKeyRegTxnWithStateProofKey( 37 | fromAddr, 38 | []byte{}, 39 | sp, 40 | voteKey, 41 | selKey, 42 | sProofKey, 43 | voteFirst, 44 | voteLast, 45 | keyDilution, 46 | nonpart, 47 | ) 48 | // example: TRANSACTION_KEYREG_ONLINE_CREATE 49 | if err != nil { 50 | fmt.Printf("Error creating transaction: %s\n", err) 51 | return 52 | } 53 | _ = tx 54 | 55 | // disabled example: TRANSACTION_KEYREG_OFFLINE_CREATE 56 | // disabled example: TRANSACTION_KEYREG_OFFLINE_CREATE 57 | } 58 | -------------------------------------------------------------------------------- /examples/smoke_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/env/bin bash 2 | 3 | export ALGOD_PORT="60000" 4 | export INDEXER_PORT="59999" 5 | export KMD_PORT="60001" 6 | 7 | # Loop through each directory in the current working directory 8 | for dir in */; do 9 | # Check if main.go exists in the directory 10 | if [ -f "${dir}main.go" ]; then 11 | # Run the "go run" command with the relative path 12 | go run "${dir}main.go" 13 | # Check if the test failed 14 | if [ $? -ne 0 ]; then 15 | echo "Test failed, stopping script" 16 | exit 1 17 | fi 18 | fi 19 | done -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/algorand/go-algorand-sdk/v2 2 | 3 | go 1.25.0 4 | 5 | toolchain go1.25.3 6 | 7 | require ( 8 | github.com/algorand/avm-abi v0.2.0 9 | github.com/algorand/go-codec/codec v1.1.10 10 | github.com/cucumber/godog v0.14.1 11 | github.com/google/go-querystring v1.1.0 12 | github.com/stretchr/testify v1.9.0 13 | golang.org/x/crypto v0.45.0 14 | ) 15 | 16 | require ( 17 | github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect 18 | github.com/cucumber/messages/go/v21 v21.0.1 // indirect 19 | github.com/davecgh/go-spew v1.1.1 // indirect 20 | github.com/gofrs/uuid v4.3.1+incompatible // indirect 21 | github.com/hashicorp/go-immutable-radix v1.3.1 // indirect 22 | github.com/hashicorp/go-memdb v1.3.4 // indirect 23 | github.com/hashicorp/golang-lru v0.5.4 // indirect 24 | github.com/pmezard/go-difflib v1.0.0 // indirect 25 | github.com/spf13/pflag v1.0.5 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | ) 28 | -------------------------------------------------------------------------------- /mnemonic/errors.go: -------------------------------------------------------------------------------- 1 | package mnemonic 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var errWrongKeyLen = fmt.Errorf("key length must be %d bytes", keyLenBytes) 8 | var errWrongMnemonicLen = fmt.Errorf("mnemonic must be %d words", mnemonicLenWords) 9 | var errWrongChecksum = fmt.Errorf("checksum failed to validate") 10 | -------------------------------------------------------------------------------- /mnemonic/helpers.go: -------------------------------------------------------------------------------- 1 | package mnemonic 2 | 3 | import ( 4 | "golang.org/x/crypto/ed25519" 5 | 6 | "github.com/algorand/go-algorand-sdk/v2/types" 7 | ) 8 | 9 | // FromPrivateKey is a helper that converts an ed25519 private key to a 10 | // human-readable mnemonic 11 | func FromPrivateKey(sk ed25519.PrivateKey) (string, error) { 12 | seed := sk.Seed() 13 | return FromKey(seed) 14 | } 15 | 16 | // ToPrivateKey is a helper that converts a mnemonic directly to an ed25519 17 | // private key 18 | func ToPrivateKey(mnemonic string) (sk ed25519.PrivateKey, err error) { 19 | seedBytes, err := ToKey(mnemonic) 20 | if err != nil { 21 | return 22 | } 23 | return ed25519.NewKeyFromSeed(seedBytes), nil 24 | } 25 | 26 | // FromMasterDerivationKey is a helper that converts an MDK to a human-readable 27 | // mnemonic 28 | func FromMasterDerivationKey(mdk types.MasterDerivationKey) (string, error) { 29 | return FromKey(mdk[:]) 30 | } 31 | 32 | // ToMasterDerivationKey is a helper that converts a mnemonic directly to a 33 | // master derivation key 34 | func ToMasterDerivationKey(mnemonic string) (mdk types.MasterDerivationKey, err error) { 35 | mdkBytes, err := ToKey(mnemonic) 36 | if err != nil { 37 | return 38 | } 39 | if len(mdkBytes) != len(mdk) { 40 | panic("recovered mdk is wrong length") 41 | } 42 | copy(mdk[:], mdkBytes) 43 | return 44 | } 45 | -------------------------------------------------------------------------------- /test/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_IMAGE=golang:1.25.3 2 | FROM $GO_IMAGE 3 | 4 | # Copy SDK code into the container 5 | RUN mkdir -p /app/go-algorand-sdk 6 | COPY . /app/go-algorand-sdk 7 | WORKDIR /app/go-algorand-sdk 8 | 9 | # Run integration tests 10 | CMD ["/bin/bash", "-c", "make unit && make integration && make smoke-test-examples"] 11 | -------------------------------------------------------------------------------- /test/integration.tags: -------------------------------------------------------------------------------- 1 | @abi 2 | @algod 3 | @applications.boxes 4 | @applications.verified 5 | @assets 6 | @auction 7 | @c2c 8 | @compile 9 | @compile.disassemble 10 | @compile.sourcemap 11 | @dryrun 12 | @kmd 13 | @rekey_v1 14 | @send 15 | @send.keyregtxn 16 | @simulate 17 | -------------------------------------------------------------------------------- /test/unit.tags: -------------------------------------------------------------------------------- 1 | @unit.abijson 2 | @unit.abijson.byname 3 | @unit.algod 4 | @unit.algod.ledger_refactoring 5 | @unit.algod.heartbeat 6 | @unit.algod.heartbeat.msgp 7 | @unit.applications 8 | @unit.applications.boxes 9 | @unit.atomic_transaction_composer 10 | @unit.blocksummary 11 | @unit.blocktxids 12 | @unit.dryrun 13 | @unit.dryrun.trace.application 14 | @unit.feetest 15 | @unit.indexer 16 | @unit.indexer.blockheaders 17 | @unit.indexer.ledger_refactoring 18 | @unit.indexer.logs 19 | @unit.indexer.rekey 20 | @unit.indexer.heartbeat 21 | @unit.offline 22 | @unit.program_sanity_check 23 | @unit.ready 24 | @unit.rekey 25 | @unit.responses 26 | @unit.responses.231 27 | @unit.responses.blocksummary 28 | @unit.responses.genesis 29 | @unit.responses.messagepack 30 | @unit.responses.messagepack.231 31 | @unit.responses.minbalance 32 | @unit.responses.participationupdates 33 | @unit.responses.sync 34 | @unit.responses.timestamp 35 | @unit.responses.txid.json 36 | @unit.responses.unlimited_assets 37 | @unit.sourcemap 38 | @unit.statedelta 39 | @unit.stateproof.paths 40 | @unit.stateproof.responses 41 | @unit.sync 42 | @unit.tealsign 43 | @unit.responses.timestamp 44 | @unit.transactions 45 | @unit.transactions.keyreg 46 | @unit.transactions.payment 47 | @unit.txngroupdeltas 48 | -------------------------------------------------------------------------------- /transaction/waitForConfirmation.go: -------------------------------------------------------------------------------- 1 | package transaction 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/algorand/go-algorand-sdk/v2/client/v2/algod" 8 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common" 9 | "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" 10 | ) 11 | 12 | // WaitForConfirmation waits for a pending transaction to be accepted by the network 13 | // txid: The ID of the pending transaction to wait for 14 | // waitRounds: The number of rounds to block before exiting with an error. 15 | func WaitForConfirmation(c *algod.Client, txid string, waitRounds uint64, ctx context.Context, headers ...*common.Header) (txInfo models.PendingTransactionInfoResponse, err error) { //nolint:revive // Ignore Context order for backwards compatibility 16 | response, err := c.Status().Do(ctx, headers...) 17 | if err != nil { 18 | return 19 | } 20 | 21 | lastRound := response.LastRound 22 | currentRound := lastRound + 1 23 | 24 | for { 25 | // Check that the `waitRounds` has not passed 26 | if currentRound > lastRound+waitRounds { 27 | err = fmt.Errorf("wait for transaction id %s timed out", txid) 28 | return 29 | } 30 | 31 | txInfo, _, err = c.PendingTransactionInformation(txid).Do(ctx, headers...) 32 | if err == nil { 33 | if len(txInfo.PoolError) != 0 { 34 | // The transaction has been rejected 35 | err = fmt.Errorf("transaction rejected: %s", txInfo.PoolError) 36 | return 37 | } 38 | 39 | if txInfo.ConfirmedRound > 0 { 40 | // The transaction has been confirmed 41 | return 42 | } 43 | } 44 | // Note that we intentionally ignore errors from PendingTransactionInformation, since it 45 | // may return 404 if the algod instance is behind a load balancer and the request goes 46 | // to a different algod than the one we submitted the transaction to 47 | 48 | // Wait until the block for the `currentRound` is confirmed 49 | response, err = c.StatusAfterBlock(currentRound).Do(ctx, headers...) 50 | if err != nil { 51 | return 52 | } 53 | 54 | // Increment the `currentRound` 55 | currentRound++ 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /types/auction.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Bid represents a bid by a user as part of an auction. 4 | type Bid struct { 5 | _struct struct{} `codec:",omitempty,omitemptyarray"` 6 | 7 | // BidderKey identifies the bidder placing this bid. 8 | BidderKey Address `codec:"bidder"` 9 | 10 | // BidCurrency specifies how much external currency the bidder 11 | // is putting in with this bid. 12 | BidCurrency uint64 `codec:"cur"` 13 | 14 | // MaxPrice specifies the maximum price, in units of external 15 | // currency per Algo, that the bidder is willing to pay. 16 | // This must be at least as high as the current price of the 17 | // auction in the block in which this bid appears. 18 | MaxPrice uint64 `codec:"price"` 19 | 20 | // BidID identifies this bid. The first bid by a bidder (identified 21 | // by BidderKey) with a particular BidID on the blockchain will be 22 | // considered, preventing replay of bids. Specifying a different 23 | // BidID allows the bidder to place multiple bids in an auction. 24 | BidID uint64 `codec:"id"` 25 | 26 | // AuctionKey specifies the auction for this bid. 27 | AuctionKey Address `codec:"auc"` 28 | 29 | // AuctionID identifies the auction for which this bid is intended. 30 | AuctionID uint64 `codec:"aid"` 31 | } 32 | 33 | // SignedBid represents a signed bid by a bidder. 34 | type SignedBid struct { 35 | _struct struct{} `codec:",omitempty,omitemptyarray"` 36 | 37 | // Bid contains information about the bid. 38 | Bid Bid `codec:"bid"` 39 | 40 | // Sig is a signature by the bidder, as identified in the bid 41 | // (Bid.BidderKey) over the hash of the Bid. 42 | Sig Signature `codec:"sig"` 43 | } 44 | 45 | // NoteFieldType indicates a type of auction message encoded into a 46 | // transaction's Note field. 47 | type NoteFieldType string 48 | 49 | const ( 50 | // NoteDeposit indicates a SignedDeposit message. 51 | NoteDeposit NoteFieldType = "d" 52 | 53 | // NoteBid indicates a SignedBid message. 54 | NoteBid NoteFieldType = "b" 55 | 56 | // NoteSettlement indicates a SignedSettlement message. 57 | NoteSettlement NoteFieldType = "s" 58 | 59 | // NoteParams indicates a SignedParams message. 60 | NoteParams NoteFieldType = "p" 61 | ) 62 | 63 | // NoteField is the struct that represents an auction message. 64 | type NoteField struct { 65 | _struct struct{} `codec:",omitempty,omitemptyarray"` 66 | 67 | // Type indicates which type of a message this is 68 | Type NoteFieldType `codec:"t"` 69 | 70 | // SignedBid, for NoteBid type 71 | SignedBid SignedBid `codec:"b"` 72 | } 73 | -------------------------------------------------------------------------------- /types/basics_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "encoding/base64" 7 | "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" 8 | 9 | "github.com/stretchr/testify/require" 10 | ) 11 | 12 | func TestSignedTxnFromBase64String(t *testing.T) { 13 | note := []byte("Testing SignedTxnFromBase64String()") 14 | 15 | // Create a signed transaction with a note and base64 encode it. 16 | var st SignedTxn 17 | st.Txn.Note = note 18 | b64data := base64.StdEncoding.EncodeToString([]byte(string(msgpack.Encode(st)))) 19 | 20 | // Verify that FromBase64String() decodes the txn. 21 | var vst SignedTxn 22 | err := vst.FromBase64String(b64data) 23 | require.NoError(t, err) 24 | require.Equal(t, vst.Txn.Note, note) 25 | } 26 | 27 | func TestBlockFromBase64String(t *testing.T) { 28 | protocol := "Testing BlockFromBase64String()" 29 | 30 | // Create a block with a protocol string and base64 encode it. 31 | var bl Block 32 | bl.CurrentProtocol = protocol 33 | b64data := base64.StdEncoding.EncodeToString([]byte(string(msgpack.Encode(bl)))) 34 | 35 | // Verify that FromBase64String() decodes the txn. 36 | var vbl Block 37 | err := vbl.FromBase64String(b64data) 38 | require.NoError(t, err) 39 | require.Equal(t, vbl.CurrentProtocol, protocol) 40 | } 41 | -------------------------------------------------------------------------------- /types/blockhash.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/base64" 5 | "strings" 6 | ) 7 | 8 | // MarshalText returns the BlockHash string as an array of bytes 9 | func (b *BlockHash) MarshalText() ([]byte, error) { 10 | result := base64.StdEncoding.EncodeToString(b[:]) 11 | return []byte(result), nil 12 | } 13 | 14 | // UnmarshalText initializes the BlockHash from an array of bytes. 15 | func (b *BlockHash) UnmarshalText(text []byte) error { 16 | // Remove the blk- prefix if it is present to allow decoding either format. 17 | if strings.HasPrefix(string(text), "blk-") { 18 | text = text[4:] 19 | } 20 | 21 | // Attempt to decode base32 format 22 | d, err := DigestFromString(string(text)) 23 | if err == nil { 24 | *b = BlockHash(d) 25 | return nil 26 | } 27 | 28 | // ignore the DigestFromString error because it isn't the native MarshalText format. 29 | 30 | // Attempt to decode base64 format 31 | data, err := base64.StdEncoding.DecodeString(string(text)) 32 | if err == nil { 33 | if len(data) != len(b[:]) { 34 | return errWrongBlockHashLen 35 | } 36 | copy(b[:], data[:]) 37 | return nil 38 | } 39 | return err 40 | } 41 | -------------------------------------------------------------------------------- /types/blockhash_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | json2 "github.com/algorand/go-algorand-sdk/v2/encoding/json" 10 | ) 11 | 12 | func TestUnmarshalBlockHash(t *testing.T) { 13 | testcases := []struct { 14 | name string 15 | input string 16 | outputB64 string 17 | err string 18 | }{ 19 | { 20 | name: "blk-B32", 21 | input: "blk-PEMLJXJYPLIFJ7DGVGTSEGUHUFR3M6Y67UZW3AC4LLNLF26XIXQA", 22 | outputB64: "eRi03Th60FT8ZqmnIhqHoWO2ex79M22AXFrasuvXReA=", 23 | }, { 24 | name: "B32", 25 | input: "PEMLJXJYPLIFJ7DGVGTSEGUHUFR3M6Y67UZW3AC4LLNLF26XIXQA", 26 | outputB64: "eRi03Th60FT8ZqmnIhqHoWO2ex79M22AXFrasuvXReA=", 27 | }, { 28 | name: "B64", 29 | input: "eRi03Th60FT8ZqmnIhqHoWO2ex79M22AXFrasuvXReA=", 30 | outputB64: "eRi03Th60FT8ZqmnIhqHoWO2ex79M22AXFrasuvXReA=", 31 | }, { 32 | name: "B64-err-length", 33 | input: "AAE=", 34 | err: "decoded block hash is the wrong length", 35 | }, { 36 | name: "B64-err-illegal", 37 | input: "bogus", 38 | err: "illegal base64 data at input byte 4", 39 | }, { 40 | name: "Overflow does not panic", 41 | input: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ", 42 | err: "illegal base64 data at input byte 56", 43 | }, 44 | } 45 | 46 | for _, tc := range testcases { 47 | t.Run(tc.name, func(t *testing.T) { 48 | t.Parallel() 49 | // wrap in quotes so that it is valid JSON 50 | data := []byte(fmt.Sprintf("\"%s\"", tc.input)) 51 | 52 | var hash BlockHash 53 | err := json2.Decode(data, &hash) 54 | if tc.err != "" { 55 | require.Error(t, err) 56 | require.ErrorContains(t, err, tc.err) 57 | return 58 | } 59 | require.NoError(t, err) 60 | actual, err := hash.MarshalText() 61 | require.NoError(t, err) 62 | require.Equal(t, tc.outputB64, string(actual)) 63 | }) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /types/errors.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var errWrongAddressByteLen = fmt.Errorf("encoding address is the wrong length, should be %d bytes", hashLenBytes) 8 | var errWrongAddressLen = fmt.Errorf("decoded address is the wrong length, should be %d bytes", hashLenBytes+checksumLenBytes) 9 | var errWrongChecksum = fmt.Errorf("address checksum is incorrect, did you copy the address correctly?") 10 | var errWrongBlockHashLen = fmt.Errorf("decoded block hash is the wrong length, should be %d bytes", Sha512_256Size) 11 | -------------------------------------------------------------------------------- /types/heartbeat.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // HeartbeatTxnFields captures the fields used for an account to prove it is 4 | // online (really, it proves that an entity with the account's part keys is able 5 | // to submit transactions, so it should be able to propose/vote.) 6 | type HeartbeatTxnFields struct { 7 | _struct struct{} `codec:",omitempty,omitemptyarray"` 8 | 9 | // HeartbeatAddress is the account this txn is proving onlineness for. 10 | HbAddress Address `codec:"a"` 11 | 12 | // HbProof is a signature using HeartbeatAddress's partkey, thereby showing it is online. 13 | HbProof HeartbeatProof `codec:"prf"` 14 | 15 | // The final three fields are included to allow early, concurrent check of 16 | // the HbProof. 17 | 18 | // HbSeed must be the block seed for this transaction's firstValid 19 | // block. It is the message that must be signed with HbAddress's part key. 20 | HbSeed Seed `codec:"sd"` 21 | 22 | // HbVoteID must match the HbAddress account's current VoteID. 23 | HbVoteID OneTimeSignatureVerifier `codec:"vid"` 24 | 25 | // HbKeyDilution must match HbAddress account's current KeyDilution. 26 | HbKeyDilution uint64 `codec:"kd"` 27 | } 28 | -------------------------------------------------------------------------------- /types/lightBlockHeader.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // A Seed contains cryptographic entropy which can be used to determine a 4 | // committee. 5 | type Seed [32]byte 6 | 7 | // LightBlockHeader represents a minimal block header. It contains all the necessary fields 8 | // for verifying proofs on transactions. 9 | // In addition, this struct is designed to be used on environments where only SHA256 function exists 10 | type LightBlockHeader struct { 11 | _struct struct{} `codec:",omitempty,omitemptyarray"` 12 | 13 | Seed Seed `codec:"0"` 14 | BlockHash Digest `codec:"1"` 15 | RoundNumber Round `codec:"r"` 16 | GenesisHash Digest `codec:"gh"` 17 | Sha256TxnCommitment Digest `codec:"tc,allocbound=Sha256Size"` 18 | } 19 | -------------------------------------------------------------------------------- /types/overflow.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Overflow provides a set of helper function to prevent overflows 4 | 5 | // OAdd16 adds 2 uint16 values with overflow detection 6 | func OAdd16(a uint16, b uint16) (res uint16, overflowed bool) { 7 | res = a + b 8 | overflowed = res < a 9 | return 10 | } 11 | 12 | // OAdd adds 2 values with overflow detection 13 | func OAdd(a uint64, b uint64) (res uint64, overflowed bool) { 14 | res = a + b 15 | overflowed = res < a 16 | return 17 | } 18 | 19 | // OSub subtracts b from a with overflow detection 20 | func OSub(a uint64, b uint64) (res uint64, overflowed bool) { 21 | res = a - b 22 | overflowed = res > a 23 | return 24 | } 25 | 26 | // OMul multiplies 2 values with overflow detection 27 | func OMul(a uint64, b uint64) (res uint64, overflowed bool) { 28 | if b == 0 { 29 | return 0, false 30 | } 31 | 32 | c := a * b 33 | if c/b != a { 34 | return 0, true 35 | } 36 | return c, false 37 | } 38 | --------------------------------------------------------------------------------