Make Multisig transactions with Beem without spending all day in the transaction builder.

in #steem2 years ago (edited)

This is in response to @timcliff's bounty post and @crokkon's initial solution. While Crokkon's solution is a good one and he got there first, I think it has some usability issues that are fairly easily resolved, so I thought I would write them up.

This tutorial requires the tools Beem and Beempy by @holger80, for which installation instructions can be found here.

Setting up our multiauth account

Beempy makes this surprisingly easy. We need to have the active key for the target account imported into the wallet, but then we can do this easily from the command line with the allow command, which takes several arguments. The generic form of the command is:

allow -a [Target account] --permissions [Permission] --weight [Weight] --threshold [Threshold] [Authorized account or public key]

I used the heron-themed accounts I have, with @green-heron the account being saddled with multi-sig permissions. The goal was to have two accounts with 25% weight, and five accounts with 10% weight, with a final required weight of 40%.

beempy allow -a green-heron --permission active --weight 25 tcpolymath
beempy allow -a green-heron --permission active --weight 25 herons-unlimited
beempy allow -a green-heron --permission active --weight 10 great-blue-heron
beempy allow -a green-heron --permission active --weight 10 night-heron
beempy allow -a green-heron --permission active --weight 10 goliath-heron
beempy allow -a green-heron --permission active --weight 10 snowy-egret
beempy allow -a green-heron --permission active --weight 10 --threshold 40 whistling-heron

Saving the threshold value for last is necessary because we're using the active key and also setting it to multi-auth; if we set the threshold beforehand we'll have to either import the owner key for the account or set up a multi-auth transaction in order to make the new authorizations.

This isn't necessary for setting up multi-auth on the posting key, which can be done simply by removing the "--permission active" option from the commands.

Using our multi-auth account to send transfers algorithmically

Here we do need Beem's transaction builder, but we can be fairly simple about it. First we load the required functions, initialize the Steem instance, and begin a transaction:

from beem import Steem
from beem.transactionbuilder import TransactionBuilder
from beembase.operations import Transfer

tx = TransactionBuilder(steem_instance=stm)

Then we build our basic transfer transaction and add it to the transaction object, which Beem makes very easy and self-explanatory:

transfer={"from": "green-heron", "to": "tcpolymath", "amount": "1 STEEM", "memo": "multisig transaction example"}

After this, we need to get the signatures, and sign the transaction. If we have them all available in our Beem wallet this is again very simple:

tx.appendSigner('herons-unlimited', 'active')
tx.appendSigner('great-blue-heron', 'active')
tx.appendSigner('night-heron', 'active')

As long as we're signing things algorithmically, where the same program would be attaching all of the signatures - say, for instance, we're a front end collecting signatures from the users - this method works well even when we pass the transaction object tx throughout our program and sign it at different times. It is possible to pass the transaction manually between humans in different locations extremely clumsily by exporting the signed transaction as a JSON and having each person sign it individually, but practically it's hard to see a real-life application for that process. It would be easier to spin up a simple web front end to get the necessary signatures than to do the manual process more than about three times.

However we've acquired the necessary signatures, once we have them we simply sign and broadcast the transaction:


And then we're done. It's actually surprisingly easy. You can see my example transaction here.



You're absolutely right, the part of adding authorities is already handled by beempy. Even if it requires a few more commands, it comes with beem out-of-the-box. I see @holger80 is active on the repository this evening and I also tried to make a PR to get the full set of steps integrated into beempy. I'm pretty sure we will have this properly integrated very soon :)

I fixed the sign and broadcast operation of beempy now. It was some work, let's see what will happen with the bounty...

@buildteam and @steemvoter are proud to award you a Steemvoter Guild vote for your efforts in contributing to the multisig bounty.

To listen to the audio version of this article click on the play image.

Brought to you by @tts. If you find it useful please consider upvoting this reply.

Hi @tcpolymath!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 4.725 which ranks you at #1483 across all Steem accounts.
Your rank has dropped 2 places in the last three days (old rank 1481).

In our last Algorithmic Curation Round, consisting of 207 contributions, your post is ranked at #17.

Evaluation of your UA score:
  • Some people are already following you, keep going!
  • The readers appreciate your great work!
  • Good user engagement!

Feel free to join our @steem-ua Discord server

This post has been included in today's SOS Daily News - a digest of all you need to know about the State of Steem.

You got a 52.34% upvote from @ocdb courtesy of @tcpolymath!

@ocdb is a non-profit bidbot for whitelisted Steemians, current max bid is 12 SBD and the respective amount in Steem.
Check our website for the whitelist, queue and delegation info. Join our Discord channel for more information.

If you like what @ocd does, consider voting for ocd-witness through SteemConnect or on the Steemit Witnesses page. :)

This post has received a 1.56 % upvote from @drotto thanks to: @sbi-booster.


This post has been granted a 100% upvote, courtesy to @wokeprincess, from BlissFish!
Enjoy the Bliss!

Join us on Discord!
Upvote this post to help the minnows win a bigger upvote!

Congrats @tcpolymath, you are one of the finalists for the Multisig bounty, BuildTeam will be sponsoring a Steemvoter Guild vote in addition to any other bounty you may receive. Incoming shortly.