### Start Catchup - Python Example Source: https://context7_llms Example of how to start a catchup using the requests library in Python. ```python import requests headers = { 'Accept': 'application/json', 'X-Algo-API-Token': 'API_KEY' } r = requests.post('http://localhost/v2/catchup/{catchpoint}', headers = headers) print(r.json()) ``` -------------------------------- ### Start Catchup - HTTP Example Source: https://context7_llms Example of an HTTP POST request to start a catchup. ```http POST http://localhost/v2/catchup/{catchpoint} HTTP/1.1 Host: localhost Accept: application/json ``` -------------------------------- ### Start Catchup - Shell Example Source: https://context7_llms Example of how to start a catchup using curl in a shell environment. ```shell curl -X POST http://localhost/v2/catchup/{catchpoint} \ -H 'Accept: application/json' \ -H 'X-Algo-API-Token: API_KEY' ``` -------------------------------- ### Start Catchup - Java Example Source: https://context7_llms Example of starting a catchup using HttpURLConnection in Java. ```java URL obj = new URL("http://localhost/v2/catchup/{catchpoint}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` -------------------------------- ### Start Catchup - Go Example Source: https://context7_llms Example of initiating a catchup using the net/http package in Go. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://localhost/v2/catchup/{catchpoint}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Start Catchup - Ruby Example Source: https://context7_llms Example of initiating a catchup using the rest-client gem in Ruby. ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'X-Algo-API-Token' => 'API_KEY' } result = RestClient.post 'http://localhost/v2/catchup/{catchpoint}', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Start Catchup - JavaScript Example Source: https://context7_llms Example of how to initiate a catchup using the fetch API in JavaScript. ```javascript const headers = { 'Accept':'application/json', 'X-Algo-API-Token':'API_KEY' }; fetch('http://localhost/v2/catchup/{catchpoint}', { method: 'POST', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Start Catchup - PHP Example Source: https://context7_llms Example of initiating a catchup using Guzzle HTTP client in PHP. ```php 'application/json', 'X-Algo-API-Token' => 'API_KEY', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('POST','http://localhost/v2/catchup/{catchpoint}', array( 'headers' => $headers, 'json' => $request_body, )); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` -------------------------------- ### Algorand Subscriber Quick Start Source: https://context7_llms Demonstrates the basic setup for creating an AlgorandSubscriber, defining filters, setting up event listeners for transactions, handling errors, and starting or polling the subscriber. ```typescript const subscriber = new AlgorandSubscriber( { filters: [ { name: 'filter1', filter: { type: TransactionType.pay, sender: 'ABC...', }, }, ], /* ... other options (use intellisense to explore) */ }, algod, optionalIndexer, ); // Set up subscription(s) subscriber.on('filter1', async transaction => { // ... }); //... // Set up error handling subscriber.onError(e => { // ... }); // Either: Start the subscriber (if in long-running process) subscriber.start(); // OR: Poll the subscriber (if in cron job / periodic lambda) subscriber.pollOnce(); ``` -------------------------------- ### Bootstrap Algorand Node Source: https://context7_llms Initializes a new Algorand node by installing the daemon, starting the node, and performing a Fast-Catchup. This command simplifies the process of getting a fresh node running. ```bash nodekit bootstrap [flags] # Options: # -h, --help help for bootstrap ``` -------------------------------- ### Search Applications - Go Example Source: https://context7_llms Go language example for making a GET request to the Algorand API to search for applications. It shows how to set headers and use http.Client. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://example.com/v2/applications", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Lookup Asset Balances - HTTP Example Source: https://context7_llms Basic HTTP request example for fetching asset balances, showing the GET method and required headers. ```http GET https://example.com/v2/assets/{asset-id}/balances HTTP/1.1 Host: example.com Accept: application/json ``` -------------------------------- ### Start Algorand Node on New Network (Unmanaged Install) Source: https://context7_llms Starts the Algorand node using the newly created data directory, connecting it to the specified network. This command initiates the sync process for the new network. ```shell ./goal node start -d ~/node/data_testnet ``` -------------------------------- ### Get Account Information - Go Example Source: https://context7_llms Example of retrieving Algorand account information using Go's net/http package. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://localhost/v2/accounts/{address}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Transaction Proof (Go) Source: https://context7_llms Go language example for fetching a transaction proof. It sets up HTTP headers and makes a GET request to the Algorand API. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://localhost/v2/blocks/{round}/transactions/{txid}/proof", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Account Application Info (Go) Source: https://context7_llms A Go example for retrieving account application details via an HTTP GET request. It shows how to set headers and make the request using the standard http client. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://localhost/v2/accounts/{address}/applications/{application-id}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Pending Transactions - Go Example Source: https://context7_llms Shows a Go example for fetching pending transactions using the net/http package, demonstrating how to set request headers and execute the request. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://localhost/v2/transactions/pending", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Create Wallet - Go Example Source: https://context7_llms Example of creating a wallet using Go's net/http package. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "X-KMD-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://localhost/v1/wallet", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Basic App Create Example Source: https://context7_llms Shows a basic example of creating a new application using the app_create method. ```python result = algorand.send.app_create( AppCreateParams( sender="CREATORADDRESS", approval_program="TEALCODE", clear_state_program="TEALCODE", ) ) ``` -------------------------------- ### Complete Typed Client Example: Deploy and Call Source: https://context7_llms A comprehensive example showcasing the usage of a typed application client. It includes setting up the Algorand client, deploying a contract idempotently, and calling a 'hello' method. ```python # Typed: Complete example using a typed application client import algokit_utils from artifacts.hello_world.hello_world_client import ( HelloArgs, # Generated args class HelloWorldFactory, # Generated factory class ) # Get Algorand client from environment variables algorand = algokit_utils.AlgorandClient.from_environment() deployer = algorand.account.from_environment("DEPLOYER") # Create the typed app factory typed_factory = algorand.client.get_typed_app_factory( HelloWorldFactory, default_sender=deployer.address ) # Deploy idempotently - creates if it doesn't exist or updates if changed typed_client, result = typed_factory.deploy( on ``` -------------------------------- ### Start LocalNet with Custom Configuration Directory Source: https://context7_llms Demonstrates how to start an AlgoKit LocalNet instance using a custom configuration directory. This is useful for managing multiple LocalNet setups or integrating with CI/CD pipelines. ```plaintext algokit localnet start --config-dir /path/to/custom/config ``` -------------------------------- ### Bootstrap Option: All Dependencies and Setup Source: https://context7_llms Explains the 'all' bootstrap command, which executes all other bootstrap sub-commands to ensure comprehensive project setup, including dependencies and environment variables. ```bash # This command would execute 'env', 'poetry' (if applicable), and 'npm' (if applicable): # algokit bootstrap all ``` -------------------------------- ### Get Account Information - HTTP Example Source: https://context7_llms Example of an HTTP GET request to retrieve Algorand account information. ```http GET http://localhost/v2/accounts/{address} HTTP/1.1 Host: localhost ``` -------------------------------- ### Get Block Hash - HTTP Example Source: https://context7_llms Example of an HTTP GET request to retrieve the block hash for a given round. Requires API key authentication. ```http GET http://localhost/v2/blocks/{round}/hash HTTP/1.1 Host: localhost Accept: application/json ``` -------------------------------- ### AlgoKit Configuration Example Source: https://context7_llms An example of the `.algokit.toml` file, showing project deployment settings, including custom commands and environment secrets for different networks. ```toml [algokit] min_version = "v{latest_version}" [project] ... # project configuration and custom commands [project.deploy] command = "poetry run python -m smart_contracts deploy" environment_secrets = [ "DEPLOYER_MNEMONIC", ] [project.deploy.localnet] environment_secrets = [] ``` -------------------------------- ### Get Pending Transactions - HTTP Example Source: https://context7_llms Provides a raw HTTP request example for retrieving pending transactions, specifying the GET method, host, and required Accept header. ```http GET http://localhost/v2/transactions/pending HTTP/1.1 Host: localhost Accept: application/json ``` -------------------------------- ### Get Application Creator with algopy Source: https://context7_llms Illustrates fetching the creator address of an application using `algopy.op.AppParamsGet.app_creator`. It takes an `algopy.Application` ID and returns the creator's address and an existence flag. The example includes context setup and assertion of the creator's address. ```python class AppParamsContract(algopy.ARC4Contract): @algopy.arc4.abimethod def get_app_creator(self, app_id: algopy.Application) -> algopy.arc4.Address: creator, exists = algopy.op.AppParamsGet.app_creator(app_id) assert exists return algopy.arc4.Address(creator) # setup context (below assumes available under 'ctx' variable) contract = AppParamsContract() app = context.any.application() creator = contract.get_app_creator(app) assert creator == context.default_sender ``` -------------------------------- ### Example CLI Commands for Client Generation Source: https://context7_llms Command-line examples for generating typed clients using `algokit generate client`. ```bash # Generate a Python typed client from a single application.json algokit generate client path/to/application.json --output client.py # Generate TypeScript typed clients for multiple application.json files in a directory algokit generate client smart_contracts/artifacts --output {contract_name}.ts # Generate Python typed clients alongside their respective application.json files algokit generate client smart_contracts/artifacts --output {app_spec_path}/client.py ``` -------------------------------- ### Get Asset Total Supply with algopy Source: https://context7_llms Shows how to retrieve the total supply of an asset using `algopy.op.AssetParamsGet.asset_total`. This function requires an asset ID and returns the total supply along with an existence flag. The example demonstrates context setup and verifying the total supply. ```python from algopy import op class AssetParamsContract(algopy.ARC4Contract): @algopy.arc4.abimethod def get_asset_total(self, asset_id: algopy.UInt64) -> algopy.UInt64: total, exists = op.AssetParamsGet.asset_total(asset_id) assert exists return total # setup context (below assumes available under 'ctx' variable) asset = context.any.asset(total=algopy.UInt64(1000000), decimals=algopy.UInt64(6)) contract = AssetParamsContract() total = contract.get_asset_total(asset.id) assert total == algopy.UInt64(1000000) ``` -------------------------------- ### Get Metrics - HTTP Example Source: https://context7_llms Example HTTP request for retrieving metrics. ```http GET http://localhost/metrics HTTP/1.1 Host: localhost ``` -------------------------------- ### Get Metrics - Shell Example Source: https://context7_llms Example of how to retrieve metrics using curl. ```shell curl -X GET http://localhost/metrics \ -H 'X-Algo-API-Token: API_KEY' ``` -------------------------------- ### Reference Implementation Example Source: https://context7_llms A JavaScript example demonstrating how a DApp can use the Algorand wallet API to enable a wallet, query transaction parameters, create transactions, and sign/post them. ```js async function main(wallet) { // Account discovery const enabled = await wallet.enable({ genesisID: 'testnet-v1.0' }); const from = enabled.accounts[0]; // Querying const algodv2 = new algosdk.Algodv2(await wallet.getAlgodv2Client()); const suggestedParams = await algodv2.getTransactionParams().do(); const txns = makeTxns(from, suggestedParams); // Sign and post const res = await wallet.signAndPostTxns(txns); console.log(res); } ``` -------------------------------- ### Example Python Smart Contract Initialization Source: https://context7_llms Demonstrates initializing a Python-based Algorand smart contract project. It includes setting up the project structure and dependencies. ```python # Example of a Python project initialization (conceptual) # This would typically be handled by the algokit init command # Assume a template structure is cloned and dependencies are managed by poetry # smart_contracts/helloworld.py # from algosdk.v2client import algod # from algosdk.future.transaction import ApplicationCreateTxn # def create_hello_world_app(client: algod.AlgodClient): # # ... application creation logic ... # pass # main execution flow after init and bootstrap # if __name__ == "__main__": # algod_address = "http://localhost:5000" # algod_token = "your_algod_token" # algod_client = algod.AlgodClient(algod_address, algod_token) # create_hello_world_app(algod_client) ``` -------------------------------- ### Start Algorand Node Daemon Source: https://context7_llms Starts the Algorand daemon on the local machine. It can also forcefully start the daemon if it's already running. The daemon must be installed prior to starting. ```plaintext nodekit start [flags] ``` -------------------------------- ### Get Metrics - Ruby Example Source: https://context7_llms Example of how to retrieve metrics using Ruby's rest-client. ```ruby require 'rest-client' require 'json' headers = { 'X-Algo-API-Token' => 'API_KEY' } result = RestClient.get 'http://localhost/metrics', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Get API Versions - HTTP Example Source: https://context7_llms Example HTTP request for retrieving API versions. ```http GET http://localhost/versions HTTP/1.1 Host: localhost ``` -------------------------------- ### Get API Versions - Shell Example Source: https://context7_llms Example of how to retrieve API versions using curl. ```shell curl -X GET http://localhost/versions \ -H 'X-Algo-API-Token: API_KEY' ``` -------------------------------- ### Create Application with Parameters Source: https://context7_llms Demonstrates creating an Algorand application using the AppClient, with options for bare calls and ABI method calls. Includes specifying arguments, static fees, on-complete actions, and compilation parameters for deploy-time replacements and immutability. ```python app_client = factory.send.bare.create() result, app_client = factory.send.bare.create( params=AppClientBareCallParams( args=[bytes([1, 2, 3, 4])], static_fee=AlgoAmount.from_microalgos(3000), on_complete=OnComplete.OptIn, ), compilation_params={ "deploy_time_params": { "ONE": 1, "TWO": "two", }, "updatable": True, "deletable": False, } ) result, app_client = factory.send.create( AppClientMethodCallParams( method="create_application", args=[1, "something"] ) ) ``` -------------------------------- ### Standalone Project Configuration Example (Frontend) Source: https://context7_llms Presents a TOML configuration for a standalone project of type 'frontend', also defining a custom 'hello' command. ```toml # ... other non [project.run] related metadata [project] type = 'frontend' name = 'project_b' [project.run] hello = { commands = ['echo hello'], description = 'Prints hello' } # ... other non [project.run] related metadata ``` -------------------------------- ### Create Wallet - Ruby Example Source: https://context7_llms Example of creating a wallet using Ruby's rest-client. ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-KMD-API-Token' => 'API_KEY' } result = RestClient.post 'http://localhost/v1/wallet', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Fetch Algorand Asset Information (Go) Source: https://context7_llms Provides a Go example for fetching Algorand asset data. This snippet shows how to set up the HTTP request, including headers and data, and execute it using Go's standard http client. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://example.com/v2/assets/{asset-id}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Lookup Block - HTTP Example Source: https://context7_llms Example of how to lookup block information using an HTTP GET request. ```http GET https://example.com/v2/blocks/{round-number} HTTP/1.1 Host: example.com Accept: application/json ``` -------------------------------- ### Get Metrics - Python Example Source: https://context7_llms Example of how to retrieve metrics using Python's requests library. ```python import requests headers = { 'X-Algo-API-Token': 'API_KEY' } r = requests.get('http://localhost/metrics', headers = headers) print(r.json()) ``` -------------------------------- ### Get Metrics - JavaScript Example Source: https://context7_llms Example of how to retrieve metrics using JavaScript's fetch API. ```javascript const headers = { 'X-Algo-API-Token':'API_KEY' }; fetch('http://localhost/metrics', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }) .then(function(body) { console.log(body); }); ``` -------------------------------- ### Get Account Information - PHP Example Source: https://context7_llms Example of retrieving Algorand account information using PHP. ```php { ctx.reset(); }); test('increment', () => { // Instantiate contract // ... rest of the test logic for BaseContract ... ``` -------------------------------- ### Deploying a Smart Contract Source: https://context7_llms Demonstrates how to deploy a smart contract using the client, specifying creation and update parameters, and enabling update and delete functionalities. It also shows how to set on-completion actions. ```typescript client.deploy({ createParams: { onComplete: OnApplicationComplete.OptIn, }, updateParams: { method: 'named_update(uint64,string)string', args: { arg1: 123, arg2: 'foo', }, }, // Can leave this out and it will do an argumentless bare call (if that call is allowed) //deleteParams: {} allowUpdate: true, allowDelete: true, onUpdate: 'update', onSchemaBreak: 'replace', }); ``` -------------------------------- ### Get Metrics - PHP Example Source: https://context7_llms Example of how to retrieve metrics using PHP's Guzzle HTTP client. ```php 'API_KEY', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://localhost/metrics', array( 'headers' => $headers, 'json' => $request_body, )); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` -------------------------------- ### Create Wallet - Python Example Source: https://context7_llms Example of creating a wallet using Python's requests library. ```python import requests headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-KMD-API-Token': 'API_KEY' } r = requests.post('http://localhost/v1/wallet', headers = headers) print(r.json()) ``` -------------------------------- ### Get API Versions - Java Example Source: https://context7_llms Example of how to retrieve API versions using Java's HttpURLConnection. ```java URL obj = new URL("http://localhost/versions"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` -------------------------------- ### Create Wallet - JavaScript Example Source: https://context7_llms Example of creating a wallet using JavaScript's fetch API. ```javascript const inputBody = '{ "master_derivation_key": [ 0 ], "wallet_driver_name": "string", "wallet_name": "string", "wallet_password": "string" }'; const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'X-KMD-API-Token':'API_KEY' }; fetch('http://localhost/v1/wallet', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }) .then(function(body) { console.log(body); }); ``` -------------------------------- ### Get API Versions - Ruby Example Source: https://context7_llms Example of how to retrieve API versions using Ruby's rest-client. ```ruby require 'rest-client' require 'json' headers = { 'X-Algo-API-Token' => 'API_KEY' } result = RestClient.get 'http://localhost/versions', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Import Multisig Account - Go Example Source: https://context7_llms Go example using net/http to import a multisig account. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "X-KMD-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://localhost/v1/multisig/import", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get API Versions - Go Example Source: https://context7_llms Example of how to retrieve API versions using Go's net/http package. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://localhost/versions", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... ``` -------------------------------- ### Get API Versions - Python Example Source: https://context7_llms Example of how to retrieve API versions using Python's requests library. ```python import requests headers = { 'X-Algo-API-Token': 'API_KEY' } r = requests.get('http://localhost/versions', headers = headers) print(r.json()) ``` -------------------------------- ### Installation Source: https://context7_llms Instructions for installing the algokit-utils library using pip or poetry. ```bash pip install algokit-utils # or poetry add algokit-utils ``` -------------------------------- ### Algorand Subscriber Quick Start Source: https://context7_llms Demonstrates how to initialize and use the AlgorandSubscriber to subscribe to transactions on the Algorand testnet. Includes setting up filters, watermark persistence, sync behavior, and handling notifications and errors. ```python from algokit_subscriber import AlgorandSubscriber from algosdk.v2client import algod from algokit_utils import get_algod_client, get_algonode_config # Create an Algod client algod_client = get_algod_client(get_algonode_config("testnet", "algod", "")) # testnet used for demo purposes # Create subscriber (example with filters) subscriber = AlgorandSubscriber( config={ "filters": [ { "name": "filter1", "filter": { "type": "pay", "sender": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ", }, }, ], "watermark_persistence": { "get": lambda: 0, "set": lambda x: None }, "sync_behaviour": "skip-sync-newest", "max_rounds_to_sync": 100, }, algod_client=algod_client, ) # Set up subscription(s) subscriber.on("filter1", lambda transaction, _: print(f"Received transaction: {transaction['id']}")) # Set up error handling subscriber.on_error(lambda error, _: print(f"Error occurred: {error}")) # Either: Start the subscriber (if in long-running process) # subscriber.start() # OR: Poll the subscriber (if in cron job / periodic lambda) result = subscriber.poll_once() print(f"Polled {len(result['subscribed_transactions'])} transactions") ``` -------------------------------- ### Get API Versions - JavaScript Example Source: https://context7_llms Example of how to retrieve API versions using JavaScript's fetch API. ```javascript const headers = { 'X-Algo-API-Token':'API_KEY' }; fetch('http://localhost/versions', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }) .then(function(body) { console.log(body); }); ``` -------------------------------- ### Standalone Project Configuration Example (Contract) Source: https://context7_llms Shows a TOML configuration for a standalone project of type 'contract', including a custom 'hello' command. ```toml # ... other non [project.run] related metadata [project] type = 'contract' name = 'project_a' [project.run] hello = { commands = ['echo hello'], description = 'Prints hello' } # ... other non [project.run] related metadata ``` -------------------------------- ### Get Account Information - Java Example Source: https://context7_llms Example of retrieving Algorand account information using Java's HttpURLConnection. ```java URL obj = new URL("http://localhost/v2/accounts/{address}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` -------------------------------- ### Install Algorand Python Source: https://context7_llms Instructions for installing the Algorand Python types from PyPi using pip or poetry. ```bash pip install algorand-python ``` ```bash poetry add algorand-python ``` -------------------------------- ### Get Account Information - Ruby Example Source: https://context7_llms Example of retrieving Algorand account information using Ruby's RestClient. ```ruby require 'rest-client' require 'json' headers = { 'X-Algo-API-Token' => 'API_KEY' } result = RestClient.get 'http://localhost/v2/accounts/{address}', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Get Algorand Application Box by Name (Ruby) Source: https://context7_llms Provides a Ruby example using the 'rest-client' gem to get Algorand application box details. It sets up headers and parameters for the GET request. ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'X-Algo-API-Token' => 'API_KEY' } result = RestClient.get 'http://localhost/v2/applications/{application-id}/box', params: { 'name' => 'string' }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Initialize New Algorand Project (Defaults) Source: https://context7_llms Initializes a new Algorand project with default settings using `algokit init --defaults`. This bypasses interactive prompts and uses pre-defined configurations for a starter project. ```plaintext algokit init --defaults ``` -------------------------------- ### Initialize Project with Community Template Source: https://context7_llms Demonstrates how to initialize a new Algorand project using a community template from a GitHub URL. It also shows how to specify a particular commit, branch, or tag for the template. ```shell algokit init --template-url https://github.com/algorandfoundation/algokit-python-template ``` ```shell algokit init --template-url https://github.com/algorandfoundation/algokit-python-template --template-url-ref 0232bb68a2f5628e910ee52f62bf13ded93fe672 ``` -------------------------------- ### Get API Versions - PHP Example Source: https://context7_llms Example of how to retrieve API versions using PHP's Guzzle HTTP client. ```php 'API_KEY', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://localhost/versions', array( 'headers' => $headers, 'json' => $request_body, )); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` -------------------------------- ### Search Assets using Go Source: https://context7_llms A Go language example demonstrating how to search for assets using the net/http package. It shows setting headers and making a GET request. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://example.com/v2/assets", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Create Wallet - Shell Example Source: https://context7_llms Example of creating a wallet using curl in shell. ```shell curl -X POST http://localhost/v1/wallet \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'X-KMD-API-Token: API_KEY' ``` -------------------------------- ### Get Account Information - Python Example Source: https://context7_llms Example of fetching Algorand account information using Python's requests library. ```python import requests headers = { 'X-Algo-API-Token': 'API_KEY' } r = requests.get('http://localhost/v2/accounts/{address}', headers = headers) print(r.json()) ``` -------------------------------- ### Initialize Algorand Project Source: https://context7_llms Generates a base project structure for Algorand smart contracts using AlgoKit. This command sets up all necessary files and configurations to begin development. ```bash algokit init ``` -------------------------------- ### Get Account Information - JavaScript Example Source: https://context7_llms Example of fetching Algorand account information using JavaScript's fetch API. ```javascript const headers = { 'X-Algo-API-Token':'API_KEY' }; fetch('http://localhost/v2/accounts/{address}', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Lookup Asset Balances - Curl Example Source: https://context7_llms Example using curl to make a GET request to the asset balances endpoint, specifying the Accept header. ```shell curl -X GET https://example.com/v2/assets/{asset-id}/balances \ -H 'Accept: application/json' ``` -------------------------------- ### Bootstrap Dependencies and Initialize Git Source: https://context7_llms Initializes a new project, automatically bootstraps dependencies (e.g., Python via Poetry), and initializes a Git repository with an initial commit. ```plaintext ? Do you want to run `algokit bootstrap` to bootstrap dependencies for this new project so it can be run immediately? Yes Installing Python dependencies and setting up Python virtual environment via Poetry poetry: Creating virtualenv my-smart-contract in /Users/algokit/algokit-init/my-smart-contract/.venv poetry: Updating dependencies poetry: Resolving dependencies... poetry: poetry: poetry: Writing lock file poetry: poetry: poetry: Package operations: 53 installs, 0 updates, 0 removals poetry: poetry: poetry: • Installing pycparser (2.21) ---- other output omitted for brevity ---- poetry: • Installing ruff (0.0.171) Copying /Users/algokit/algokit-init/my-smart-contract/smart_contracts/.env.template to /Users/algokit/algokit-init/my-smart-contract/smart_contracts/.env and prompting for empty values ? Would you like to initialise a git repository and perform an initial commit? Yes 🎉 Performed initial git commit successfully! 🎉 🙌 Project initialized at `my-smart-contract`! For template specific next steps, consult the documentation of your selected template 🧐 Your selected template comes from: ➡️ https://github.com/algorandfoundation/algokit-python-template As a suggestion, if you wanted to open the project in VS Code you could execute: > cd my-smart-contract && code . ``` -------------------------------- ### Basic App Call Example Source: https://context7_llms Demonstrates a basic example of calling an application using the app_call method. ```python algorand.send.app_call( AppCallParams( sender="CREATORADDRESS", app_id=123456, ) ) ``` -------------------------------- ### Get Block Hash - cURL Example Source: https://context7_llms Example of how to retrieve the block hash for a given round using cURL. Requires API key authentication. ```shell curl -X GET http://localhost/v2/blocks/{round}/hash \ -H 'Accept: application/json' \ -H 'X-Algo-API-Token: API_KEY' ``` -------------------------------- ### ARC-55 Setup and Usage Example (Conceptual) Source: https://context7_llms Illustrates the conceptual flow for setting up and using an ARC-55 compliant contract, including generating transaction group nonces and managing signatures. ```Python # Conceptual Python example for ARC-55 usage # Assume 'app_client' is an initialized Algorand client for the ARC-55 contract # 1. Admin sets up the multisignature configuration # admin_address = "" # signer_addresses = ["", ""] # threshold = 2 # app_client.arc55_setup(threshold, signer_addresses) # 2. Generate a new transaction group nonce # transaction_group_nonce = app_client.arc55_newTransactionGroup() # 3. Add transactions to the group (example: adding a transaction to be signed) # transaction_bytes = b"" # app_client.arc55_addTransactionContinued(transaction_bytes) # 4. Signers add their signatures # signer_1_signature = b"" # app_client.arc55_setSignatures(transaction_group_nonce, signer_1_signature) # 5. Admin or signers can remove transactions or clear signatures if needed # app_client.arc55_removeTransaction(transaction_group_nonce, 0) # Remove the first transaction # app_client.arc55_clearSignatures(transaction_group_nonce, "") ``` -------------------------------- ### Get Algorand Metrics Source: https://context7_llms Examples for fetching Algorand metrics using different languages. This involves making an HTTP GET request to the /metrics endpoint. ```PHP 'API_KEY', ); $request_body = array(); try { $client = new GuzzleHttpClient(); $response = $client->request('GET', 'http://localhost/metrics', array( 'headers' => $headers, 'json' => $request_body, )); print_r($response->getBody()->getContents()); } catch (GuzzleHttpExceptionBadResponseException $e) { print_r($e->getMessage()); } ?> ``` ```Java URL obj = new URL("http://localhost/metrics"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```Go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "X-Algo-API-Token": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://localhost/metrics", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Block Hash - PHP Example Source: https://context7_llms Example of how to retrieve the block hash for a given round using PHP with GuzzleHttp. Requires API key authentication. ```php 'application/json', 'X-Algo-API-Token' => 'API_KEY', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://localhost/v2/blocks/{round}/hash', array( 'headers' => $headers, 'json' => $request_body, )); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` -------------------------------- ### Lookup Block - Go Example Source: https://context7_llms Example of how to lookup block information using Go's net/http package. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://example.com/v2/blocks/{round-number}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ```