Documentation
¶
Overview ¶
package algosdkwrapper provides utility functions to interact with an Algorand local network wrapping the go-algorand-sdk.
Index ¶
- func AddDummyTrasactions(atc *transaction.AtomicTransactionComposer, numberOfTxnToAdd int) error
- func BuildMethodCallParams(appId uint64, schema *Arc32Schema, methodName string, oc types.OnCompletion, ...) (*transaction.AddMethodCallParams, error)
- func CompileTealFromFile(tealFile string) ([]byte, error)
- func DeleteApp(appId uint64) error
- func DeployApp(approvalTeal []byte, clearTeal []byte) (uint64, error)
- func DeployArc4AppIfNeeded(appName string, dir string) (appId uint64, err error)
- func EnsureFunded(address string, min uint64)
- func ExecuteAbiCall(appId uint64, schema *Arc32Schema, methodName string, oc types.OnCompletion, ...) (*transaction.ABIMethodResult, error)
- func ExecuteGroup(atc *transaction.AtomicTransactionComposer, simulate bool) (*transaction.ExecuteResult, error)
- func GetAlgodClient() *algod.Client
- func GetAppByName(appName string, creatorAddress string) (*models.Application, error)
- func GetDefaultAccount() (account *crypto.Account, err error)
- func GetIndexerClient() *indexer.Client
- func GetKmdClient() kmd.Client
- func GetSandboxAccounts() ([]crypto.Account, error)
- func LogicSigFromFile(filename string) (*crypto.LogicSigAccount, error)
- func SendTxn(txn types.Transaction, account *crypto.Account) (*models.PendingTransactionInfoResponse, error)
- func SetDevNet(dir string)
- type Arc32Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDummyTrasactions ¶ added in v0.1.6
func AddDummyTrasactions(atc *transaction.AtomicTransactionComposer, numberOfTxnToAdd int) error
AddDummyTrasactions adds numberOfTxnToAdd dummy transactions to atc. The last transaction will have a fee of 1 algo to cover the fee for the group. A local network must be running with default parameters
func BuildMethodCallParams ¶ added in v0.1.6
func BuildMethodCallParams( appId uint64, schema *Arc32Schema, methodName string, oc types.OnCompletion, methodArgs []interface{}, boxes []types.AppBoxReference, signer transaction.TransactionSigner, ) (*transaction.AddMethodCallParams, error)
BuildMethodCallParams builds the parameters to add a method call to an atomic transaction composer.
func CompileTealFromFile ¶
CompileTealFromFile reads a teal file and returns a compiled b64 binary. A local network must be running
func DeleteApp ¶ added in v0.1.6
DeleteApp deletes an application by its id A local network must be running with default parameters
func DeployApp ¶ added in v0.1.6
DeployApp deploys a smart contract application and returns its id A local network must be running with default parameters
func DeployArc4AppIfNeeded ¶
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. To look for the app, it uses the func `GetAppByName` which looks for a global state field `app_name' with value appName.
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 ¶
EnsureFunded checks if the given address has at least min 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, schema *Arc32Schema, methodName string, oc types.OnCompletion, methodArgs []interface{}, boxes []types.AppBoxReference, signer transaction.TransactionSigner, simulate bool, ) (*transaction.ABIMethodResult, error)
ExecuteAbiCall calls an abi method on an app and returns the result. If signer is nil, it uses the default localnet account for both. A local network must be running
func ExecuteGroup ¶ added in v0.1.6
func ExecuteGroup(atc *transaction.AtomicTransactionComposer, simulate bool, ) (*transaction.ExecuteResult, error)
ExecuteGroup executes a transaction group composed by atc. If simulate is true, it simulates the group instead of sending it. A local network must be running with default parameters
func GetAlgodClient ¶
func GetAppByName ¶
func GetAppByName(appName string, creatorAddress string) ( *models.Application, error)
GetAppByName returns the the first app it finds that is created by creatorAddress and has a global storage field `app_name' with value appName. If the app is not found, it returns nil. A local network must be running
func GetDefaultAccount ¶
GetDefaultAccount returns the default account for the local network A local network must be running
func GetIndexerClient ¶
func GetKmdClient ¶
func GetSandboxAccounts ¶
func LogicSigFromFile ¶ added in v0.1.6
func LogicSigFromFile(filename string) (*crypto.LogicSigAccount, error)
LogicSigFromFile returns a logicsig account from a teal file A local network must be running with default parameters
func SendTxn ¶
func SendTxn(txn types.Transaction, account *crypto.Account) ( *models.PendingTransactionInfoResponse, error)
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