Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cryptoTransfer support for erc20 & erc721 tokens #804

Open
se7enarianelabs opened this issue Jun 12, 2024 · 0 comments
Open

cryptoTransfer support for erc20 & erc721 tokens #804

se7enarianelabs opened this issue Jun 12, 2024 · 0 comments
Labels
ArianeLabs Items ArianeLabs is contributing to enhancement New feature or request

Comments

@se7enarianelabs
Copy link

Problem

Currently, Hedera allows developers to treat HTS tokens as ERC20 and ERC721 tokens in smart contracts thanks to HIP-218. This has enabled us to port EVM contracts and support HTS tokens out-of-the-box.

Previously, supporting NFT royalty fees in NFT marketplaces was challenging. Consider this pseudocode:

erc721.transferFrom(_from, _to, serialNumber)
_to.call{value: msg.value}("");

This allows for a non-custodial NFT marketplace. However, from Hedera's perspective, we have one parent Ethereum transaction and within it, two child Ethereum transactions (for erc721.transferFrom and _to.call). NFT royalty fees are only applied if the NFT and value are exchanged in the same Hedera "child" transaction, so in our pseudocode, only NFT fallback fees will be applied.

With the upcoming support for HBAR allowance in cryptoTransfer, we will be able to support NFT royalty fees. This will require checking if the settlement involves HTS NFTs for HBAR and using cryptoTransfer with allowances. For any settlement involving ERC20 or ERC721 tokens, we still need to use the standard EVM method, as cryptoTransfer does not support "ERC" tokens.

Example:

// Check if HTS NFT and (HTS FT or HBAR) is part of the settlement
if (isToken(erc721) && (isToken(erc20) || erc20 == "0x")) {
    // Call crypto transfer
} else {
    erc721.transferFrom(_from, _to, serialNumber);
    _to.call{value: msg.value}("");
}

Currently, if we do not want to support NFT royalty fees, EVM developers can port existing NFT marketplace Solidity contracts. If they want a custom marketplace exclusively for HTS tokens, they can use cryptoTransfer. However, to support both ERC and HTS tokens with NFT royalty fees, they need to use both the Ethereum method and cryptoTransfer.

Solution

Our proposal is to implement something like cryptoTransferWithERCSupport, which would have the same interface as cryptoTransfer but would check if the addresses provided as parameters are HTS/HBAR or ERC. If they are ERC, it would redirect to the ERC contract implementation, similar to the redirectForToken mechanism in HIP-218.

Alternatives

No response

@se7enarianelabs se7enarianelabs added the enhancement New feature or request label Jun 12, 2024
@Nana-EC Nana-EC added the ArianeLabs Items ArianeLabs is contributing to label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ArianeLabs Items ArianeLabs is contributing to enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants