Basic- Sending Multi-Sig Tx
In this lesson, we will show you how to operate with multi-sig transactions.
You can manage the multi-sig wallet using quras-js module. Then let's see about this step by step.
Generate Tx
Multi-Sig wallet is the same as the general wallet. The difference is that the transaction of multi-sig wallet needs multiple signatures to be added to the blocks.
Multi-Sig wallet supports sending asset transactions and claim transactions. And generating transactions is the same as general wallet.
Basic- Sending Asset
Basic- Claiming Gas
Create Multi-Sig Tx
Multi-Sig tx needs all members pubkeys. So before you create multi-sig tx, you have to get all member's pubkeys.
Quras.api.qurasDB.getMyMultiSignMemberPubkeys(Quras.CONST.QURAS_NETWORK.MAIN, 'Ddb6XJozy18AbJx2Nnmh7Q8rVHzcSM2HYd')
.then((data) => {

    if (data.length < 1) throw new Error("There is no members");
    testTx.createMultiSign(data, 'e4fdf1d4d00bc9597d9a94bf880810221501289f96c0ac89eed1a19a334785b0'); // Sign the transaction using private key
})
.catch((error) =>{
    console.log("error");
}); 
Relay Multi-Sig Wallet Tx Data
Multi-Sig wallet contains more than one wallet and they have to send the multi-sig tx data to each other.
Quras.tx.getMultiSignTxRawData(tx) // Get raw data of multi-sig tx.
var tx = Quras.tx.Transaction.getMultiSignTx(rawdata); // Get Multi-Sig tx from raw data.
Add Signature To Multi-Sig Tx
After you receive the multi-sig wallet data, you can add your signature using private key to the transaction.
tx.joinMultiSign('8488eb4be90c73650723277c43464f751b976c0954f0cc305ed1260dbc87f7d0'); // Sign the transaction using private key
Check If Multi-Sig Tx Is Completed
When multi-sig tx has more than Math.floor(n/2) + 1 signatures, the transaction can be added to the blocks. Here n is the member count of multi-sig wallet.
tx.isCompletedMultiSign();
Complete And Broadcast Multi-Sig Tx
If the transaction has more than Math.floor(n/2) + 1 signatures, you have to send the transaction to RPC server.
tx = tx.completeMultiSignTx();

const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
rpcServer.sendRawTransaction(tx.serialize()) // Send the transaction to RPC Server.
.then((data) => {
    console.log(data);
})
.catch ((error) => {
    console.log(error);
});