Skip to content
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

TokenCreateTransaction fails with INVALID_EXPIRATION_TIME when freezing with a client without operator #2216

Open
seromenho opened this issue Mar 19, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@seromenho
Copy link
Contributor

seromenho commented Mar 19, 2024

Description

I am creating a TokenCreateTransaction transaction to be signed and broadcasted later (in less than the validity time window), but there's an error when executing the query

transaction xxx failed precheck with status INVALID_EXPIRATION_TIME

Steps to reproduce

const client = Client.forTestnet()
const payerAccountId = AccountId.fromString(payerAccountIdString)
const transactionId = TransactionId.generate(payerAccountId)
const treasuryPublicKey = PublicKey.fromStringED25519(publicKey)

const tx = new TokenCreateTransaction()
    .setTokenName(name)
    .setTokenSymbol(symbol)
    .setTreasuryAccountId(tresuryAccountId)
    .setInitialSupply(Long.fromString(initialSupply))
    .setTokenType(type)
    .setDecimals(decimals)
    .setPauseKey(treasuryPublicKey)
    .setSupplyKey(treasuryPublicKey)
    .setAdminKey(treasuryPublicKey)
    .setWipeKey(treasuryPublicKey)
    .setKycKey(treasuryPublicKey)
    .setTransactionId(transactionId)
    .setNodeAccountIds(nodeAccountIds)
    .freezeWith(client)

After signing, on broadcasting the error happens.

const client = Client.forTestnet()
const signedTransaction = Transaction.fromBytes(Buffer.from(signedRawTx, 'hex'))
const txResponse = await signedTransaction.execute(client)

Additional context

Maybe a related issue: #991

Hedera network

testnet

Version

2.37.0

Operating system

Linux

@seromenho seromenho added the bug Something isn't working label Mar 19, 2024
@seromenho
Copy link
Contributor Author

seromenho commented Mar 19, 2024

I've found the problem right after creating this issue 🙃

I've fixed this manually setting the expiration time. If I freeze the transaction without an operator the default value for expiration time is not set correctly.

The documentation mentions that the default expiration time is 90 days by default. https://docs.hedera.com/hedera/sdks-and-apis/sdks/token-service/define-a-token

const expirationTime = new Date()
expirationTime.setSeconds(expirationTime.getSeconds() + 7890000)
...
.setExpirationTime(expirationTime)
...

The problem is solved so feel free to close the issue.
I'll leave it open as if the expiration time is optional and has a default value of 90 days, you shouldn't need to explicitly set it.
Freezing with a client without an operator should have the same behaviour as freezing vs with a client without an operator that works just fine.

@seromenho seromenho reopened this Mar 19, 2024
@svetoslav-nikol0v svetoslav-nikol0v self-assigned this Apr 16, 2024
@svetoslav-nikol0v
Copy link
Contributor

Hi seromenho,

Setting the expiration time will do the job. In the newest version 2.44.0 the expiration time is set to 90 days (as mentioned in the documentation) so it's not necessary to set it explicitly.
Regarding the issue you mentioned above, the logic that was implemented then is removed now because overrides the auto-renew account if is different from the operator account.

We'll close the ticket if you have no further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants