More detail about new AVM contract to contract

Hi. i did read about Algorand newest update Contract to Contract calls and an ABI come to Algorand | Algorand Developer Portal and feeling very amazing with these.

there are more point here i want to make clear

  • applications can create other contracts on the network this sound like factory pattern can be used here. any code example of app create app here since seem like this still a new things and haven’t been updated in the examples?
  • we can use this as example here for contract call contract using group inner txn: user A call contract B using group txn1. contract B call contract C using group txn2.
  • i see in the article that contract C can using CallerApplicationID and CalllerApplicationAddress in group txn2 to get the info of contract B. but any others way to do this? something like txn.sender in others platform?
  • in the contract C with group txn2 what is the value for Txn.sender() and Gtxn[index]? does it refer to group txn1 or group inner txn 2?
  • contract C if need to check group txn 2 field can using Gtxn[index]? or need to call others Pyteal opcode since i cant find it in the new version of pyteal (v10)? if does have pyteal corresponding to op code gitxn (to reveal inner group txn2) please let me know.

Thanks. it does very amazing to see these updates

That is a good point.

A minor caveat is that right now in many cases where Ethereum use a factory design, I personally believe it is cleaner on Algorand to use local storage of fresh accounts rekeyed to the application account address (or controlled by a LogicSig).
This is what tinyman is using for example: GitHub - tinymanorg/tinyman-contracts-v1: Tinyman AMM Contracts V1.1

I don’t think there is another way. Why do you want another way?

Apart from CallerApplicationID and CallerApplicationAddress, everything looks like the transaction was made at top-level from Contract C point of view. Txn and Gtxn refer to the inner transaction and inner transaction group that called Contract C (that is in your notation group txn2).

It can use gtxn.
gitxn is to inspect inner transactions made by contract C.

This is what tinyman is using for example: GitHub - tinymanorg/tinyman-contracts-v1: Tinyman AMM Contracts V1.1

i did see the tiny man design. logicSig is cool but i want to use the address of the app and building own inner txn to minimum the txn needed. what i need here is any example of app create app (in pyteal is great)

I don’t think there is another way. Why do you want another way?

so it would be the general case (for example to check if the sender is authoried, no matter of any address). and quick question here in my above B,C contract call example. in C contract, when i check Txn.sender, what will be the value? is that A?

It can use gtxn .
gitxn is to inspect inner transactions made by contract C.

thank for your answer. i want to make thing clearer here. In contract C, i call gtxn to get the group txn2. In contract B, i call gitxn to get the groupt txn2.

If B used the default sender, it is the application account of B.
In general, it is the sender of the inner transaction as specified by B.
(It can either be the application account of B or any account rekeyed to that address.)

Yes, exactly.

Intersting here since in contract C, CallerApplicationID and CalllerApplicationAddress could return B and B’s address.
So it still mean that (if all default, B does not change the sender group txn2) in contract C, get Txn.sender will return B’s address just like CalllerApplicationAddress?

So in C, how to get address of A? Is there anyway?

Yes

I don’t think there is any way.

1 Like

thanks for your answer

any docs or update relate to this?

very amazing and really want to use new AVM version 1.1. does any testnet available for teal version 6?

i try https://api.testnet.algoexplorer.io api (v2 - Algorand Developer Portal) and https://node.testnet.algoexplorerapi.io but it seem like it cant compile new op code: HTTP Error 400: Bad Request AlgodHTTPError: 773: unknown opcode: bsqrt (try using bsqrt here)

Any solution or others testnet api available for teal version 6?

TestNet has not fully upgraded yet.
You can either use BetaNet or your own private network using sandbox.

1 Like

Thanks for your answer. it help me a lot

So any plan to see this upgrade in testnet or mainnet? if does, when does this will likely happend? a month is good?

Hi i want to ask if i can query other transcation properties in group inner txn
for example 1 i got this group txn
txn1: call to contract A, then A call inner txn create contract B
txn2: call to contract C. in this contract, how can i get address/appId of B?

for example 2 i got this group txn
txn1: call to contract C. C then call contract A, A call inner txn create contract B. After call contract A, C want to call contract B. how C now can know address/appId of B?

Thanks for your answer!

It will be available starting from round 19756192 on MainNet.
This is around 3pm EST on Saturday, March 12

Not directly, but contract A can log it or store it in its scratch space so that contract C can read it with the appropriate opcode.

A needs to return it via a log opcode or store it in its scratch space.

1 Like

Thanks for your help.

Speaking to return value, are there any example of call inner txn, app call log and get the return value from that in pyteal?
This seem pretty new and give more flexibility.