4

Generating transaction via ApiPromise through api.tx.xxx method generated a SubmittableExtrinsicFunction object. Which has a toJSON() function that return what I would call a raw transaction.

Is there any way I can recreate a SubmittableExtrinsicFunction from the raw transaction?

Also if you sign the SubmittableExtrinsicFunction you get a Submittable object. Which again has a toJSON() function the question again is how to go from json result back to Submittable object.

1 Answer 1

5

The best way to do the serialization here is to use toHex() instead of toJSON().

Take a look at the example of how to do it:

const transfer = await api.tx.balances.transfer(BOB, 100000000000);
// Serialize
const serializedTransaction = transfer.toHex();
// Deserialize
const deserializedTransaction = api.tx(serializedTransaction);

Now you have the SubmittableExtrinsic again and you can send it:

const result = await deserializedTransaction.signAndSend(alice);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.