Skip to content

Allows multiple parties to agree on transactions before execution base on NewChain.

License

Notifications You must be signed in to change notification settings

newtonproject/MultiSignatureWallet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiSignatureWallet

MultiSignatureWallet project contains the following:

  • Deploy Multisignature wallet contract
  • Submit, confirm, execute, revoke or check transactionId
  • Get basic information
  • Manage owners, dailyLimit and required

Table of Contents

QuickStart

Download from releases

Binary archives are published at https://release.cloud.diynova.com/newton/MultiSignatureWallet/.

Building the source

Windows

install:

git clone https://github.com/newtonproject/MultiSignatureWallet.git && cd MultiSignatureWallet && make install

run MultiSignatureWallet:

%GOPATH%/bin/MultiSignatureWallet.exe

Linux or Mac

install:

git clone https://github.com/newtonproject/MultiSignatureWallet.git && cd MultiSignatureWallet && make install

run MultiSignatureWallet:

$GOPATH/bin/MultiSignatureWallet

Usage

Contract

Use commands go generate or abigen to generate MultiSigWalletWithDailyLimit.go from MultiSigWalletWithDailyLimit.sol.

abigen --sol contract/MultiSigWalletWithDailyLimit.sol --pkg cli --out cli/MultiSigWalletWithDailyLimit.go

tips:

  1. the version to compiler used is solc-v0.4.15+commit.8b45bddb
  2. the version of newton MultiSignatureWallet is solc-v0.4.24+commit.e67f0147

Commandline

Help

Use command MultiSignatureWallet help to display the usage.

Usage:
  MultiSigWallet [flags]
  MultiSigWallet [command]

Available Commands:
  account     Manage NewChain accounts
  broadcast   Broadcast sign transacion hex in the signTxFilePath to blockchain
  build       Build transaction
  confirm     Confirm transactionId
  deploy      Deploy NewChain contract
  execute     Execute transactionId
  help        Help about any command
  info        Show the basic info of contract wallet or a transaction ID
  init        Initialize config file
  list        List of transaction IDs in defined range
  owner       Manage contract owners
  revoke      Revoke transactionId
  sign        Sign the transaction in the file
  submit      Submit a transaction, pay amount in unit to target address
  update      Manage daily limit and requirement
  version     Get version of MultiSigWallet CLI

Flags:
  -c, --config path               The path to config file (default "./config.toml")
  -a, --contractAddress address   Contract address
  -f, --from address              the from address who pay gas
  -h, --help                      help for MultiSigWallet
  -i, --rpcURL url                NewChain json rpc or ipc url (default "https://rpc1.newchain.newtonproject.org")
  -w, --walletPath directory      Wallet storage directory (default "./wallet/")

Use "MultiSigWallet [command] --help" for more information about a command.

Use config.toml

You can use a configuration file to simplify the command line parameters.

One available configuration file config.toml is as follows:

contractaddress = "0xf09E6759c2588eE8435902d16350E321CBD27af3"
from = "0xdDeB86Dd09F16316B67322199E288d7AF35E0806"
rpcurl = "https://rpc1.newchain.newtonproject.org"
walletpath = "./wallet/"

Initialize config file

# Initialize config file
$ MultiSignatureWallet init

Just press Enter to use the default configuration, and it's best to create a new user.

