MultiSafe is a shared crypto wallet for managing Stacks (STX) and Bitcoin (BTC).

Overview

MultiSafe

MultiSafe is a shared crypto wallet for managing Stacks (STX) and Bitcoin (BTC).

Deploy a MultiSafe

https://app.multisafe.xyz/

Features

Current supported features:

  • Send, transfer and hold STX
  • Supports up to 20 owners

Future updates (coming soon):

  • User-friendly app
  • SIP-009 Non-fungible token and SIP-010 Fungible token support
  • Native Bitcoin (BTC) support

Security

  • Please be aware that the code hasn't been audited by an independent security team. Use at your own risk.
  • We are planning a security audit for June 2022
  • We would love your help testing our code. Please report any bugs as a Github issue.

Clarity Usage

Requires Clarinet

Install Clarinet: https://github.com/hirosystems/clarinet

MultiSafe is written in Clarity and therefore requires you to install Clarient locally on the command line. Type the following command to check that you have Clarinet installed:

$ clarinet --version

Download MultiSafe

  1. Clone the repo:
$ git clone https://github.com/Trust-Machines/multisafe.git && cd multisafe
  1. Run the unit test to confirm all the tests passed and everything is working:
$ clarinet test
  1. Open the Clarinet console in order to interact with the contract
$ clarinet console

Setup the first MultiSafe owners

Go to /contracts/safe.clar. At the bottom of that contract you'll see a list with three sample owners. These are the default Clarinet wallets that you can use for testing locally in Clarient.

(init (list 
    'ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5 
    'ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG 
    'ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC
) u2)

If you'd like to deploy to mainnet/testnet update those wallet addresses with your own wallet addresses.

Get Safe Owners

(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe get-owners)

In the example above ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe is your safe's contract name.

get-owners will return [ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5, ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG, ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC]

Get minimum confirmations

(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe get-min-confirmation)

The Clarinet console demo will return u2

In this example “u2” tells us that we need a minimum of 2 confirmations in order to approve a transaction

Add new users

  1. Change the transaction sender to “wallet_1”
::set_tx_sender ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
  1. Add a new user to the wallet. In this example, we add “wallet_9” to MultiSafe.
(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe submit 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.add-owner 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe 'STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6 u0)

ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM = deployer 'STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6 = wallet_9

  1. If you “get-owners” you’ll see that there are still only 3 owners. In order to confirm the 4th owner you will need to switch to “wallet_2” or “wallet_3” (the other owner”) and approve the transaction.
(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe get-owners)

Returns: [ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5, ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG, ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC]

  1. Change owner to wallet_2
::set_tx_sender ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG
  1. As wallet_2 owner, now you can approve the 4th new owner
(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe confirm u0 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.add-owner 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe)
  1. Call “get-owners” again and you will see the 4th owner has been added
(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe get-owners)

Returns: [ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5, ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG, ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC, STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6]

Send STX to the MultiSafe

If you are the wallet_3 owner (ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC) then the following command will allow you to send STX from your wallet to the MultiSafe

(stx-transfer? u5000 'ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe)

::get_assets_maps will show you that the STX has been transfered into the .safe contract

Send STX from MultiSafe to a new wallet

In this example, using Clarinet console, we will send STX from MultiSafe to "wallet_7"

  1. Send STX to wallet_7

Assuming you are an owner — in this example, you will send 1000 uSTX from the MultisSafe to wallet_7 (ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ).

(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe submit 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.transfer-stx 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe 'ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ u1000)
  1. Change owner to wallet_2
::set_tx_sender ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG
  1. Wallet_2 can now confirm the transaction
(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe confirm u1 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.transfer-stx 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe)

MultiSafe now has -1000 uSTX, and wallet_7 +1000 uSTX

API Reference

Owner only functions

The following function can be run by only safe owners:

submit (executor <executor-trait>, safe <safe-trait>, param-p principal, param-u uint) => (response uint)

confirm (tx-id uint, executor <executor-trait>, safe <safe-trait>) => (response bool)

revoke (tx-id uint) => (response bool)

Safe only functions

The following functions can be run by only safe contract itself and requires the minimum number of confirmations:

add-owner (owner principal) => (response bool)

remove-owner (owner principal) => (response bool)

set-min-confirmation (value uint) => (response bool)

Views (Read only functions)

get-version() => string-ascii

get-owners() => list

get-min-confirmation() => uint

get-nonce() => uint

get-transaction (tx-id uint) => tuple

get-transactions (tx-ids (list 20 uint)) => list

Comments
  • [BUG] Owners can set min-confirmation > 20 and by doing so they can lock safe permanently.

    [BUG] Owners can set min-confirmation > 20 and by doing so they can lock safe permanently.

    https://github.com/Trust-Machines/multisafe/blob/e5a3768e9cdbd65979bf076f4d88f8eb53f9b21f/contracts/safe.clar#L124-L130

    There should be one more asserts! that ensures value is less than or equal 20.

    bug 
    opened by LNow 5
  • FT and NFTs do not display correctly on testnet MultiSafes because metadata is disabled

    FT and NFTs do not display correctly on testnet MultiSafes because metadata is disabled

    image

    Thinking this is more of an issue with Stacks API issue for testnet and that metadata is disabled on it, but logging here anyway as well since the presence of it makes it significantly more difficult to test the MultiSafe with various assets (since you can't differentiate them in the UI).

    opened by wbnns 4
  • Changing `min-confirmations` affects all transactions

    Changing `min-confirmations` affects all transactions

    When we change min-confirmations from X to Y it affects both on going and future transactions. I think that each transaction should have its own fixed min-confirmation threshold that is set up when transaction is created.

    enhancement 
    opened by LNow 4
  • Crucial functions are secured with `tx-sender`

    Crucial functions are secured with `tx-sender`

    It is not a bug per-se, but securing crucial functions with just tx-sender can be considered as security flaw.

    Depending on your security strategy and approach I would suggest securing those functions with contract-caller or add 1uSTX transfer to crucial functions in order to enforce the need to construct TX with post-conditions.

    Reference: https://github.com/LNow/clarity-notes/blob/main/security/function-calls.md

    discussion 
    opened by LNow 3
  • Add 'get-owners' or 'get-info' function to safe-trait

    Add 'get-owners' or 'get-info' function to safe-trait

    Adding 'get-owners' or 'get-info' function to safe-trait would allow on-chain verification of safe owner from other clarity contracts.

    e.g. In LEOS project, this will help verify if a user have created multi-safe contract, is in the list of owners of that contract or not.

    enhancement 
    opened by leosguru 2
  • fixing test script to allow clarinet 0.31.1

    fixing test script to allow clarinet 0.31.1

    Made some changes in the test file; all tests do not pass yet ; some of them return different values than expected and some others have a runtime error; i plan to look into these tests next; 7 tests pass although for one of them i had to change the return values expected

    opened by fanjum11 2
  • Deposit not showing in safe

    Deposit not showing in safe

    I deployed my first safe to mainnet and deposited 5 STX but it doesn't appear in the UI:

    • Safe deployment: https://explorer.stacks.co/txid/0x1bd774bf557059fef27b76e6f52fd9dfbc9967533a6951657b23dcc7289d670d?chain=mainnet
    • Deposit: https://explorer.stacks.co/txid/0xc86b7ed4b01afc54edfb6b76f393147e650a357ad016ab005975ae0b1575ff6f?chain=mainnet
    image
    opened by markmhx 2
  • License is missing from this repository and needs to be added

    License is missing from this repository and needs to be added

    @talhasch

    Hello, we just observed there is no License file in this repository -- we're interested in developing on top of MultiSafe and extending it via code contributions here but can't do so if there is no license defined since the opaqueness of not having one creates an undefined state of what is permissible use of this code.

    Cc: @muneeb-ali

    opened by wbnns 1
  • Open sourcing frontend code for app.multisafe.xyz

    Open sourcing frontend code for app.multisafe.xyz

    Does this initiative exist? Might be worth considering adding to this repo (or its own separate repo if that is preferred).

    This will enable people to contribute to improving the UI, UX, etc. Speaking for myself, I noted some issues + opportunities and would be interested.

    Example issue:

    On the Transactions page, when loaded by for review an owner that was not the transaction originator, there is no REVOKE button. So hypothetically speaking, let's say one of the owner accounts was compromised and an unauthorized transaction was made by it. There is no revoke button for the other owners.

    image

    opened by wbnns 1
  • Use send-many-memo for STX transfers

    Use send-many-memo for STX transfers

    opened by talhasch 1
  • [BUG] One

    [BUG] One "transaction" can be executed multiple times.

    If safe have multiple owners, then one transaction can be executed more than once.

    # switch to one of the owners
    ::set_tx_sender ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
    # create new "transaction"
    (contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe submit 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.set-min-confirmation 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe .tx-sender u3)
    
    # change to 2nd owner
    ::set_tx_sender ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG
    # confirm transaction => 1st execution
    (contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe confirm u0 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.set-min-confirmation 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe)
    
    # change to 3rd owner
    ::set_tx_sender ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC
    # confirm transaction => 2nd execution
    (contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe confirm u0 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.set-min-confirmation 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.safe)
    

    Add here: https://github.com/Trust-Machines/multisafe/blob/e5a3768e9cdbd65979bf076f4d88f8eb53f9b21f/contracts/safe.clar#L237-L244 one extra assert:

    (asserts! (not (get confirmed tx)) ERR-TX-CONFIRMED)
    
    opened by LNow 1
  • In UI there it is not possible to revoke a pending, unauthorized transaction

    In UI there it is not possible to revoke a pending, unauthorized transaction

    On the Transactions page, when loaded by for review an owner that was not the transaction originator, there is no REVOKE button. So hypothetically speaking, let's say one of the owner accounts was compromised and an unauthorized transaction was made by it. There is no revoke button for the other owners.

    image

    opened by wbnns 3
Owner
Trust Machines
Trust Machines
A simple CLI Tools to Empty Crypto Wallet & Send to your other Wallet Address

A simple CLI tools to empty crypto wallet & send to your other wallet, Build with Nodejs using Ethers API Run Locally Clone the project git clone ht

Raihan Ramadhani 11 Dec 29, 2022
Bitcoin terminal tracker is a terminal app which allow you to track bitcoin price from your terminal

BTC Terminal Tracker Bitcoin terminal tracker is a terminal app which allow you to track bitcoin price from your terminal. In this version (V1.2) I ch

Sina yeganeh 9 Jul 27, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Trustless BTC-ETH exchange.

# Silver Portal ⚠️ This is an experimental prototype for testnet use only. The basic idea Silver Portal lets you swap ether and bitcoin, trustlessly.

DC 24 Sep 2, 2022
CLI utility that broadcasts BTC, ETH, SOL, ZEC & XMR transactions through TOR using public block explorers

tx-tor-broadcaster CLI utility that broadcasts BTC, ETH, SOL, ZEC & XMR transactions through TOR using public block explorers. Provides a great degree

Paul Miller 58 Dec 25, 2022
Create, sign & decode BTC transactions with minimum deps.

micro-btc-signer Create, sign & decode BTC transactions with minimum deps. ?? Small: ~2.2K lines Create transactions, inputs, outputs, sign them No ne

Paul Miller 19 Dec 30, 2022
A Multichain crypto wallet library that supports Ethereum, Solana and other EVM compatible blockchains.

Multichain Crypto Wallet A Multichain crypto wallet library that supports Ethereum, Solana and other EVM compatible blockchains. Installation npm inst

Abdulfatai Suleiman 117 Jan 2, 2023
Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

null 2 Jan 5, 2022
🌈 Put a date and a crypto, optionally a quantity of that crypto, to see how much has augmented/increased in dollars & percentage

crypif Put a date and a crypto, optionally a quantity of that crypto, to see how much has augmented/increased in dollars & percentage Figma I still ha

Eliaz Bobadilla 8 Apr 4, 2022
Nami Wallet is a browser based wallet extension to interact with the Cardano blockchain.

Nami Wallet Nami Wallet is a browser based wallet extension to interact with the Cardano blockchain. It's an open-source project and built by Berry Po

Berry 335 Dec 29, 2022
Crypto-tracker - Get crypto currency data in one click. Followed by a few more clicks.

https://crypto-tracker-ayaanzaveri08.vercel.app/ Crypto Tracker Crypto Tracker tracks crypto with the CoinGecko API. This app uses the React framework

Ayaan Zaveri 0 Apr 30, 2022
A simple API to interact with Stacks and CityCoins data.

CityCoins API Probably Nothing CF Workers + IttyRouter + micro-stacks + TypeScript ...and it feels good! Things to Note uses simple typed responses an

CityCoins 9 Oct 10, 2022
A simple project of task list! - Stacks HTML, CSS and JS(pure)

Stacks used This project The purpose of this was to recreate a To do list project using the concepts of JavaScript, HTML and CSS and also storing the

Alisson Peixer 3 Sep 20, 2022
The one DAO to rule them all. A modular DAO written in Clarity for the Stacks blockchain.

ExecutorDAO The one DAO to rule them all. ExecutorDAO is designed to be completely modular and flexible, leveraging Clarity to the fullest extent. The

Marvin 31 Oct 5, 2022
Stacks Voice is a reference project that builds on the SIP018 signed structured data standard to create an accountless internet forum.

Stacks Voice Stacks Voice is a reference project that builds on the SIP018 signed structured data standard to create an accountless internet forum. Th

Clarity Innovation Lab 4 Dec 21, 2022
A Stacks DeFi app that automates covered call writing to generate sustainable, risk-adjusted yield.

?? Options Vault ?? A Stacks DeFi app that automates covered call writing to generate sustainable, risk-adjusted yield. Options vaults allow you to al

null 15 Nov 16, 2022
Vaultacks lets users store files off-chain on Gaia. Files are encrypted by default but also can be made public and shared

Vaultacks Vaultacks is built on the Stacks Chain. It lets users upload files to Gaia, a off-chain data storage system. Vaultacks currently uses the de

Anish De 5 Sep 14, 2022