algorand / go-algorand

Algorand's official implementation in Go.
https://developer.algorand.org/
Other
1.35k stars 473 forks source link

Support the ability to specify 'gaid t' as an app ID or asset ID #3701

Open AustP opened 2 years ago

AustP commented 2 years ago

Problem

Imagine that we have a smart contract that someone can call, and it will mint a new NFT asset for them. If the user wants the NFT to be in their wallet, they will have to sign a minimum of two transactions. This makes for a poor experience asking the user to sign a transaction, wait 15 seconds, then immediately sign another transaction.

Solution

The solution is adding support for a transaction to specify the asset/app ID that was created earlier in the group transaction, similar to how gaid t works in TEAL. The user could then sign a single group transaction and the end result would be a new asset is minted, opted into, and transferred to their wallet. An example of how this could be done using goal is below:

goal app call --app-id $APP_ID --app-arg "str:mintAsset" -f $ACCOUNT -o txn0.txn
goal asset send --assetid 'gaid 0' -f $ACCOUNT -a 0 -t $ACCOUNT -o txn1.txn
goal app call --app-id $APP_ID --app-arg "str:sendAsset" -f $ACCOUNT -o txn2.txn

If this worked for app IDs, then it would also handle the situation where you create a contract and want to fund it as an account in a single transaction.

Dependencies

No dependencies.

Urgency

The sooner this is implemented, the slicker Algorand becomes.

algoanne commented 2 years ago

Hi @AustP , thanks for reaching out. I think delegated signatures could achieve what you're looking for: https://developer.algorand.org/docs/get-details/dapps/smart-contracts/smartsigs/modes/?from_query=delegate#delegated-approval . Let me know if that doesn't solve your problem - definitely want to make Algorand slicker.

algoanne commented 2 years ago

Talking to some friends about this a little. The delegated approval is considered "the nuclear option" in the sense that it increases security risk (for obviously reasons). So, going to think about this problem a bit more.

AustP commented 2 years ago

Yes, I agree. Using delegated approval would work but in addition to increasing the security risk, also requires more overhead for the developer. I think this use case will become more and more common as Algorand grows, so making it easier for developers to accomplish this task seems like a good thing to me.

Also, I don't know if using 'gaid 0' to specify is the best solution to the problem. I was mainly trying to come up with a good way to convey the issue and a possible solution.

algoanne commented 2 years ago

Hi @AustP we're likely going to take a more drastic move to solve this problem (you're not the first to bring up this clunkiness), so I'm going to move this ticket to iceboxed and move it to the team who will work on that area. Once we have the new work written up we'll link it here and close this ticket. FYI @yaovi-a