Add fungible token contract, via HTS#48
Conversation
markogracin
commented
Feb 13, 2025
- due compatibility with Hedera (hashscan), and usage with Hashpack, we went in the HTS direction over standard ERC20.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
e3a95d4 to
39f4435
Compare
pcaversaccio
left a comment
There was a problem hiding this comment.
I quickly glanced through the contract and left some comments.
| */ | ||
| constructor() { | ||
| _owner = msg.sender; | ||
| _feeRecipient = msg.sender; |
There was a problem hiding this comment.
constructor(address feeRecipient_) {
...
if (feeRecipient_== address(0)) {
revert FeeReceiptInvalid(address(0));
}
_feeRecipient = feeRecipient_;
}| * @notice Sets up a 1% fractional fee with min/max limits | ||
| * @notice Contract maintains supply and fee management permissions | ||
| */ | ||
| function createFungible() external payable returns (address createdTokenAddress) { |
There was a problem hiding this comment.
I have never seen such a function tbh and I'm not sure if this the right way to do it, it's definitely not the right way on Ethereum lol
There was a problem hiding this comment.
Also should only be invoked by the owner?
There was a problem hiding this comment.
Yeah, this part that differs from the standard contracts, as it's using HederaTokenService, to make it compatible with hashpack wallet and hashscan. Will find the examples and documentation that I used to add this, as a reference.
| address(this), | ||
| amount | ||
| ); | ||
| if (transfer != HederaResponseCodes.SUCCESS) revert("Collateral coin transfer failed"); |
There was a problem hiding this comment.
This contract uses inconsistently require and revert. Can we use everywhere custom errors please?
| * @notice Transfers all available balance to fee recipient | ||
| * @notice Reverts if no fees are available to collect | ||
| */ | ||
| function collectFees() external { |
There was a problem hiding this comment.
we should have another emergency function to save any wrongly sent tokens to the contract.
Thanks @pcaversaccio, appreciate it! Will take a look this weekend, and get back to re-check. |
Introduced OpenZeppelin's `Ownable` contract to simplify ownership management and removed custom `onlyOwner` modifier logic. Updated `TokenCreator` to inherit `Ownable`, refactored constructor, and replaced `_owner` references with `owner()`. Added `@openzeppelin/contracts` as a dependency in `package.json`, and updated import statements accordingly.
Introduce public getter functions to retrieve addresses for the token, collateral token, contract owner, and fee recipient, as well as the amount of locked collateral.
…wner Add `onlyOwner` modifier to `createFungible` and `setCollateralToken` functions to ensure only the contract owner can execute these actions.
Replaced generic string-based revert messages with custom error types for improved clarity and gas efficiency.
Introduce `emergencyTokenRecovery` to allow the contract owner to recover wrongly sent tokens, ensuring collateral or main token fees remain unaffected. Added relevant event and error.