I am trying to create a JS code to be able to vote using proxy account that has been given democracy permissions to stash account, so I would be able to vote using just my mobile phone instead of accessing my home setup for voting using just terminal.
Substrate Extrinsics Docs instructs following
proxy(real: AccountId32, force_proxy_type: Option, call: Call),
so we need to make a proxy call with address of stash account, type of proxy call and call in encoded format like 0x0500306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc200f00a0be1c448399.
My struggle is, how do I get voting data this call data in encoded format? How do I use these imaginary keys to sign my vote?
const PROXY = {
address: '5D7m1JT5QR6Pg1z4LXZPTNZqiFVzUX9NbAndeZvVzrjUCpNe',
key: 'expose circle crack addict nasty horny men write sugar cloth sound orbit',
type: 'Governance'
};
const STASH = {
address: '5Dhf5LvBWcvioXuLeGzW1xLaEKTfFmUmnE2ZC5RLKaJu2K8M',
key: 'tank barrel crack addict nasty horny men write sugar unfold hood expect depend'
};
function proxyVoting(address, type, ref_index, vote) {
api.tx.proxy.proxy(address, type, (call)=>{
api.tx.democracy.vote(ref_index, vote);
});
}
proxyVoting(STASH.address, PROXY.type, 183, true);
Error: createType(Call):: Call: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId32","force_proxy_type":"Option<KusamaRuntimeProxyType>","call":"Call"}:: Struct: failed on call: Call:: Call: Cannot decode value '(call)=>{
api.tx.democracy.vote(ref_index, vote);
}' of type function