The extension inject contentscript with web3 provider variable: vizonator. Any action is passed to expansion executive logic, which checks saved rules to approve or refuse the action. If no rules was found for specific site — extension asks the user for approval.
This documentation mostly for javascript frontend developers.
Available operations
Types of operations: sign and execute operation, extension data, API.
Each operation requires several rules scope. If user checked to remember decision, extension save it to specific site.
- check vizonator variable
- get_account (extension data)
- get_settings (extension data)
- import_account
- get_custom_account (API)
- get_account_history (API)
- get_accounts_on_sale (API)
- get_subaccounts_on_sale (API)
- account_metadata
- award
- fixed_award
- committee_vote_request
- custom
- delegate_vesting_shares
- passwordless_auth
- transfer
- transfer_to_vesting
- withdraw_vesting
check_vizonator
Test vizonator variable before request any operations.
if(typeof vizonator !== "undefined"){
$(".vizonator_callback.test_check_vizonator").html("Vizonator initialized!");
}
else{
$(".vizonator_callback.test_check_vizonator").html("Vizonator NOT initialized...");
}
Run exampleget_account
Rules scope: account
Retrieving current account information from extension: login, current energy, if memo and active private keys are filled.
vizonator.get_account(function(error,result){
let el=$(".vizonator_callback.test_get_account");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleget_settings
Rules scope: settings
Retrieving current settings from extension: energy step, default energy spend by award operation, dark mode, language.
vizonator.get_settings(function(error,result){
let el=$(".vizonator_callback.test_get_settings");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleimport_account
Rules scope: account
let account="invite";
let regular_key=false;
let active_key="5KcfoRuDfkhrLCxVcE9x51J6KN9aM9fpb78tLrvvFckxVV6FyFW";
let memo_key=false;
vizonator.import_account(account,regular_key,active_key,memo_key,function(error,result){
let el=$(".vizonator_callback.test_import_account");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleget_custom_account
Rules scope: account, api
API request for any VIZ account with custom protocol sequencer. If account is empty or boolean false — asks for user account.
let account="on1x";
let protocol="V";//can be empty
vizonator.get_custom_account(account,protocol,function(error,result){
let el=$(".vizonator_callback.test_get_custom_account");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleget_account_history
Rules scope: account, api
API request for operation history to any VIZ account. If account is empty or boolean false — asks for user account.
let account="on1x";
let from=-1;//from the latest activity
let limit=5;
vizonator.get_account_history(account,from,limit,function(error,result){
let el=$(".vizonator_callback.test_get_account_history");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleget_accounts_on_sale
Rules scope: account, api
let from=0;//from first entry
let limit=50;//max 1000
vizonator.get_accounts_on_sale(from,limit,function(error,result){
let el=$(".vizonator_callback.test_get_accounts_on_sale");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleget_subaccounts_on_sale
Rules scope: account, api
let from=0;//from first entry
let limit=50;//max 1000
vizonator.get_subaccounts_on_sale(from,limit,function(error,result){
let el=$(".vizonator_callback.test_get_subaccounts_on_sale");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampleaccount_metadata
Rules scope: meta, regular, account
Rewrite/update account metadata information. Usualy used to modify profile page (first - get metadata from blockchain, second - change it structure, third - write it on blockchain by this operation).
let metadata="{}";//be careful, this operation will be clear account metadata
vizonator.account_metadata({json:metadata},function(error,result){
let el=$(".vizonator_callback.test_account_metadata");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run exampleaward
Rules scope: award, regular
Additional properties: beneficiaries (structed as array of accounts with percent of received reward [{"account":"login1","weight":100},{"account":"login2","weight":200}]), custom_sequence (used by social gateways), force_memo_encoding (force encoding).
Result contains object with approximate_amount property as decimial. It is approximate amount of social capital that has been awarded.
vizonator.award({receiver:"on1x",energy:500,memo:"Vizonator docs"},function(error,result){
let el=$(".vizonator_callback.test_award");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result));
}
});
Run examplefixed_award
Rules scope: award, regular
Identical to award, difference in variable reward_amount and max_energy for a fixed reward.
vizonator.fixed_award({receiver:"on1x",reward_amount:"1.000 VIZ",max_energy:500,memo:"Vizonator docs"},function(error,result){
let el=$(".vizonator_callback.test_fixed_award");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result));
}
});
Run examplecommittee_vote_request
Rules scope: committee, regular
Vote for active request in VIZ DAO. Param vote_percent can be in range from -10000 (-100.00%) to 10000 (100.00%).
vizonator.committee_vote_request({request_id:5,vote_percent:10000},function(error,result){
let el=$(".vizonator_callback.test_committee_vote_request");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run examplecustom
Rules scope: custom, protocol_*, regular*, active*
Post custom protocol json data in blockchain. Authority can be active or regular.
let authority_type="regular";//can be "active"
let protocol_id="test";
let json_data='{"hello":"world"}';
vizonator.custom({authority:authority_type,id:protocol_id,json:json_data},function(error,result){
let el=$(".vizonator_callback.test_custom");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run exampledelegate_vesting_shares
Rules scope: delegate, active
Delegate social capital to another account or undelegate. Influences the efficiency of awards and votes in DAO.
let amount="1.000000 SHARES";//"0.000000 SHARES" for undelegate
vizonator.delegate_vesting_shares({delegatee:"on1x",vesting_shares:amount},function(error,result){
let el=$(".vizonator_callback.test_delegate_vesting_shares");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run examplepasswordless_auth
Rules scope: auth, account, regular*, active*
Sign unique passwordless string for proof of authentification. String contains site origin, authority type, account and timestamp in unixtime format. Site that processing the signature verification must cache it with 2-minute expiration to block any other attempts from other sources (in case of a MITM attack).
let authority_type="regular";//can be "active"
vizonator.passwordless_auth({authority:authority_type},function(error,result){
let el=$(".vizonator_callback.test_passwordless_auth");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text(JSON.stringify(result,null,2));
}
});
Run exampletransfer
Rules scope: transfer, active
Ask user to transfer amount of viz. Can force encoding the memo.
let amount="0.001 VIZ";
let memo="Vizonator docs";
let force_encoding=false;//can be boolean true for force encoding by shared memo key
vizonator.transfer({to:"committee",amount:amount,memo,force_memo_encoding:force_encoding},function(error,result){
let el=$(".vizonator_callback.test_transfer");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run exampletransfer_to_vesting
Rules scope: vesting, active
Ask user to stake amount of viz to social capital.
vizonator.transfer_to_vesting({to:"committee",amount:"0.001 VIZ"},function(error,result){
let el=$(".vizonator_callback.test_transfer_to_vesting");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run examplewithdraw_vesting
Rules scope: vesting, active
Ask user to unstake amount of social capital to viz.
vizonator.withdraw_vesting({vesting_shares:"10.000000 SHARES"},function(error,result){
let el=$(".vizonator_callback.test_withdraw_vesting");//debug element
if(error){
el.text("Error: "+JSON.stringify(error));
}
else{
el.text("Result: "+JSON.stringify(result));
}
});
Run example