Algo minimum balance of an address and Algorand network dapp

gm, i’m currently develop some applications on Algorand.

there some point i want to discuss while i’ve finished reading docs and researching about algorand contract:

  • minimum account balance (for account and smart contract address also): how does it calculated through query the info of the account (as i know, must have the info of the asset opt in, global variable created, local variable opt in,…)? does the sdk or the network have some way to query it in one go? i did read in these Smart contract details - Algorand Developer Portal and Algorand Standard Assets (ASAs) - Algorand Developer Portal and see some application (like tinyman) have a way when user hit max algo to sell, it does count the minimum and left over a little. or when i try to send more then minimum available, the network did response back that bellow x amount of minimum algo balance.

  • the second one is: i’m using python sdk. i’m try to increase the priority of my transaction so that i could be included in the block faster, how can i do it (which mean increase the “gas price” by normal mean)?

  • and the last one is: for what i see, teal only support uint64 which the max value is 2^64. which quite smaller than other chains. so how do you deal with number bigger than 2^64 or the math which result more than that.

thanks for reading and keep building on algorand!!

1 Like

thanks for your answering. it make more sense for me now.

so do you know how to calculate the minimum algo for an address given? i mean the step and the field need to use.
for example using using sdk or api to get user info, and use which field of that user info multiple and plus each other to some number, so the final result will be the minimal algo balance for that address?

Yes, see:

and references therein.

1 Like

Tks fabrice, it was a great help for me.

One more question: when i send a failed transaction to app, it appear to show error code like assert failed pc=800.
So do you have any idea where to find exactly the line of code validate error or smt like that, please let me know.

from my observation, this number tells you somehow information how far the error has been thrown in the code… perhaps the meaning of pc is point cursor or somehing like that

800 is quite big and seems that the app is failing at the end…

if you have ability to change the code, just insert return 0 somewhere in the middle of the app, and this number shuould be less… this way you can detect exact line code which is failing

but i am not an expert here… depends on many things… for example if you use teal/pyteal/reach or if you use external code or others… perhaps others might have better insight

1 Like

Hi @hungpq ,

I suggest you debugging the Smart Contract with the transaction that is generating this assertion error, by using the TEAL debugger: you will be able to inspect your code line by line acting on the stack machine.

1 Like

Thanks everyone, i got the overall idea.

One more question, does algorand contract have something simillar to event in others blockchain. and anyidea of browsing event in block base? like query event in some specific range block?

The AVM provides a log opcode to return bytes response as a result of an ApplicationCall to the Application.

The AVM 1.0 still doesn’t a Contract-to-Contract call (the Application Call as Inner Transaction will be added in the next release of the AVM), so you can not automatically “inform” or “callback” a contract from another one.

The Indexer provides all the APIs (wrapped directly in the SDKs) to query the blockchain as you like, for example: retrieving transactions of a given ASA within a block range, retrieving transactions of a given address, read the local state of an Application for a given address, read the global state of the Application, etc.

One more here

in others blockchain, there has concept in smart contract called factory (a contract can create other contract). can smart contract in algorand do the same (for statefull smart contract)?

And another thing, i did read about stateful and stateless smartcontract in Algorand.

And for developing dapps, i see stateful have all the things that stateless smart contract does have. so why some dapp (like Tiny Man) still use stateless smart contract (smart signature) in their contract design? does it come to some special design or edge case that they have to do it.

Yes, once the AVM will support Contract-2-Contract call in the next release.

1 Like

Not sure about the specific Tinyman use-case but I suspect that’s because they started the development of their protocol before the AVM supported Inner Transactions, so I’d say is rather a legacy reason than a design one.

Smart Signature are still very helpful if you have highly cost opcodes like ed25519verify .

Here you have a great review of the AVM evolution by @jannotti: https://www.youtube.com/watch?v=zmRT46H0hzg

1 Like

tks for your answer. it help me a lot
i got another one. for contract call (pay, transfer asset from contract), these fee of the transaction must be paid by the contract.
therefore i must design a funding amt in a group txn in the group txn of interact for the contract. is there any better degisn for this? like sender send 1 txn interact to the contract and pay also the fee for the inner txn itslef (seem like assert that no fee is paid by this contract in this article Building a decentralized vault using stateful smart contracts | Algorand Developer Portal)

You can design your Smart Contract forcing InnerTxn.fee == 0 and let users trigger the Inner Transaction by calling the App with an ApplicationCall.fee == 2 * min_fee.

Since the Inner Transaction is executed “atomically” with the AppCall, the Consensus Protocol just checks that the pooled fee is sufficient (in this case the Application Call backs both its own fee and the Inner Transaction fee).

1 Like

A post was split to a new topic: Update of smart contracts and testing

To help users follow more easily discussion, I’ve split this topic into:

A post was split to a new topic: Overflow/underflow of []byte integer operations