# 4 - User B signs the transaction

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

{% hint style="info" %}
[Start by decoding the transaction.](https://multisig-doc.hive-keychain.com/utils/decode-transaction)
{% endhint %}

Assuming the user subscribed to the[ real-time notification](https://multisig-doc.hive-keychain.com/websocket-flow/3-user-b-receives-the-signature-request), 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>
