hiero-ledger / hiero-ledger/hiero-consensus-node
.setAccountId does not accept EVM address based account ID
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
### Description
## Description copied from issue: https://github.com/hashgraph/hedera-sdk-js/issues/2442
Variation 1 - EVM address as string:
```javascript
const assocTx = await new TokenAssociateTransaction()
.setAccountId('0x34fe5d75bd7ee95273ac9883c460d71edb0a2b6e')
.setTokenIds([tokenId])
.setNodeAccountIds([AccountId.fromString('0.0.5')])
.freezeWith(client);
```
Variation 2 - account ID based on EVM address:
```javascript
const assocTx = await new TokenAssociateTransaction()
.setAccountId(AccountId.fromEvmAddress(0, 0,'0x34fe5d75bd7ee95273ac9883c460d71edb0a2b6e'))
.setTokenIds([tokenId])
.setNodeAccountIds([AccountId.fromString('0.0.5')])
.freezeWith(client);
```
Variation 3 - Account ID in S.R.N format:
```javascript
const assocTx = await new TokenAssociateTransaction()
.setAccountId(AccountId.fromString('0.0.4654396'))
.setTokenIds([tokenId])
.setNodeAccountIds([AccountId.fromString('0.0.5')])
.freezeWith(client);
```
This also occurs for `TokenFreezeTransaction()` as it was reported by a developer who is part of the Hello Future Hackathon.
### Steps to reproduce
## Steps to reproduce
1. Create assocTx in each of the above variations.
2. Sign an submit assocTx using the code below
3. Observe that with variation 1 and 2, there is an error, but variation 3 works
* Note that all 3 variations refer to the same account:https://hashscan.io/testnet/account/0.0.4654396
* Note that this behaviour is inconsistent with other SDK methods, such as TransferTransaction, which do accept their own equivalents of variations 1 and 2.
```javascript
const assocTxId = assocTx.transactionId;
logger.log('The token association transaction ID:', assocTxId.toString());
await logger.logSectionWithWaitPrompt('Submitting token association transaction');
const assocTxSigned = await assocTx.sign(account1Key);
const assocTxSubmitted = await assocTxSigned.execute(client);
const assocTxReceipt = await assocTxSubmitted.getReceipt(client);
const assocTxStatus = assocTxReceipt.status;
logger.log(
'The token association transaction status is:',
assocTxStatus.toString(),
);
```
### Additional context
## Additional context
The error is INVALID_ACCOUNT_ID and the full output is copied below.
The error occurs when getReceipt is invoked.
ReceiptStatusError: receipt for transaction 0.0.4650263@1722847623.102513022 contained error status INVALID_ACCOUNT_ID
at new ReceiptStatusError (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/ReceiptStatusError.js:37:9)
at TransactionReceiptQuery._mapStatusError (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/transaction/TransactionReceiptQuery.js:332:16)
at TransactionReceiptQuery.execute (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/Executable.js:725:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TransactionResponse.getReceipt (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/transaction/TransactionResponse.js:81:25)
at async scriptTokenHts (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/tokenHts/script-tokenHts.js:126:28) {
status: Status { _code: 15 },
transactionId: TransactionId {
accountId: AccountId {
shard: [Long],
realm: [Long],
num: [Long],
aliasKey: null,
evmAddress: null,
_checksum: null
},
validStart: Timestamp { seconds: [Long], nanos: [Long] },
scheduled: false,
nonce: null
},
transactionReceipt: TransactionReceipt {
status: Status { _code: 15 },
accountId: null,
fileId: null,
contractId: null,
topicId: null,
tokenId: null,
scheduleId: null,
exchangeRate: ExchangeRate {
hbars: 30000,
cents: 143313,
expirationTime: 2024-08-05T09:00:00.000Z,
exchangeRateInCents: 4.7771
},
topicSequenceNumber: Long { low: 0, high: 0, unsigned: false },
topicRunningHash: Uint8Array(0) [],
totalSupply: Long { low: 0, high: 0, unsigned: false },
scheduledTransactionId: null,
serials: [],
duplicates: [],
children: []
}
}
### Hedera network
testnet
### Version
2.48.1
### Operating system
macOS
Contributor guide
Research direction
Start by reproducing the failure in script-tokenHts.js around line 126, then trace TokenAssociateTransaction and TokenFreezeTransaction handling of setAccountId. Compare their behavior with TransferTransaction and the working 0.0.4654396 form. Done means the EVM string and AccountId.fromEvmAddress forms work consistently with the numeric account ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100