$ MultiSignatureWallet init
Initialize config file
Enter file in which to save (./config.toml):
Enter the wallet storage directory (./wallet/):
Enter NewChain json rpc or ipc url (https://rpc1.newchain.newtonproject.org):
Create a default account or not: [Y/n]
Your new account is locked with a password. Please give a password. Do not forget this password.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
New accout is  0xdDeB86Dd09F16316B67322199E288d7AF35E0806
Get faucet for 0xdDeB86Dd09F16316B67322199E288d7AF35E0806
Your configuration has been saved in  ./config.toml

Create account

# Create an account with faucet
MultiSignatureWallet account new --faucet

# Create 10 accounts
MultiSignatureWallet account new -n 10 --faucet

# Create an account with the standard scrypt for keystore
MultiSignatureWallet account new -s

Deploy contract

# Deploy multisignature wallet contract
# with 3 owner, 2 required confirmations
MultiSignatureWallet deploy -o 0xdDeB86Dd09F16316B67322199E288d7AF35E0806,0x9B3deA9C636BA262f870f98a1c64d444BF0f6544,0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31 -r 2

# with 3 owner, 2 required confirmations and 1024 NEW daily withdraw without confirmations
MultiSignatureWallet deploy -o 0xdDeB86Dd09F16316B67322199E288d7AF35E0806,0x9B3deA9C636BA262f870f98a1c64d444BF0f6544,0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31 -r 2 -l 1024

# with 3 owner, 2 required confirmations and 10 WEI daily withdraw without confirmations
MultiSignatureWallet deploy -o 0xdDeB86Dd09F16316B67322199E288d7AF35E0806,0x9B3deA9C636BA262f870f98a1c64d444BF0f6544,0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31 -r 2 -l 1024 -u WEI

Submit transaction

# Submit transaction, pay 10 NEW from the contract address to 0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31
MultiSignatureWallet submit 10 -t 0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31

This will get a message back from the wallet contract with a number or hash code which is the transactionID.

You have to communicate this transactionID to other owners to get them to confirm it.

Confirm transactionID

# Confirm transaction ID
MultiSignatureWallet confirm 1

Revoke transactionID

# Revoke a confirmation for a transaction
MultiSignatureWallet revoke 1

Execute transactionID

# Execute a confirmed transaction
MultiSignatureWallet execute 1

List transactionIDs

# List transaction IDs
MultiSignatureWallet list

# List pending transaction IDs
MultiSignatureWallet list --pending

# List executed transaction IDs
MultiSignatureWallet list --executed

# List transaction IDs from index 10 to 20
MultiSignatureWallet list --fromindex 10 --toindex 20

Get basic info

# Get the basic information of the contract wallet
MultiSignatureWallet info

# Get the basic infofmation of a transaction ID
MultiSignatureWallet info 1

# Force display value in unit
MultiSignatureWallet info -u NEW
MultiSignatureWallet info 1 -u NEW

# Get the basic information of the specified contract address
MultiSignatureWallet info -a 0x8CFA0D92673bECC7A4B480844376A82b942E469b

Manage owners

# List all owners
MultiSignatureWallet owner list

# Check whether an address is an owner
MultiSignatureWallet owner check 0x9B3deA9C636BA262f870f98a1c64d444BF0f6544

# Add an owner
MultiSignatureWallet owner add 0x9B3deA9C636BA262f870f98a1c64d444BF0f6544

# Remove an owner
MultiSignatureWallet owner remove 0x9B3deA9C636BA262f870f98a1c64d444BF0f6544

# Replace an owner(0x9B3deA9C636BA262f870f98a1c64d444BF0f6544) with a new one
MultiSignatureWallet owner replace 0x9B3deA9C636BA262f870f98a1c64d444BF0f6544 0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31

Update daily limit or the number of required

# Update the daily limit to 1024 NEW
MultiSignatureWallet update dailylimit 1024

# Update the daily limit to 10 WEI
MultiSignatureWallet update dailylimit 10 -u WEI

# Update the number of required to 2 
MultiSignatureWallet update required 2

Build transaction online

# Build transaction
MultiSignatureWallet build

Sign transaction offline

# Sign transaction from file and save sign transaction hex to file
MultiSignatureWallet sign tx.txt

# Sign transaction save to the specified file
MultiSignatureWallet sign tx.txt --out tx.sign

Broadcast signed transaction online

# Broadcast signed transaction hex to NewChain system
MultiSignatureWallet broadcast tx.sign

Token

Token info

# Show token info of current MSW
MultiSignatureWallet info --token 0x20F12218281F9CA566B5c41F17c6c19050125cD3

Token info

# Send 10 token from MSW to 0xA950D99522C377C4786d77Af56A240D7e626e61d
MultiSignatureWallet submit 10 --to 0xA950D99522C377C4786d77Af56A240D7e626e61d --token 0x20F12218281F9CA566B5c41F1
7c6c19050125cD3

Examples

Online Example (3/3)

For owner A
Submit transaction
# Submit transaction, pay 10 NEW from the contract address to 0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31
MultiSignatureWallet submit 10 -t 0xc8B5c4cB6DB7254d082b24A96627F143E8A80c31

This will get a message back from the wallet contract with a number or hash code which is the transactionID.

You have to communicate this transactionID to other owners to get them to confirm it.

For owner B and C

Confirm transaction
# Confirm transaction ID
MultiSignatureWallet confirm 1

Offline Example (3/3)

MultiSignatureWallet provides offline signature, the process is as follows:

For owner A

Build Submit Transaction Information (Online Computer)
# Build transaction, use the defalult setting
$ MultiSignatureWallet build
Enter contract address (default: 0xc264cdD35F99C72b78315D25E6E353dBc7AA0430):
Enter from address who sign tx (default: 0x7c1d845a0CC7E24352A59FEF437eB27b504769DE):
Which action to use? (default = submit)
 1. Submit - Submit transaction, pay to address
 2. Confirm - Confirm transaction ID
 3. Revoke - Revoke a confirmation for a transaction
 4. Execute - Execute a confirmed transaction
 5. OwnerAdd - Add an owner
 6. OwnerRemove - Remove an owner
 7. OwnerReplace - Replace an owner
 8. DailyLimit - Update the daily limit
 9. Required - Update the number of required
Enter the number of action (default: 1):
Enter to address: 0x7c1d845a0CC7E24352A59FEF437eB27b504769DE
Enter unit for amount (NEW or WEI, default NEW):
Enter amount to pay in NEW (default: 0):
Enter text message (default is empty):
Transaction details are as follows:
{
 "from": "0x7c1d845a0cc7e24352a59fef437eb27b504769de",
 "to": "0xc264cdd35f99c72b78315d25e6e353dbc7aa0430",
 "value": "0",
 "unit": "WEI",
 "data": "0xc64274740000000000000000000000007c1d845a0cc7e24352a59fef437eb27b504769de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
 "nonce": 52,
 "gasPrice": 100,
 "gas": 132155,
 "networkID": 16888
}
Enter file to save transaction (default: 20180929180404.tx):
Successfully save transaction to file 20180929180404.tx
Sign Transaction (Offline Computer)
# Sign transaction from file tx.txt and save sign transaction hex to file tx.txt.sign
MultiSignatureWallet sign tx.txt
Broadcast Signed Transaction (Online Computer)
# Broadcast signed transacion hex to NewChain system
# This will return an transacionID and tell it to the other owners.
MultiSignatureWallet broadcast tx.txt.sign

For owner B and C

Build Confirm TransactionID Information (Online Computer)
# Build transaction and select 2
MultiSignatureWallet build
Sign Transaction (Offline Computer)
# Sign transaction from file tx.txt and save sign transaction hex to file tx.txt.sign
MultiSignatureWallet sign tx.txt
Broadcast Signed Transaction (Online Computer)
# Broadcast signed transacion hex to NewChain system
MultiSignatureWallet broadcast tx.txt.sign

Offline Example Tips:

  • The last owner should build transaction after the other owners broadcast, otherwise it will causes the error intrinsic gas too low.