Developers can effortlessly initiate multi-signature transactions using SDKs. This article will utilize the account PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew as an illustration to employ Pollux web SDK for constructing a multi-signature transfer transaction on the YUVi test network.
The steps for multi-signature transaction are as follows::
Modify account permission
Query account permission
Select permission and create transaction
Perform the multi-signing
Check transaction's sign weight
Check approved list
Broadcast transaction
Modify Account Permission
Update the account permission through POXscan or by utilizing the wallet's accountpermissionupdate API. In this instance, an additional active permission titled "NewAddedActivePermission" is introduced to the account PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew via Poxscan.
2. Query Account Permission
Use the wallet/get account API to query account permission information:
In the obtained outcome, it is evident that the account PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew possesses an Active authorization identified by the ID 3. The threshold for this authorization is 2, and it holds authority over two accounts, each assigned a weight of 1.
3. Select Permission and Create Transaction
In this instance, we opt for the active permission associated with ID 3 of PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew to compose a multi-signature POX transfer transaction through the PolluxWeb.transactionBuilder.sendPox method.
var unsignedTransaction = await poxWeb.transactionBuilder.sendpox('PVqTEPUPiTxhzaSnD9xXEvarUQooLibkXM', 10000000, 'PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew',{permissionId: 3});
Sender: the owner_address in the transaction, that is PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew. When constructing a transaction, there's no need to concern yourself with the transaction creator; simply designate the sender of the POX in the transaction to the multi-signature address. Multi-signature permission: Opt for the active permission identified as 3 for PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew - {permissionId: 3}.
4. Perform the Multi-Signing
The Active permission of PTBHseaG95LN7uMzbAVPeSAivGjw3iTeew with id 3 is authorized to "PW5Kzigm3yoKR2h2RWLSFLFeWZjL5SjHxg" and "PUTRPJVWcfKwpF3uxxdLPfrzBNENFC3Ruh". These two accounts can use PolluxWeb.pox.multiSign API to sign the transaction.
```json
{
"visible": false,
"txID": "507efa43ef267005cd384f74f8bc2b2d6e807807144144fd01f194f36ddfb93a",
"raw_data": {
"contract": [ [Object] ],
"ref_block_bytes": "e5b2",
"ref_block_hash": "c565570704ef1e7a",
"expiration": 1700538150000,
"timestamp": 1700538091138
},
"raw_data_hex": "0a02e5b22208c565570704ef1e7a40f0d8e3ffbe315a6a080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541cbe603e1f0ac26c50bb795d8d54a95706c64b2e2121541d9eb1101ba37f55c436cc668ed1ac18d23d6c6631880ade204280370828de0ffbe31",
"signature": [
"9f51d0839b8dd10b5a6bc3b043f6246d5c8a00a79839a52b0987ee337911b3375d0376c3b1aef3a7ffa0779a2e3d0cb95380294e6b934f738964a0551675d45501",
"2bc656a647cbd9de932bf63909f73aacf2e97f0c771bd72b69654f6242a152e8ecbc8712ad59fe95a280cffbed5ef2dd28777dc27267976fe0c6374e00ba355c01"
]
}
```
Note: I left the `[Object]` as is, assuming it represents a nested object. Please replace it with the actual content if you have it.
5. Check Transaction's Sign Weight
Through the polluxweb.POX.getSignWeight method, you can not only check the weight required by the permission, but also check how many addresses are currently signed and the current weight. It can be called during or after the multi-signature process.
var signWeight = await poxWeb.POX.getSignWeight(signedTransaction);