1

I wonder if it's possible to create smart contract transactions and them send them to a over the network without using the .send method...? I need to group and sort and some things (from different users) before sending to an RPC / mempool

Create & sign -> Send to magic API -> Magic API does some stuff stuff -> RPC

Question from Asbjorn in Slack.

1 Answer 1

1

You can try to use the Local Forging Package to forge a transaction locally, and send the signed bytes over to an intermediate server, which can later inject them via an RPC node.

For example, following Taquito's current documentation:

Preparing a Transaction Operation

import { TezosToolkit } from '@taquito/taquito'

const Tezos = new TezosToolkit(RPC_URL);

// The PrepareProvider returns a 'PreparedOperation' type object
const prepared = await Tezos.prepare.transaction({
  source: SOURCE_PKH,
  to: DESTINATION_PKH,
  amount: 5
});

// The PreparedOperation type object needs to be converted into a forgeable type (ForgeParams)
const forgeable = await Tezos.prepare.toForge(prepared);

Forging the Transaction Operation

const forger = new LocalForger();
const forgedBytes = await forger.forge(forgeable);

Signing the Operation

After the transaction operation has been forged, it can be signed as such:

const signed = await Tezos.signer.sign(forgedBytes, new Uint8Array([3]))

The signed bytes can then transmitted to an intermediate server, via some API made for that purpose.

The server can then inject the operation into the blockchain.

Injecting the Operation

const op = await Tezos.rpc.injectOperation(signed.sbytes);

Your Answer

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