> For the complete documentation index, see [llms.txt](https://multisig-doc.hive-keychain.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://multisig-doc.hive-keychain.com/utils/encode-transaction.md).

# Encode Transaction

All multisig requests must be encrypted through Keychain to ensure that only the valid initiator and potential signers have access to them. Therefore we provided a utility function to encode as follows:

### Encode Transaction

{% hint style="info" %}
Begin by encapsulating the operation using [hive-tx Transaction()](https://github.com/mahdiyari/hive-tx-js#:~:text=axiosAdapter%20%3D%20fetchAdapter-,Create%20transaction%3A,-const%20tx%20%3D), then integrate it into the 'IEncodeTransaction' object.
{% endhint %}

<pre class="language-typescript"><code class="lang-typescript">const multisig = HiveMultisig.getInstance(window: Window,options?:MultisigOptions); 

const op: Hive.TransferOperation = [
      'transfer',
      {
        from: 'joe',
        to: 'jane',
        amount: 1,
        memo: 'payment',
      },
    ];

const _hiveTx = new hiveTx.Transaction();
const transaction  _hiveTx.create([op], getSeconds(expiration))
const txEncode: IEncodeTransaction = {
          transaction: transaction,
          method: 'posting',
          expirationDate: expiration,
          initiator: 'joe',
        };

<strong>const encodedTx = await multisig.utils.encodeTransaction(txEncode)
</strong></code></pre>

The `multisig.utils.encodeTransaction()` function will automatically assign the encoded message to all potential signers. This process encodes the transaction through Keychain and returns the 'RequestSignatureMessage' object.

### IEncodeTransaction object

<table><thead><tr><th width="177.33333333333331">Property</th><th width="328">Description</th><th>Type</th></tr></thead><tbody><tr><td>transaction</td><td>The transaction that is being initiated. Contains the operation and expiration wrapped using <code>hive-tx.Transaction()</code> </td><td>hive-tx Transaction</td></tr><tr><td>method</td><td>The type of key subscribing to the WebSocket. Can be "Active" or "Posting"</td><td>KeychainKeyTypes enum</td></tr><tr><td>expirationDate</td><td>The expiration date of the multisig request. Must be minimum of 10 minutes and maximum of 1 hour from the time of creatio</td><td>Date or string</td></tr><tr><td>initiator object</td><td>Initiator details corresponding to the method. Including username, public key, and weight. </td><td>username: string<br>publicKey: string<br>weight: number</td></tr></tbody></table>
