-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: Creates design doc for enabling access to hts token evm address #3258
Open
konstantinabl
wants to merge
8
commits into
main
Choose a base branch
from
3257-create-design-doc-enabling-returning-of-hts-token-address-in-receipt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+62
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0f67df4
Creates design doc for enabling access to newly created hts token add…
konstantinabl 91a33f8
Makes small wording changes
konstantinabl 3a07dff
Improves design doc
konstantinabl 92a3d61
Makes testing plan more detailed
konstantinabl 49f3591
Adds example call result
konstantinabl 95efc28
Makes small improvement to fromatting
konstantinabl 40f8f16
Update docs/design/hts_address_tx_receipt.md
konstantinabl 06ba64b
Update docs/design/hts_address_tx_receipt.md
konstantinabl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# HTS Token Creation via SystemContract Receipt Enhancement | ||
|
||
## Purpose | ||
The purpose of this enhancement is to improve the interoperability between Hedera Token Service (HTS) and Ethereum-compatible tools, like ethers, by ensuring access to the necessary information about newly created tokens, in this case token address. This change specifically addresses the gap in Web3 tooling support when creating tokens through HTS precompile contracts, making user experience smoother. | ||
|
||
|
||
## Problem Statement | ||
When users create tokens (fungible and non-fungible) by directly calling the 0x167 contract there is no way for them to get the evm address of the newly created token via standard EVM tooling e.g ethers. This is because the transaction receipt's contractAddress field is not being populated with the HTS token address, since essentially the operations is just a contract call, but not a contract create (deploy). | ||
|
||
## Current Behaviour | ||
|
||
Currently, when creating a token via HTS the address of the system contract is returned as a contractAddress in the transaction receipt. | ||
|
||
## Proposed Solution | ||
|
||
### Technical Details | ||
|
||
### 1. Function Signature Detection | ||
|
||
Detect in the transactionResponse from the mirror node, if the transaction was calling any of the HTS methods - createFungibleToken/createNonFungibleToken/createFungibleTokenWithCustomFees/createNonFungibleTokenWithCustomFees | ||
|
||
N.B The following forms of the [HTS system contract](https://github.com/hashgraph/hedera-smart-contracts/tree/v0.10.1/contracts/system-contracts/hedera-token-service) create token function selectors will be supported. This is as of the 0.56 version of the services. | ||
|
||
```javascript | ||
const HTS_CREATE_FUNCTIONS_SIGNATURE = [ | ||
"createFungibleToken(...)", | ||
"createNonFungibleToken(...)", | ||
"createFungibleTokenWithCustomFees(...)", | ||
"createNonFungibleTokenWithCustomFees(...)" | ||
]; | ||
const functionSelector = receiptResponse.function_parameters.substring(0, FUNCTION_SELECTOR_CHAR_LENGTH); | ||
const isTokenCreation = HTS_CREATE_FUNCTIONS_SIGNATURE.some(signature => | ||
Utils.calculateFunctionSelector(signature) === functionSelector | ||
); | ||
``` | ||
|
||
### 2. Extract the token address from the `call_result` field in the transaction response. | ||
The extractions can performed with string matching logic since we know what the function response is beforehand and we know the last 40 characters of the response are the token address. | ||
|
||
Example call_result. First 64 characters excluding 0x prefix are the response code, second 64 characters are the token address: | ||
```json | ||
"call_result": "0x0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000040a" | ||
``` | ||
|
||
konstantinabl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```javascript | ||
const tokenAddress = receiptResponse.call_result.substring(receiptResponse.call_result.length - 40); | ||
``` | ||
After extraction, the expected output is: | ||
``` | ||
"0x000000000000000000000000000000000000000000000000000000000000040a" | ||
``` | ||
|
||
### 3. Add the token address to the receipt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: nothing in this section. |
||
|
||
|
||
## Testing Requirements | ||
|
||
### Acceptance tests | ||
1. Test creation of fungible token via ethers and correct receipt response | ||
2. Test creation of non fungible token via ethers and correct receipt response | ||
3. Test creation of fungible token with custom fees via ethers and correct receipt response | ||
4. Test creation of non fungible token with custom fees via ethers and correct receipt response |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notably, this should be done in a way that can be generalized to other future system contracts e.g. createSchedule or createTopic