> 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/websocket-flow/4-user-b-signs-the-transaction.md).

# 4 - User B signs the transaction

The received signature requests from either [subscribing to Websocket](/websocket-flow/1-users-connect-to-the-websocket.md) or subscribing to [real-time notification](/websocket-flow/3-user-b-receives-the-signature-request.md) can be signed through the following process.

{% hint style="info" %}
[Start by decoding the transaction.](/utils/decode-transaction.md)
{% endhint %}

Assuming the user subscribed to the[ real-time notification](/websocket-flow/3-user-b-receives-the-signature-request.md), they can include the decoding and signing process inside the callback function of`multisig.wss.onReceiveSignRequest()` as follows:

```typescript

const signRequestCallback:SignatureRequestCallback =  async (message: SignatureRequest) => {
  
  const data: IDecodeTransaction = {
         signatureRequest:message,
         username: 'user-b'
      };
  const decodedTx:ITransaction = await multisig.utils.decodeTransaction(data);
  
  if(decodedTx){
    const sign: ISignTransaction = {
      decodedTransaction: decodedTx.transaction,
      signerId: decodedTx.signer.id,
      signatureRequestId: decodedTx.signatureRequestId,
      username,
      method: decodedTx.method,
    };
  
    const signatures: string[] = await multisig.wss.signTransaction(sign);
  }
};

await multisig.wss.onReceiveSignRequest(signRequestCallback);
```

The `multisig.wss.signTransaction()`returns an array of signatures. When this array contains one or more signatures, it means the transaction is ready for broadcasting otherwise not when it is empty.

### ISignTransaction object

<table><thead><tr><th>Property</th><th width="280.3333333333333">Description</th><th>Type</th></tr></thead><tbody><tr><td>decodedTransaction</td><td>The decoded transaction obtained from <code>multisig.utils.decodeTransaction()</code></td><td>dhive Transaction</td></tr><tr><td>signerId</td><td>A signer id assigned by the backend</td><td>number</td></tr><tr><td>signatureRequestId</td><td>The signature request id assigned by the backend.</td><td>number</td></tr><tr><td>username</td><td>username of the signer</td><td>string</td></tr><tr><td>method</td><td>The keyType used when initiating the transaction </td><td>KeychainKeyTypes enum</td></tr></tbody></table>
