I am trying to create a multi-sig proposal (eosio.msig::propose) using eosjs v20.0.0. The proposed transaction is arbitrary but in my case, I would like to propose an updateauth action.
The equivalent cleos command is:
cleos multisig propose changeowner '[{"actor": "alice", "permission": "active"}, {"actor": "bob", "permission": "active"}]' '[{"actor": "master", "permission": "owner"}]' eosio updateauth '{"account": "master", "permission": "owner", "parent": "", "auth": {"keys":[{"key":"EOS6kYgMTCh1iqpq9XGNQbEi8Q6k5GujefN9DSs55dcjVyFAq7B6b", "weight":1}],"threshold":1,"accounts":[],"waits":[]}}"}' -p alice@active
Where the master
account is a multi-sig between alice and bob like
master
permissions:
owner 2: 1 alice@active, 1 bob@active
active 1: 1 ACTIVE_PUBLIC_KEY
My attempt to do with eosjs is following:
account = alice;
actionName = 'propose';
actionData = {
proposer: account,
proposal_name: 'changeowner',
requested: [
{
'actor': account,
'permission': 'active'
},
{
'actor': 'bob',
'permission': 'active'
}
],
trx: {
expiration: '2020-04-22T16:39:15',
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: [
{
account: 'eosio',
name: 'updateauth',
authorization: [
{
actor: account,
permission: 'active'
}
],
data: {
account: account,
permission: 'owner',
parent: '',
auth: {
keys: [
{
key: 'EOS6kYgMTCh1iqpq9XGNQbEi8Q6k5GujefN9DSs55dcjVyFAq7B6b',
weight: 1
}
],
threshold: 1,
accounts: [],
waits: []
}
}
}
],
transaction_extensions: []
}
};
try {
const result = await api.transact({
actions: [{
account: 'eosio.msig',
name: actionName,
authorization: [{
actor: account,
permission: 'active',
}],
data: actionData,
}]
}, {
blocksBehind: 3,
expireSeconds: 30
});
console.log(result);
} catch (e) {
console.log('Caught exception: ' + e);
if (e instanceof RpcError) {
console.log(JSON.stringify(e.json, null, 2));
}
}
However I get the error:
Caught exception: Error: Expected string containing hex digits
because I am passing the action data in trx
as json and not hex. Is there a way to pass in json and/or is there a way to convert my json to hex?