Skip to main content
Version: 19.0.0

Forger

Operations must be forged and signed before it gets injected into the blockchain. Forging is the act of encoding your operation into its binary representation.

Forger implementations

Forging can be done either remotely using the RPC node or locally. Note that forging locally is considered a safer option. If forging remotely, it is important to ensure that the node is trusted.

Since version 12 of Taquito, an instance of LocalForger is set by default on the TezosToolkit. The LocalForger is implemented in the @mavrykdynamics/taquito-local-forging package, which provides developers with local forging and parsing functionalities.

Changing the underlying forger

Composite forger

Using a Composite forger can provide additional security because the binary returned by the forger instances will be compared and if there is a mismatch, a ForgingMismatchError will be thrown. Here is an example of a composite forger using the LocalForger and the RpcForger.

import { TezosToolkit, RpcForger, CompositeForger } from '@mavrykdynamics/taquito';
import { localForger } from '@mavrykdynamics/taquito-local-forging';
const tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
const rpcForger = tezos.getFactory(RpcForger)();
const composite = new CompositeForger([rpcForger, localForger]);
tezos.setForgerProvider(composite);

RpcForger

When the node is trusted, the forger can be set to an instance of RpcForger as follow:

import { TezosToolkit, RpcForger } from '@mavrykdynamics/taquito';
const tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
tezos.setForgerProvider(Tezos.getFactory(RpcForger)());

Provide detailed feedback