HIP-1010: Update Token Custom Fee Schedules via Smart Contracts
Author | Stanimir Stoyanov |
---|---|
Working Group | Nana Essilfie-Conduah, Luke Lee, David Bakin, Mustafa Uzun |
Requested By | IOBuilders |
Discussions-To | https://github.com/hashgraph/hedera-improvement-proposal/pull/1010 |
Status | Accepted ⓘ |
Needs Council Approval | Yes ⓘ |
Review period ends ⓘ | Wed, 14 Aug 2024 07:00:00 +0000 |
Type | Standards Track ⓘ |
Category | Service ⓘ |
Created | 2024-07-11 |
Updated | 2024-08-16 |
Requires | 18, 206, 514 |
Table of Contents
Abstract
HIP-514 introduced the ability for smart contracts to manage tokens. However, the ability to update or remove the Custom Fees
for a token is not currently supported.
This proposal aims to address this gap by introducing two new system contract functions in the Hedera Smart Contract Service (HSCS) logic that would expose the already defined in HIP-18 Hedera Token Service (HTS) logic.
Motivation
In many decentralized scenarios a contract may create a token with custom fees and at some point desire to update or remove said fees.
However, the current version of the Hedera Smart Contract Service (HSCS) does not provide us with a system contract function that is covering this use case.
Rationale
The HSCS already has the functionality that exposes HTS functions to smart contract calls (IHederaTokenService.sol
), so naturally we would want to extend that with the addition of new functions, rather than creating new approach for this case only.
By adding updateFungibleTokenCustomFees
and updateNonFungibleTokenCustomFees
functions to the token proxy redirect facade contract, functionality that is already available to HTS tokens can be included to the available capabilities of token contracts.
We have proposed two separate functions to distinguish between fungible and non fungible tokens. One key difference between them is that the FT can set Fixed
and Fractional
custom fees, while the NFTs can have Fixed
and Royalty
.
User stories
- As an EOA I would like to initiate a smart contract transaction that updates a fungible token’s custom fees and set a Fixed HBar fee.
- As an EOA I would like to initiate a smart contract transaction that updates a fungible token’s custom fees and set a Fixed HTS token fee.
- As an EOA I would like to initiate a smart contract transaction that updates a fungible token’s custom fees and set a Fractional fee.
- As an EOA I would like to initiate a smart contract transaction that updates a fungible token’s custom fees and set a combination of Fixed and Fractional fees.
- As an EOA I would like to initiate a smart contract transaction that updates a non-fungible token’s custom fees and set a Fixed HBar fee.
- As an EOA I would like to initiate a smart contract transaction that updates a non-fungible token’s custom fees and set a Fixed HTS token fee.
- As an EOA I would like to initiate a smart contract transaction that updates a non-fungible token’s custom fees and set a Royalty fee.
- As an EOA I would like to initiate a smart contract transaction that updates a non-fungible token’s custom fees and set a combination of Fixed and Royalty fees.
Specification
The ledger HSCS will utilize the existing Hedera Token Service (HTS) HAPI transaction for TokenFeeScheduleUpdate
within the System contract logic.
To achieve this the Hedera Token Service (HTS) system contract logic must be updated to expose the necessary custom fee features.
Hedera Token Service (HTS) system contract
New system contract functions must be added to the IHederaTokenService
interface to support the updating the custom fees for fungible and non-fungible tokens.
Hash | Selector | Return | Descriptions |
---|---|---|---|
0xe780c5d3 | function updateFungibleTokenCustomFees(address token, IHederaTokenService.FixedFee[] memory fixedFees, IHederaTokenService.FractionalFee[] memory fractionalFees) returns (int64 responseCode) | ResponseCode | The response code from the call |
0x01f9eb7d | function updateNonFungibleTokenCustomFees(address token, IHederaTokenService.FixedFee[] memory fixedFees, IHederaTokenService.RoyaltyFee[] memory royaltyFees) returns (int64 responseCode) | ResponseCode | The response code from the call |
Backwards Compatibility
Backwards compatibility is ensured as no existing features are modified. Similar to HTS system contract this HIP simply exposes HAPI entity functionality.
Security Implications
The newly added flows will adopt the HAPI authorization logic. In this way the transaction would be successful only if the given contract making the call is set as a feeScheduleKey
to the token or a threshold key including the calling contract ID is set for the same.
We will apply the TokenFeeScheduleUpdate
throttle mechanism.
How to Teach This
Reference Implementation
Rejected Ideas
updateTokenFeeSchedules
- An unified smart contract function to update or reset token’s custom fees based on the existing HTS logic. This idea relied on creating a new structure in theIHederaTokenService
interface to wrap the existing Fee structures into oneCustomeFee
and use it as an argument to the function. This was rejected as we provided а more clean solution differentiating between fungible and non fungible tokens.
References
Copyright/license
This document is licensed under the Apache License, Version 2.0 – see LICENSE or (https://www.apache.org/licenses/LICENSE-2.0)
Citation
Please cite this document as: