This repository is a dApp implemented as an aergo smart contract that can extract Aergo and vote BPs through 2 of 4 multiple signatures.
Receive data and deploy the contract to an aergo blockchain.
- Download or clone this repository.
- Compile a
contract/multisig2of4.lua
smart contract file using aergoluac. Or use pre-compiled payload filedapp/build/contract.payload
. - Deploy the compiled contract with 4 owners addresses as arguments.
- Deposit Aergo at any time to this contract's address.
Run dApp to invoke the user interface. Then load the deployed contract to check the current status and get the its abi.
- Before you start, you will need a chrome browser and a aergo browser wallet.
- Open a
dapp/build/index.html
file using the browser. - Or launch a local web server (This step requires npm).
- Put an aergo node address in a form of
http://ip:port
and the deployed contract address. - Check that the contract is loaded well and its balance and stake amount are displayed.
This process requires two owners to do the same steps.
The owners go through a preliminary work to share and agree an administrative request. After agreement, two owners convert the administrative request into a single text via the genMsgSign
Query. Two owners sign the text with the owner's private key.
- Select a request type; withdraw, staking, unstaking, and voting.
- Fill its form. (e.g, withdraw = an amount to send & a receiver's address).
- Click
Query Gen Msg
button and copy a single text. - Log in to the owner account in your browser wallet.
- Move to the sign tab.
- Put the copied single text into a message text box and click sign button.
- Copy a signed message and give it to an tx sender (or operator).
You can make a request to the wallet contract by sending two signed texts by the 2 owners in the payload of the transaction.
- Operator runs dApp.
- Fill the request form with same request parameters.
- Paste the signed texts and select the owner IDs that matches the signature.
- Click a `Gen Req Payload' Button and Copy a result payload.
- Log in to browser wallet and move to a send tab.
- Enter the contract address to a recipient.
- Click
Add Data
and paste the copied payload. - Continue and send a transaction.
- Check a result in aergoscan.
It guides you how to create the arguments manually to call the contract in case you use CLI or other SDK.
Commonly, the first argument is a request type charactor in upper case.
- Withdraw:
["W", {"_bignum": "${amount}"}, "${toAddress}"]
- Stake:
["S", {"_bignum": "${amount}"}]
- Unstake:
["U", {"_bignum": "${amount}"}]
- Vote:
["V", "${ballot_peer_id_1}", "${ballot_peer_id_2}", ..., "${ballot_peer_id_N}"]
As above, the first argument is a request type charactor in upper case. The second value is the ID of the owner of the first signature, and the third value is the first signed text. The fourth value is the ID of the owner of the second signature, and the fifth value is the second signed text. The rest is the same as above.
- Withdraw:
["W", ${owner_id_1}, "${owner_signed_msg_1}", ${owner_id_2}, "${owner_signed_msg_2}", {"_bignum": "${amount}"}, "${toAddress}"]
- Stake:
["S", ${owner_id_1}, "${owner_signed_msg_1}", ${owner_id_2}, "${owner_signed_msg_2}", {"_bignum": "${amount}"}]
- Unstake:
["U", ${owner_id_1}, "${owner_signed_msg_1}", ${owner_id_2}, "${owner_signed_msg_2}", {"_bignum": "${amount}"}]
- Vote:
["V", ${owner_id_1}, "${owner_signed_msg_1}", ${owner_id_2}, "${owner_signed_msg_2}", "${ballot_peer_id_1}", "${ballot_peer_id_2}", ..., "${ballot_peer_id_N}"]
This chapter describes how to run the test code.
- (Pre-requisites: native lua 5.1 or luajit)
- Move to the
test/lua
directory. - run
lua unittest.lua
in command line.
- (Pre-requisites: brick)
- Move to the
test/brick
directory. - run
brick ${test_brick_file}
- init.brick: create accounts and deploy contract.
- staking.brick: test staking & unstaking aergo.
- voting.brick: test voting bps.
- withdraw.brick: test withdraw aergo.
- Wallet Integration: don't need to copy and paste