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

Unable to deserialize a transaction after serialization and freezing #2138

Closed
SvetBorislavov opened this issue Feb 15, 2024 · 0 comments · Fixed by #2139
Closed

Unable to deserialize a transaction after serialization and freezing #2138

SvetBorislavov opened this issue Feb 15, 2024 · 0 comments · Fixed by #2139
Assignees
Labels
bug Something isn't working
Milestone

Comments

@SvetBorislavov
Copy link
Contributor

Description

The scenario is the following: You create a transaction, serialize it, deserialize it, and only freeze it, without signing it.
After that serialize it again and when you try to deserialize it, the following error is thrown:
"failed to validate transaction bodies"

Steps to reproduce

  1. Run the following snippet:
const {
  AccountUpdateTransaction,
  Client,
  TransactionId,
  Timestamp,
  AccountId,
  Transaction,
} = require('@hashgraph/sdk');

async function run() {
  // Setting up Client
  const client = Client.forTestnet();

  // Creating Transation ID
  const accountId = AccountId.fromString('0.0.2159149');
  const transactionId = new TransactionId(
    accountId,
    Timestamp.fromDate(new Date())
  );

  // Creating a transaction
  const transaction = new AccountUpdateTransaction()
    .setTransactionId(transactionId)
    .setAccountId(accountId)
    .setAccountMemo('Hello');

  // Serializing the transaction
  const bytes = transaction.toBytes();

  // Sending...

  // Deserialize when received
  const transactionToFreeze = Transaction.fromBytes(bytes);

  // Freeze the transaction
  transactionToFreeze.freezeWith(client);

  // Serialize it again and send it
  const newBytes = transactionToFreeze.toBytes();

  // Deserializing the frozen transaction
  const frozenTransaction = Transaction.fromBytes(newBytes);

  client.close();
}
run();

Additional context

No response

Hedera network

other

Version

v2.42.0-beta.2

Operating system

None

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

Successfully merging a pull request may close this issue.

2 participants