Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Separate creating, signing, transmitting transactions. #756

Closed
MoMannn opened this issue Mar 17, 2023 · 3 comments
Closed

Separate creating, signing, transmitting transactions. #756

MoMannn opened this issue Mar 17, 2023 · 3 comments
Labels

Comments

@MoMannn
Copy link

MoMannn commented Mar 17, 2023

Feature Request

Not 100% sure if this isn't already possible just wanted to make sure this can be done. From what I searched there was no examples of this.

Suggestion

Developer should be able to completely separate the process of creating, signing, transmitting and confirming a transaction.
So on one side the transaction itself for a specific chain with the metadata can be constructed then serialised. Somewhere else this transaction can be parsed and signed and serialised again. Another service can handled signed transaction to push them on chain and a completely x service can then check/validate if that transaction was accepted into the chain.

Motivation

Consider a service creating 10000 transactions on chain per hour. Like an exchange or something similar.
So it's very important that the signing process occurs somewhere with very limited access in a secure manner with high validations. While the transaction construction can happen anywhere and since the signing service does not need to be aware of the chain he is signing for there is no need for metadata. After the transaction is signed you want to push it on chain. But if you are performing tons of transactions you don't want to thing one by one waiting for transactions to be accepted. But you can have a service just pushing the transactions not waiting for them to get accepted into a block since there are tons of transactions happening.

Use Cases

  • Security of signing keys.
  • Services performing high amount of transactions.
  • Separating chain specific logic of transaction construction with signing the transaction which is the same for every chain.
@robocapi robocapi added this to Capi Mar 17, 2023
@harrysolovay
Copy link
Contributor

harrysolovay commented Mar 17, 2023

Hi @MoMannn. I believe this is currently possible... but let's be certain:

  1. creating

Construct the extrinsic

const call = Balances.transfer({
  value: 12345n,
  dest: billy.address,
})
  1. signing

Sign it and collect the hex representation for later usage

const signedHex = await call
  .signed(signature({ sender: alexa }))
  .hex()
  .run()
  1. submitting

Use that hex representation (ostensibly in another env or run) to describe the submission of the signed extrinsic.

const txStatus = Rune
  .constant(hex.decode(signedHex))
  .into(SignedExtrinsicRune, chain)
  .sent()
  1. confirming

As for confirming, we can do this in a number of ways. One way would be to iterate over blocks within a given range and compare the extrinsic hexes. Another would be to make use of txStatus (and in doing so, initiate the submission).

const finalizedHash = await txStatus.finalizedHash().run()

Please confirm that this is what you're looking for. If not, we can certainly improve the API such that it meets your needs.

Speaking of improving the API, perhaps we should have a static ofHex method on SignedExtrinsicRune to simplify this use case.

- const txStatus = Rune
-   .constant(hex.decode(signedHex))
-   .into(SignedExtrinsicRune, chain)
+ const txStatus = SignedExtrinsicRune.ofHex(signedHex, chain)
   .sent()

@MoMannn
Copy link
Author

MoMannn commented Mar 17, 2023

This looks like what I would need, just looking if things can get serialised. So if you can serialise call send it to another microservice then parse to recreate the call object to sign and serialise again...

For confirming yeah getting extrinsic then having an outside indexer is probably the way to go.

@harrysolovay
Copy link
Contributor

Great! Please don't hesitate to follow up with any other questions / rough edges (as we'll want to smooth them out before 0.1.0).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Done
Development

No branches or pull requests

2 participants