algosdkwrapper

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

package algosdkwrapper provides utility functions to interact with an Algorand local network wrapping the go-algorand-sdk.

Index

Constants

This section is empty.

Variables

View Source
var (
	ALGOD_URL   = "http://localhost:4001"
	ALGOD_TOKEN = strings.Repeat("a", 64)

	INDEXER_URL   = "http://localhost:8980"
	INDEXER_TOKEN = strings.Repeat("a", 64)

	KMD_URL   = "http://localhost:4002"
	KMD_TOKEN = strings.Repeat("a", 64)

	KMD_WALLET_NAME     = "unencrypted-default-wallet"
	KMD_WALLET_PASSWORD = ""
)

default parameters for the local network, override them if needed

Functions

func CallVerifyMethod

func CallVerifyMethod(appId uint64, account *crypto.Account, proofFilename string,
	publicInputsFilename string, schema *Arc32Schema, simulate bool) (
	*transaction.ABIMethodResult, error)

CallVerifyMethod calls a verifier app with the given proof and public inputs. If account is nil, it uses the default localnet account. If simulate is true, it simulates the call instead of sending it, adding the maximum extra opcode budget. A local network must be running

func CompileTealFromFile

func CompileTealFromFile(tealFile string) ([]byte, error)

CompileTealFromFile reads a teal file and returns a compiled b64 binary. A local network must be running

func DeployArc4AppIfNeeded

func DeployArc4AppIfNeeded(appName string, dir string) (
	appId uint64, err error)

DeployArc4AppIfNeeded lookups the appName among the apps deployed in the local network by the main account. If the app is not found, it deploys it. If found, it checks that the app is up to date with the latest compiled version and if not it deletes it and deploys the new version.

The function expects to find the files: - dir + appName + ".approval.teal" - dir + appName + ".clear.teal" - dir + appName + ".arc32.json"

A local network must be running

func EnsureFunded

func EnsureFunded(address string, min uint64)

EnsureFunded checks if the given address has at leastrminBalance microalgos and if not funds it with twice the amount from the default account. A local network must be running

func ExecuteAbiCall

func ExecuteAbiCall(appId uint64, account *crypto.Account, schema *Arc32Schema,
	methodName string, oc types.OnCompletion, methodArgs []interface{},
	boxes []types.AppBoxReference) (
	*transaction.ExecuteResult, error)

ExecuteAbiCall calls an abi method on an app. A local network must be running

func GetAlgodClient

func GetAlgodClient() *algod.Client

func GetAppByName

func GetAppByName(appName string, creatorAddress string) (
	*models.Application, error)

GetAppByName returns the app created by creatorAddress with the name appName. If the app is not found, it returns nil. A local network must be running

func GetDefaultAccount

func GetDefaultAccount() (account *crypto.Account, err error)

GetDefaultAccount returns the default account for the local network A local network must be running

func GetIndexerClient

func GetIndexerClient() *indexer.Client

func GetKmdClient

func GetKmdClient() kmd.Client

func GetSandboxAccounts

func GetSandboxAccounts() ([]crypto.Account, error)

func SendTxn

SendTxn signs and sends a transaction to the network. If no account is provided, it uses the default localnet account. A local network must be running

Types

type Arc32Schema

type Arc32Schema struct {
	Source struct {
		Approval string `json:"approval"`
		Clear    string `json:"clear"`
	} `json:"source"`
	State struct {
		Global struct {
			NumByteSlices uint64 `json:"num_byte_slices"`
			NumUints      uint64 `json:"num_uints"`
		} `json:"global"`
		Local struct {
			NumByteSlices uint64 `json:"num_byte_slices"`
			NumUints      uint64 `json:"num_uints"`
		} `json:"local"`
	} `json:"state"`
	Contract abi.Contract `json:"contract"`
}

Arc32Schema defines a partial ARC32 schema

func ReadArc32Schema

func ReadArc32Schema(filepath string) (
	schema *Arc32Schema, err error)

ReadArc32Schema reads an ARC32 schema from a JSON file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL