Optional
config: AlgonautConfigconfig object
Usage:
import { Algonaut } from '@thencc/algonautjs';
const algonaut = new Algonaut({
nodeConfig: {
BASE_SERVER: 'https://testnet-algorand.api.purestake.io/ps2',
INDEX_SERVER: 'https://testnet-algorand.api.purestake.io/idx2'
LEDGER: 'TestNet',
PORT: '',
API_TOKEN: { 'X-API-Key': 'YOUR_API_TOKEN' }
}
});
connects the given wallet + optional init params
Optional
wInitParams: Pan array of connected accounts
walletId of which wallet type to connect
Opens Inkey to allow users to create an account or login with a previously created account. Must be called before transactions can be signed.
Optional
payload: { Optional payload object, can contain siteName
parameter to display the name of the application.
Optional
connectedOptional
sitePromise resolving to an account object of type { account: string, username: string }[]
// return array because we will support arrays of accounts in the future even if we always return 1 for now
Tells Inkey to close your session & clear local storage.
Success or fail message
Hides the Inkey wallet frame
Sends messages to Inkey via FrameBus
Message to send
Optional
options: { Optional
showWhatever Inkey gives us
Shows the Inkey wallet frame
Optional
routepath: stringSends unsigned transactions to Inkey, awaits signing, returns signed txns
Array of base64 encoded transactions OR more complex obj array w txn signing type needed
Optional
connectedAccounts: InkeyAccount[]Promise resolving to response object containing signedTxns if successful. Otherwise, provides error
or reject
properties. { success, reject, error, signedTxns }
Signs unsigned transactions, returns signed txns
Array of Uint8Array encoded transactions
Optional
connectedAccounts: InkeyAccount[]Promise resolving to response object containing signedTxns if successful. Otherwise, provides error
or reject
properties. { success, reject, error, signedTxns }
Optional
INDEX_Optional
opts: { Checks if account has at least one token (before playback) Keeping this here in case this is a faster/less expensive operation than checking actual balance
Address to check
the index of the ASA
Returns an atomic transaction that closes out the user's local state in an application. The opposite of atomicOptInApp.
Object containing appIndex
, appArgs
, and optionalFields
properties
Promise resolving to atomic transaction
Create an atomic transaction to deploy a new Smart Contract from TEAL code
AlgonautDeployArguments
AlgonautAtomicTransaction
Create asset transaction
: AlgonautCreateAssetArguments obj must contain: assetName
, symbol
, decimals
, amount
.
atomic txn to create asset
Returns atomic transaction that deletes application
ID of application
Optional
optionalTxnArgs: AlgonautTransactionFieldsPromise resolving to atomic transaction that deletes application
Optional
optionalTxnArgs: AlgonautTransactionFieldsCreates transaction to opt into an app
AlgonautCallAppArgs
AlgonautAtomicTransaction
Optional
optionalTxnArgs: AlgonautTransactionFieldsCreates send asset transaction.
IMPORTANT: Before you can call this, the target account has to "opt-in" to the ASA index. You can't just send ASAs to people blind!
object containing to
, assetIndex
, and amount
properties
Promise resolving to AlgonautAtomicTransaction
Updates an application with makeApplicationUpdateTxn
AlgonautUpdateAppArguments
atomic transaction that updates the app
Call a "method" on a stateful contract. In TEAL, you're really giving an argument which branches to a specific place and reads the other args
Object containing appIndex
, appArgs
, and optionalFields
properties
Optional
callbacks: AlgonautTxnCallbacksCloses out the user's local state in an application. The opposite of optInApp.
Object containing appIndex
, appArgs
, and optionalFields
properties
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
Promise resolving to atomic transaction
Compiles TEAL source via algodClient.compile
source to compile
Promise resolving to Buffer of compiled bytes
Create and deploy a new Smart Contract from TEAL code
AlgonautDeployArguments
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
AlgonautTransactionStatus
Create asset
AlgonautCreateAssetArguments. Must pass assetName
, symbol
, decimals
, amount
.
Optional
callbacks: AlgonautTxnCallbacksAlgonautTxnCallbacks
asset index
Creates a wallet address + mnemonic from account's secret key. Changed in 0.3: this does NOT set algonaut.account.
AlgonautWallet Object containing address
and mnemonic
Decodes app state into a human-readable format
Encoded app state
Array of objects with key, value, and address properties
Deletes an application from the blockchain
ID of application
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
Optional
optionalTxnArgs: AlgonautTransactionFieldsPromise resolving to confirmed transaction or error
Deletes asset
Index of the ASA to delete
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
Optional
optionalTxnArgs: AlgonautTransactionFieldsPromise resolving to confirmed transaction or error
deploys a contract from an lsig account keep in mind that the local and global byte and int values have caps, 16 for local and 32 for global and that the cost of deploying the app goes up based on how many of these slots you want to allocate
AlgonautLsigDeployArguments
Sync function that returns a correctly-encoded argument array for an algo transaction
must be an any[] array, as it will often need to be a mix of strings and numbers. Valid types are: string, number, and bigint
a Uint8Array of encoded arguments
Creates a LogicSig from a base64 program string. Note that this method does not COMPILE the program, just builds an LSig from an already compiled base64 result!
an algosdk LogicSigAccount
Get info about an application (globals, locals, creator address, index)
ID of application
Promise resolving to application state
Gets account local state for an app. Defaults to AnyWallets.activeAddress unless an address is provided.
the applications index
Optional
address: stringLoads and/or returns the inkey-wallet client sdk for whatever use. see inkey-client-js docs for more.
nodeConfig object or false
if no nodeConfig is set
Optional
config: AlgonautConfigOptional
walletInitParams: WalletInitParamsObjYou can be opted into an asset but still have a zero balance. Use this call for cases where you just need to know the address's opt-in state
object containing account
and assetId
properties
boolean true if account holds asset
checks if config obj is valid for use
Optional
nodeConfig: { Optional
INDEX_boolean. true is good.
Mnemonic associated with Algonaut account
If mnemonic is valid, it returns the account (address, chain). Otherwise, throws an error.
use .connect() with mnemonic arg Recovers account from mnemonic (helpful for rapid development but overall very insecure unless on server-side)
Opt-in the current account for an app.
Object containing appIndex
, appArgs
, and optionalFields
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
Promise resolving to confirmed transaction or error
Opt-in the current account for the a token or NFT Asset.
number of asset to opt-in to
Optional
callbacks: AlgonautTxnCallbacksAlgonautTxnCallbacks
, passed to sendTransaction
Optional
optionalTxnArgs: AlgonautTransactionFieldsPromise resolving to confirmed transaction or error
Sends ALGO from own account to args.to
AlgonautPaymentArgs
object containing to
, amount
, and optional note
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
Promise resolving to transaction status
Sends asset to an address.
IMPORTANT: Before you can call this, the target account has to "opt-in" to the ASA index. You can't just send ASAs to people blind!
object containing to
, assetIndex
, and amount
properties
Optional
callbacks: AlgonautTxnCallbacksoptional AlgonautTxnCallbacks
Promise resolving to confirmed transaction or error
Sends a transaction or multiple w the correct wallet according to AW
Either an array of atomic transactions or a single transaction to sign
Optional
callbacks: AlgonautTxnCallbacksOptional object with callbacks - onSign
, onSend
, and onConfirm
Promise resolving to AlgonautTransactionStatus
Optional
config: AlgonautConfigSigns a transaction or multiple w the correct wallet according to AW (does not send / submit txn(s) to network)
Either an array of atomic transactions or a single transaction to sign
Promise resolving to AlgonautTransactionStatus
Helper function to turn globals
and locals
array into more useful objects
State array returned from functions like getAppInfo
A more useful object: { array[0].key: array[0].value, array[1].key: array[1].value, ... }
TODO add correct typing for this method
Sends an update app transaction
AlgonautUpdateAppArguments
Optional
callbacks: AlgonautTxnCallbacksoptional callbacks: onSign
, onSend
, onConfirm
transaction status
General purpose method to await transaction confirmation
a string id of the transacion you want to watch
Optional
limitDelta: numberhow many rounds to wait, defaults to 50
set to true if you'd like to see "waiting for confirmation" log messages
Generated using TypeDoc
Instantiates Algonaut.js.