Msig Contract

msig is short for multiple signature, which allows multiple accounts to sign a transaction together. It enables asynchronous proposal, approval, and publication of transactions that have been agreed upon by multiple parties. The ability to sign is determined based on the weight of the account or public key, and the signature is successful when the weight threshold is reached.

Operation Example

The dmc_client object is an instance of dmc.js, which provides a series of methods for interacting with the blockchain. The dmc_client in the code examples below is created using the following code, and it is not reiterated further.

1
2
3
4
5
6
7
8
9
10
var DMC = require('dmc.js');
var dmc_client = DMC({
chainId: 'c102a8115bef9e4a4e751559aac2cdc2859417e6476f8cb6054cd3f7dffe1ce4',
keyProvider: 'creator_priKey',
httpEndpoint: 'http://testnode.dmctech.io:8801',
logger: {
log: null,
error: null
}
});

propose

Submit Proposal.

Parameters

name type description
proposer string proposer
proposal_name string proposal name
requested string required Permissions for Proposal Approval
trx string transaction Details of the Proposal Execution

Instance

In the following example, we will use the extransfer action from the dmc.token contract as the transaction content for the proposal.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
let actions = [{
'account': 'dmc.token',
'name': 'extransfer',
'authorization': [{
"actor": from,
"permission": "active"
}],
'data': {
"from": from,
"to": to,
"quantity": quantity,
"memo": memo
}
}]
let serializeActions = dmc.serializeActions_sync(actions);
let r = dmc.transact_sync({
actions: [
{
account: 'dmc.msig',
name: 'propose',
authorization: [{
actor: account,
permission: 'active',
}],
data: {
proposer: account,
proposal_name: proposal_name,
requested: [{
actor: account,
permission: 'active',
}],
trx: {
"expiration": expiration,
"ref_block_num": 0,
"ref_block_prefix": 0,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": serializeActions,
"transaction_extensions": []
}
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.log(r);

approve

Approve the proposal.

Parameters

name type description
proposer string proposer
proposal_name string proposal name
level string approve the proposal using which permission.

Instance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let r = dmc.transact_sync({
actions: [{
account: 'dmc.msig',
name: 'approve',
authorization: [
{
actor: account,
permission: 'active'
},
],
data: {
"proposer": proposer,
"proposal_name": proposal_name,
"level": {
"actor": account,
"permission": "active"
}
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.log(r);

unapprove

disapprove the proposal.

Parameters

name type description
proposer string proposer
proposal_name string proposal name
level string disapprove the proposal using which permission.

Instance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let r = dmc.transact_sync({
actions: [{
account: 'dmc.msig',
name: 'unapprove',
authorization: [
{
actor: account,
permission: 'active'
},
],
data: {
"proposer": proposer,
"proposal_name": proposal_name,
"level": {
"actor": account,
"permission": "active"
}
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.log(r);

cancel

To cancel a proposal.

Parameters

name type description
proposer string proposer
proposal_name string proposal name
canceler string the account that cancel a proposal

Instance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let r = dmc.transact_sync({
actions: [{
account: 'dmc.msig',
name: 'cancel',
authorization: [
{
actor: account,
permission: 'active'
},
],
data: {
"proposer": proposer,
"proposal_name": proposal_name,
"canceler": account
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.log(r);

exec

To execute a proposal.

parameter

name type description
proposer string proposer
proposal_name string proposal name
executer string the account that execute a proposal

Instance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let r = dmc.transact_sync({
actions: [{
account: 'dmc.msig',
name: 'exec',
authorization: [
{
actor: account,
permission: 'active'
},
],
data: {
"proposer": proposer,
"proposal_name": proposal_name,
"executer": account
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.log(r);