hedera-smart-contracts
hedera-smart-contracts copied to clipboard
Can't get HTS token address when creating the token using the interface IHederaTokenService
Description
Problem:
When creating an HTS token using the interface IHederaTokenService
, a developer can't get the token address using Ethers JS.
Context:
-
IHederaTokenService
(see file here) has the functioncreateNonFungibleToken
whichreturns (int64 responseCode, address tokenAddress);
- I currently have the JS code shown in the screenshot (see full code in this repo), which successfully creates the token calling the function
createNonFungibleToken
. - Despite the token creation working well, I can’t get the address of the newly created token using Ethers. -- Decomposing the transaction output does not return the responseCode or the tokenAddress. I think this works when creating the token through a wrapper/intermediary contract, but it doesn’t seem to work when calling the system contract using the interface… -- The logs of the tx receipt are empty and there are no events.
For devs working with Ethers/Hardhat, those tools only return a transaction hash (no tx ID). The mirror node REST API supports querying transactions with our 48-byte form of the tx hash, not the Ethereum 32-bytes one. So querying mirror nodes with the tx hashed obtained would not be seamless either.
Possible Solution:
- We are emitting a log for HTS transfers.
- We could assimilate the creation of a new token as the creation of a new smart contract, so we can use the same format for the receipt. That would be something all the Ethereum tools can easily understand and work with out of the box, without having to rely on custom logs.
Thanks to everyone who provided feedback and input!
Steps to reproduce
- Run this repo with GitPod via this link: https://gitpod.io/?autostart=true#https://github.com/ed-marquez/hedera-example-create-tokens-via-contracts/tree/5351753720d3db77cfab098834527fae1eafa299
- Enter
npx hardhat test
on the terminal - See the results of the 3rd test case
Additional context
No response
Hedera network
mainnet, testnet
Version
v0.52
Operating system
macOS