Optins to TEAL Managed Account

Hello to Algorand community!

I’m looking into “Contract-Accounts” to be able to program some spending logic in an account. This account was previously a normal Algorand account that opted-in to some app, owned by , let’s say ADMIN private key.

Now I was able to create a Contract-Account using e.g:

goal clerk compile pool-gate.teal

That yields an address, let’s call it ACCOUNT1. First question is: who is the owner of this account at this point? I assume that since it’s not an address derived from a PK, it has no related “owner”.

Having that in mind I would like to -as in the no-contract account- optin to an app from this account.
My assumption is that this works:

# Create an optin-TX
goal app optin --app-id $APPID -f $ACCOUNT1 --app-arg "int:100" -o pool-optin.txn  

# Sign this tx with program logic

goal clerk sign --argb64 "$(echo $ARG1 | base64)"  -i pool-optin.txn -p pool-gate.teal -o pool-optin.stxn

At this point I guess that I can do goal clerk rawsend to send this transaction. But how I can enforce that the optin process is done by some owner account?
In case of standard accounts, you could not optin without signing with the proper key. I understand that a .teal program replaces that mechanism.

Maybe this is easy but I’m a little dizzy now.

I managed to do it by using Delegated logicSigs instead of “Contract Accounts”. I’m happy now.

Great! I was just going to add that you can include logic in pool-gate.teal that permits opt ins to an application. You just want to make sure you add enough restrictions on this transaction for it to be secure (e.g. include an expiration round, incorporate leases, restrict to a specific app ID)

But delegated logicsigs work too. And they may be better depending on the broader context for your app…like if you need full control of the account and the ability to opt in to future applications.

2 Likes

At Algorand Builder (a framework for building Algorand projects, something like Truffle in Ethereum). We have high level deployer.optInToASA function, demonstrated in our example. We are working on adding similar support for logic signatures (PR will be merged beginning of the next week).

NOTE: You should use master version - there are lot of goodies, which are not yet released. We are closing up API updates and will release new version next week.

1 Like