hashgraph / hedera-smart-contracts

Contains Hedera Smart Contract Service supporting files
Apache License 2.0
38 stars 53 forks source link

HIP 551 HTS Atomic Examples #650

Closed Nana-EC closed 7 months ago

Nana-EC commented 8 months ago

Problem

HIP 551 highlights batch transactions. During the discussions examples were highlighted that could be captured by Smart Contract Scenarios

Solution

Add examples of common batch transactions using HTS calls

Additional considerations noted in https://github.com/hashgraph/hedera-improvement-proposal/pull/551#discussion_r1189004582 include Associate -> Contract Call

The contract call is going to send a token to the user. The user must associate the token first, or the contract will revert.

Allowance Approval -> Contract Call

The contract call is going to take tokens from a user. The user must grant a token allowance first, or the contract will revert.

Allowance Approval -> Allowance Approval -> Associate -> Contract Call

The contract call is going to take 2 different tokens from a user and send the user an unassociated token that has already been created on the network. The user must grant token allowances first and associate the receivable token, or the contract will revert.

Allowance Approval -> Allowance Approval -> Account Update -> Contract Call

The contract call is going to take 2 different tokens from a user and send the user an unassociated token that will be created in the contract call. The user must grant token allowances first and have an available auto association slot, or the contract will revert.

Contract Call -> Contract Call

First contract call is an external contract. Second contract call is a contract validating the results of the first contract. The second contract will revert if the first contract does not produce the intended results. This could be a security enhancement and improve contract call extensibility.

Alternatives

No response

Nana-EC commented 8 months ago

Can add an AtomicHTS.sol under contracts/hts-precompile

Nana-EC commented 8 months ago

See