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

Child transaction creation not working with the JS SDK #1186

Closed
ed-marquez opened this issue Jul 7, 2022 · 4 comments · Fixed by #1187
Closed

Child transaction creation not working with the JS SDK #1186

ed-marquez opened this issue Jul 7, 2022 · 4 comments · Fixed by #1187
Assignees
Labels
bug Something isn't working

Comments

@ed-marquez
Copy link
Contributor

Description

Documentation on parent/child transactions shows the method .setNonce() for TransactionId
https://docs.hedera.com/guides/docs/sdks/transactions/transaction-id

That method is not working as expected in the JS SDK. A user reported the issue and I'm also running into the same issue.
Here's the error" TypeError: Cannot assign to read only property 'nonce' of object '[object Object]'

Steps to reproduce

The following code is a starting point for debugging:

const txId1 = TransactionId.generate(new AccountId(operatorId)).setNonce(0);
// const txId2 = txId1.setNonce(1);
const txId2 = TransactionId.fromString(txId1.toString()).setNonce(1);

console.log(`${txId1} and ${txId2}`);

Additional context

No response

Hedera network

testnet

Version

2.17 and 2.14

Operating system

No response

@ed-marquez ed-marquez added the bug Something isn't working label Jul 7, 2022
@tomachianura
Copy link

very urgent to be fixed, let us know if we can be of any help.

@ed-marquez
Copy link
Contributor Author

ed-marquez commented Jul 20, 2022

@danielakhterov @keirabee This issue needs to be reopened. This child/parent txs are still not working...

A user (@HbarSuite ) and I ran into the following error when trying two different things: TRANSACTION_ID_FIELD_NOT_ALLOWED

  • One approach was to submit the child tx to the network, then the parent. The idea is that the parent tx should complete and then trigger the child tx. That results in the error listed above.

  • The other approach tried is forming both transactions and assigning the parent and child tx id's and only executing the parent tx. That is not triggering the child tx. So wen I do a record query of the parent tx with all children included, the children field is empty - which makes sense because the network doesn't know about the child tx, which means the 1st method should work (but it doesn't)

Here's some JS sample code to help with your testing:

const txId1 = TransactionId.generate(new AccountId(operatorId)).setNonce(0);
const txId2 = TransactionId.fromString(txId1.toString()).setNonce(1);
console.log(${txId1} and ${txId2});

const transferTx2 = await new TransferTransaction()
	.addHbarTransfer(operatorId, -1)
	.addHbarTransfer(aliceId, 1)
	.setTransactionId(txId2);
const transferTxSubmit2 = await transferTx2.execute(client);
const transferRec2 = await transferTxSubmit2.getRecord(client);

const transferTx = await new TransferTransaction()
	.addHbarTransfer(operatorId, -1)
	.addHbarTransfer(aliceId, 1)
	.setTransactionId(txId1);

const transferTxSubmit = await transferTx.execute(client);
const transferRec = await transferTxSubmit.getRecord(client);

const txInfo = await new TransactionRecordQuery()
	.setTransactionId(transferRec.transactionId)
	.setIncludeChildren(true)
	.execute(client);

@janaakhterov
Copy link
Contributor

@ed-marquez I could be mistaking, but I don't think users are allowed to submit child transactions. The purpose of child transactions is strictly for services to create N transactions from one user transaction depending on what that submitted transaction is attempting to do.

cc @tinker-michaelj

@tomachianura
Copy link

we are a service, that's why we need it, it shall be available on the hashgraph JS-SDK.
So any update on this?

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.

3 participants