Send Raw Transactions to Orchestrate

Goal

  • Submit already crafted transactions directly to Tx-Sender worker on Orchestrate;
  • Use PegaSys Orchestrate from tx-sender worker and forward;

In cases where we want or need to use an external service (e.g. hardware wallets) to submit already crafted transactions, we can still use Orchestrate to orchestrate the rest of their life cycle, from sending it to a specific blockchain, waiting asynchronously for the confirmation of them being mined, decoding, and recovering when needed.

Info

Please note that balance check and micro-crediting of addresses will not be done by Orchestrate when sending raw transactions. Check the Faucet’s concept to know more.

How to

In order to do so, we will use as usual the SDK, but we will need to:

  1. Initialize a new Producer; and
  2. Submit different set of fields for Producer Payload.

1. Initialize a new Producer

This step will allow us to send transactions to the tx-sender worker directly. For doing so:

const producer = await broker.producer("topic-tx-sender", [options])

options object (optional): see Kafka-node producer options.

2. Producer Payload for Raw Transactions

For sending raw transactions, we will need to pass the following fields to the producer.send method:

  • chainId
    • string(number)
    • The chain id of the blockchain sending the transactions to. If more than one, separated by commas.
    • Example: ‘3’, ‘42’


  • raw
    • string(hex)
    • Raw representation of a transaction, with signatures attached.
    • Example: ‘0xf86c258502540be40083…7cc31c6686b670bd85cbc6da2d6e85’


  • hash
    • string(hex)
    • Raw value of a hash, generated with ethereum compatible hash function keccak256, applied to the raw field.
    • Example: ‘0x58e5a0fc…4e44ba6f5eb8ba1b7eb’


  • metadata
    • string (hex)
    • This is an optional field, here you can include as many custom fields as you find useful to track.
    • Example:
metadata: {
          extra: {
            myfield1: 'mypersonalfieldvalue1', // Interesting information to track on Orchestrate logs
            myfield2: 'mypersonalfieldvalue2', // Felt like tracking this
          },

Example

```
const producerPayload = {
    chainId: '42',
    Raw: '0xf86c258502540be40083...7cc31c6686b670bd85cbc6da2d6e85',
    Hash: '0x7e654d251da770a068413677967f6d3ea2fea9e4'
}
const tx = await producer.send(producerPayload)
```

Warning

All other fields of the Producer Payload will not be used.