Standard TON Multisig wallet smart contract and correpsponding Fift interaction scripts.
(n, k)
-multisig wallet is a multisignature wallet with n
private keys holders, which accepts requests to send messages if the request (aka order, query) collects at least k
signatures of the holders. An order can have up to three unique messages to send in a single transaction. In contrast to some other blockchains, a holder doesn't need to have own wallet. It is possible to control the multisig using only the keys, while the fee is paid from multisig's own funds. Also multisig supports onchain voting for orders. Namely, if an order sent to multisig has at least one correct signature but less than k
, then it is saved to contract data to allow collecting missing signatures later. Also any order may have a time limit, after which it is expired.
Compile the contract with func -SPA stdlib.fc multisig-code.fc -o multisig-code.fif
.
Suppose you have set FIFTPATH variabale to fift library directory. Then you can run the scripts with command fift -s <script-name> <args>
. When no args are specified, a script displays short help message with info of its usage.
- You can generate one or several keys with
new-key.fif
script manually, or generate a batch or keys withgenerate-keypairs.fif
. - Having a text file with list of serialized public keys (in "user-friendly" format) you can create an init message for a new mulstisig wallet with
new-mulstisig.fif
script. - After the contract is activated, you may want to create one or several internal messages to send with
create-msg.fif
script. - Having message(s) to send you can group it to a new order with
create-order.fif
script. - You can add a signature to the order with
add-signature.fif
script, provided you have corresponding private key. Note that the index of the key is the number of line in public keys text file at which it is presented (numbering from 0). - Having two orders with the same messages to send, but (potentially) different signatures lists, you can unite the lists with
union-signatures.fif
script. - When you want to send the order to the contract, you should create the external message with
create-external-message.fif
script. Note that it requires a private key to ensure authenticity ot the signatures list. Your signature will also be counted as a vote for the order. - Send the message and enjoy your order being processed.
Also you can clear signatures list with clear-signatures.fif
and show indexes of parties signed the order with show-signed-by.fif
. show-msg.fif
and show-order.fif
can be used for displaying messages and orders in human-readable format.
-
Originally written by the Telegram team and located in TON monorepo at https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/multisig-code.fc.
-
The commit
3aa7f3f6091690c472903021ecbae348875ad6cd
of the master branch of this repo is identical to the last multisig change in the TON monorepo (master branch, commit9f351fc29f7a0e8937897a873f62fc35418fdcb1
(24.03.2020)). -
@akifoq wrote Fift scripts
-
@akifoq fixed a minor bug in a
get_messages_unsigned
,get_messages_unsigned_by_id
get-method (doesn't affect onchain behaviour). -
@akifoq added additional check for proposed query to prevent infinite repeating of correctly signed by majority of holders, but otherwise incorrect (due to a bug in offchain interface, for instance) order, which could lead to loosing unlimited amount of funds to blockchain fees.