Build with PIXA Keychain.
Your app asks, the person reads it in the wallet’s own window, and your callback gets the answer. You never hold a key, and there’s nothing to sign up for.
Looking for PIXA Keychain in this browser
Find the wallet
The extension adds window.pixa_keychain to every https:// page, and to localhost and 127.0.0.1 while you’re developing. It arrives once the page has loaded, so wait a moment before saying it isn’t there.
If it isn’t there, link to pixtopia.net/keychain. It doesn’t run on phones, so keep another way in for them.
async function findKeychain(ms = 2000) {
const end = Date.now() + ms;
while (!window.pixa_keychain && Date.now() < end) {
await new Promise((resolve) => setTimeout(resolve, 100));
}
return window.pixa_keychain ?? null;
}
Sign someone in
Your server makes a one-time message, the wallet signs it with the person’s posting key, and your server checks the signature against that account’s keys on chain. Nothing is broadcast and nothing costs anything.
- Pass
nullas the account and the person picks one in the wallet. The answer says which, indata.username. - The wallet shows your message exactly as written, so write it for a person. Name your site.
- Make the message single-use, and give it an expiry, so a signature can’t be replayed.
- Always check on your server. A page can’t tell the real extension from a script pretending to be it, and
data.usernameis only a claim until the signature proves it.
const keychain = await findKeychain();
if (!keychain) return showGetTheWallet();
// A request opens a window, so only do this after a tap.
const { message } = await post('/auth/challenge');
keychain.requestSignBuffer(null, message, 'Posting', async (answer) => {
if (!answer.success) return; // They said no.
await post('/auth/verify', {
account: answer.data.username,
message,
signature: answer.result,
});
});
import { secp256k1 } from '@noble/curves/secp256k1.js';
import { ripemd160 } from '@noble/hashes/legacy.js';
import { sha256 } from '@noble/hashes/sha2.js';
import { hexToBytes, utf8ToBytes } from '@noble/hashes/utils.js';
import { base58 } from '@scure/base';
// The key that made a signature. Pixa keys look like PIX...
function recoverKey(message, signature) {
const bytes = hexToBytes(signature);
bytes[0] -= 31; // Pixa, like Hive, adds 31 to the recovery number.
const point = secp256k1.recoverPublicKey(
bytes,
sha256(utf8ToBytes(message)),
{ prehash: false },
);
const withCheck = new Uint8Array(37);
withCheck.set(point);
withCheck.set(ripemd160(point).slice(0, 4), 33);
return 'PIX' + base58.encode(withCheck);
}
async function verifySignIn({ account, message, signature }) {
// First make sure this is a message you issued, unused and unexpired.
const response = await fetch('https://api.pixagram.com', {
method: 'POST',
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'condenser_api.get_accounts',
params: [[account]],
}),
});
const [onChain] = (await response.json()).result;
if (!onChain) return false;
const key = recoverKey(message, signature);
const { key_auths, weight_threshold } = onChain.posting;
const entry = key_auths.find(([known]) => known === key);
return Boolean(entry) && entry[1] >= weight_threshold;
}
Try it here
This is that same flow, for real, on this page. It signs a test message with your posting key, then recovers the key from the signature and looks for it on the chain. Nothing is broadcast, and the signature isn’t kept or sent anywhere.
You’ll need PIXA Keychain in this browser to try this.
The message
The wallet’s answer
Sign and send
For common actions, ask for what you want and the wallet builds the transaction, shows it in plain words, signs and broadcasts it through the person’s own node.
requestVotefor likes, weight from -10000 to 10000.requestCustomJsonfor follows and your app’s own data. It shows your message, the ID and the data.requestPostfor posts and replies.requestTransferand the other money requests.requestBroadcastfor any other operations.requestSignTxif you need to broadcast it yourself.
Set the post’s reward settings in requestPost and they’re shown in the review every time. They must name that author and permlink.
const follow = JSON.stringify(['follow', {
follower: account,
following: 'pixtopia',
what: ['blog'],
}]);
keychain.requestCustomJson(
account,
'follow',
'Posting',
follow,
'Follow @pixtopia',
(answer) => {
if (answer.success) showFollowing(answer.result.tx_id);
},
);
const node = 'https://api.pixagram.com';
const call = async (method, params) =>
(await (await fetch(node, {
method: 'POST',
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
})).json()).result;
const { head_block_number, head_block_id } =
await call('condenser_api.get_dynamic_global_properties', []);
const prefix = head_block_id
.slice(8, 16).match(/../g).reverse().join('');
const expires = new Date(Date.now() + 600000);
const transaction = {
ref_block_num: head_block_number & 0xffff,
ref_block_prefix: parseInt(prefix, 16),
expiration: expires.toISOString().slice(0, 19),
operations: [
['vote', { voter: account, author, permlink, weight: 5000 }],
],
extensions: [],
};
keychain.requestSignTx(account, transaction, 'Posting', async (answer) => {
if (answer.success) {
await call('condenser_api.broadcast_transaction', [answer.result]);
}
});
Which key to ask for
Ask for the least you need. People notice.
Posting
Likes, posts, replies, follows and your own custom_json. The only key “Don’t ask again” can apply to.
Active
Money and governance: transfers, savings, power, delegations and votes for witnesses. Always opens a window.
Memo
Encrypting and reading private messages. Always opens a window.
Owner
Refused, always. The wallet doesn’t hold owner keys, so don’t build anything that needs one.
Read the answer
Every callback gets one object. Check success before you use result.
| Field | What it is |
|---|---|
success | true if it worked |
result | What the request produced, such as a signature or the broadcast’s result |
error | Why it didn’t work |
message | A sentence you can show |
data | The request as the wallet received it |
publicKey | The public key that signed, when there is one |
request_id | The number of this request |
The errors you’ll want to handle
user_cancel | The person said no. Say nothing more. |
incomplete | The request wasn’t valid. message says why. |
ignored | A newer request from this page replaced this one. |
busy | The last request is already being sent. Wait for it. |
// A page gets one request at a time, so they wait their turn.
let line = Promise.resolve();
function ask(send) {
const turn = line.then(() => new Promise((resolve, reject) => {
send(window.pixa_keychain, (answer) => {
if (answer.success) return resolve(answer);
const error = new Error(answer.message);
error.code = answer.error;
reject(error);
});
}));
line = turn.catch(() => undefined);
return turn;
}
const answer = await ask((keychain, done) =>
keychain.requestVote(account, permlink, author, 5000, done));
Good to know
- Don’t ask unprompted. A request opens a window, so make it the result of something the person did.
- One at a time. A new request replaces one still waiting for the person, which answers
ignored, and is itself refused withbusyif the last one is already being sent. - Amounts are strings with three decimals (
"1.000"), inPIXAandPXS. Delegations are inPPorVESTS. A request inHIVEorHBDis refused. - Messages are signed as text, exactly as the person reads them. The wallet won’t decode bytes from JSON, and refuses text that starts with Pixa’s chain ID, because that could be signed into a transaction.
- Reading is up to you. For balances, posts and accounts, call a Pixa node yourself. The wallet only signs.
- The node is the person’s.
rpcis still accepted, but ignored. - Titles are the wallet’s.
titleinrequestSignBufferis ignored too. What a site writes only ever appears as a value, so it can’t pass for the wallet speaking. - Weights in authority requests are whole numbers from 1 to 65535.
- What it can’t read, it says so. An operation the wallet can’t describe gets a warning and the raw transaction, and can’t be approved in advance. That includes
custom_jsonsent throughrequestBroadcastorrequestSignTx, unless it’s a follow or a portal action. Send your app’s own data withrequestCustomJsoninstead, where people can see your message and choose not to be asked again for that ID.
Coming from Hive Keychain
The requests have the same shape, so most sites only need the global renamed and Pixa’s tokens. Both extensions can run in one browser, because nothing here shares a name with Hive Keychain’s.
- Use
PIXAandPXS, andpixaandpxsin field names likepercent_pxs. - Public keys start with
PIX, and the node isapi.pixagram.com. requestSignedCallis disabled. UserequestBroadcastorrequestSignTx.- There’s no Hive Engine, swaps, multisig or HiveAuth here.
const keychain = window.pixa_keychain;
Test your app
The repo has a page with a form for every request. Serve it from a local address and open it with the extension installed.
Requests from it are real, and so is anything your own app sends, so use a test account that holds nothing you’d miss.
git clone https://github.com/elmerlin/pixa-keychain.git
cd pixa-keychain/example
python3 -m http.server 1337
# Then open http://localhost:1337/main.html
Every request
Most take the account first and a callback near the end, with optional parameters after it.
Finding the wallet and signing messages
requestHandshakeChecks the wallet is there. Opens no window.
| Parameter | Type | What it is |
|---|---|---|
callback | function | Confirms Keychain installation (has no parameters) |
requestSignBufferSigns a message, which is how you sign someone in.
| Parameter | Type | What it is |
|---|---|---|
account (optional) | String | Pixa account to perform the request. If null, user can choose the account from a dropdown |
message | String | Message to be signed by the account |
key | String | Type of key. Can be 'Posting','Active' or 'Memo' |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
title (optional) | String | Ignored. The wallet writes its own title |
requestVerifyKeyAsks the wallet to decode a message, to show it holds a key.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
message | String | Message to be decoded by the account |
key | String | Type of key. Can be 'Posting','Active' or 'Memo' |
callback | function | Function that handles the wallet’s response to the request |
const keychain = window.pixa_keychain;
keychain.requestVerifyKey('pixtopia', encodedMessage, 'Posting', (response) => {
if (response.success === true) {
const decodedMessage = response.result;
}
});requestEncodeMessageEncrypts a message for another account.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
receiver | String | Account that will decode the string |
message | String | Message to be encrypted. It has to start with # |
key | String | Type of key. Can be 'Posting','Active' or 'Memo' |
callback | function | Function that handles the wallet’s response to the request |
const keychain = window.pixa_keychain;
const message = '#' + username + Date.now();
keychain.requestEncodeMessage(username, myUsername, message, 'Memo', (response) => {
if (response.success) {
const encodedMessage = response.result;
// Send message to a server where you can use your private key to decode it
}
});requestEncodeWithKeysEncrypts a message for several public keys.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
publicKeys | Array<String> | Key that can decode the string |
message | String | Message to be encrypted. It has to start with # |
key | String | Type of key. Can be 'Posting','Active' or 'Memo' |
callback | function | Function that handles the wallet’s response to the request |
const keychain = window.pixa_keychain;
const message = '#' + username + Date.now();
keychain.requestEncodeWithKeys(username, [pubKey1, pubKey2], message, 'Memo', (response) => {
if (response.success) {
const encodedMessages = response.result;
// Send message to a server where you can use your private key to decode it
}
});Posts and social
requestPostPublishes a post or a reply.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
title | String | Title of the blog post |
body | String | Content of the blog post |
parent_perm | String | Permlink of the parent post. Main tag for a root post |
parent_account | String | Author of the parent post. Pass '' for a root post |
json_metadata | String | The post's metadata, as JSON |
permlink | String | Permlink of the blog post |
comment_options | String | Reward settings for this post, as JSON, or ''. They must name this author and permlink, and they're shown in the review |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestPost(
'pixtopia',
'Hello World!',
'This is a blog post',
'blog',
'',
JSON.stringify({ format: 'markdown', tags: ['blog'] }),
'hello-world',
JSON.stringify({
author: 'pixtopia',
permlink: 'hello-world',
max_accepted_payout: '100000.000 PXS',
percent_pxs: 10000,
allow_votes: true,
allow_curation_rewards: true,
extensions: [[0, { beneficiaries: [{ account: 'pixa.team', weight: 1000 }] }]],
}),
(response) => {
console.log(response);
},
);requestVoteLikes or downvotes a post.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
permlink | String | Permlink of the blog post |
author | String | Author of the blog post |
weight | Number | Weight of the vote, comprised between -10,000 (-100%) and 10,000 (100%) |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Upvote with 50% weight
const keychain = window.pixa_keychain;
keychain.requestVote('pixa.team', 'hello-world', 'pixtopia', 5000, (response) => {
console.log(response);
});requestCustomJsonBroadcasts a custom_json, such as a follow or your own app’s data.
| Parameter | Type | What it is |
|---|---|---|
account (optional) | String | Pixa account to perform the request. If null, user can choose the account from a dropdown |
id | String | Type of custom_json to be broadcasted |
key | String | Type of key. Can be 'Posting' or 'Active' |
json | String | Stringified custom json |
display_msg | String | Message to display to explain to the user what this broadcast is about |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestCustomJson(null, 'my-app', 'Posting', JSON.stringify({ action: 'hello' }), 'Say hello in My App', (response) => {
console.log(response);
});Any transaction
requestBroadcastBroadcasts any operations in one transaction.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
operations | Array | Array of operations to be broadcasted |
key | String | Type of key. Can be 'Posting' or 'Active' |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestBroadcast('pixa.team', [
[
'account_witness_vote',
{
account: 'pixa.team',
witness: 'pixtopia',
approve: true
}
]
], 'Active', (response) => {
console.log(response);
});requestSignTxSigns a transaction you prepared, for you to broadcast.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
tx | Object | Unsigned transaction |
key | String | Type of key. Can be 'Posting' or 'Active' |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// This example would be done much easier with requestBroadcast
const node = 'https://api.pixagram.com';
const call = async (method, params) =>
(await (await fetch(node, {
method: 'POST',
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
})).json()).result;
const { head_block_number, head_block_id } = await call('condenser_api.get_dynamic_global_properties', []);
const prefix = head_block_id.slice(8, 16).match(/../g).reverse().join('');
const tx = {
ref_block_num: head_block_number & 0xffff,
ref_block_prefix: parseInt(prefix, 16),
expiration: new Date(Date.now() + 600000).toISOString().slice(0, 19),
operations: [...], // Add operations here
extensions: [],
};
window.pixa_keychain.requestSignTx(username, tx, 'Posting', async (response) => {
if (response.success) {
await call('condenser_api.broadcast_transaction', [response.result]);
}
});requestSignedCallDisabled. Use requestBroadcast or requestSignTx.
Money
requestTransferSends PIXA or PXS.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
to | String | Pixa account to receive the transfer |
amount | String | Amount to be transferred. Requires 3 decimals. |
memo | String | The memo will be automatically encrypted if starting by '#' and the memo key is available on Keychain. It will also overrule the account to be enforced, regardless of the 'enforce' parameter |
currency | String | 'PIXA' or 'PXS' |
callback | function | Function that handles the wallet’s response to the request |
enforce (optional) | boolean | If set to true, the person can’t choose to make the transfer from another account |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestTransfer(username, toUsername, '1.000', '', 'PIXA', (response) => {
console.log(response)
}, true);requestRecurrentTransferSets up a transfer that repeats.
| Parameter | Type | What it is |
|---|---|---|
username (optional) | String | Pixa account to perform the request |
to | String | Pixa account receiving the transfers. |
amount | String | amount to be sent on each execution. |
currency | String | PIXA or PXS on mainnet. |
memo | String | transfer memo |
recurrence | Number | How often will the payment be triggered (in hours) - minimum 24. |
executions | Number | The times the recurrent payment will be executed - minimum 2. |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
pair_id (optional) | Number | Pair id of the recurrent transfer |
// Let's send @pixtopia 5 PIXA a day
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestRecurrentTransfer(null, 'pixtopia', '5.000', 'PIXA', '', 24, 7, (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestSavingsOperationMoves PIXA or PXS in or out of savings.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
to | String | Account to receive the savings transfer |
amount | String | Amount to be transferred. Requires 3 decimals. |
currency | String | 'PIXA' or 'PXS' |
operation | String | 'deposit' or 'withdraw' |
memo (optional) | String | Memo attached to the savings operation |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestSavingsOperation(username, toUsername, '1.000', 'PXS', 'deposit', 'test memo', (response) => {
console.log(response);
});requestConversionConverts between PXS and PIXA.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
amount | String | amount to be converted. |
collaterized | Boolean | true to convert PIXA to PXS. false to convert PXS to PIXA. |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Convert 5 PIXA to PXS
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestConversion(username, '5.000', true, (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}Power and delegation
requestPowerUpTurns PIXA into Pixa Power.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
recipient | String | Account to receive the power up |
hive | String | Amount of PIXA to be powered up |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Power up 5 PP
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestPowerUp(username, username, '5.000', (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestPowerDownStarts turning Pixa Power back into PIXA.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
hive_power | String | Amount of PIXA to be powered down |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Power down 5 PP
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestPowerDown(username, '5.000', (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestDelegationLends Pixa Power to another account.
| Parameter | Type | What it is |
|---|---|---|
username (optional) | String | Pixa account to perform the request. If null, user can choose the account from a dropdown |
delegatee | String | Account to receive the delegation |
amount | String | Amount to be transferred. Requires 3 decimals for PP, 6 for VESTS. |
unit | String | PP or VESTS |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestDelegation(null, 'pixtopia', '1.000', 'PP', (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}Governance
requestWitnessVoteVotes for a witness, or takes the vote back.
| Parameter | Type | What it is |
|---|---|---|
username (optional) | String | Pixa account to perform the request. If null, user can choose the account from a dropdown |
witness | String | Account to receive the witness vote |
vote | boolean | Set to true to vote for the witness, false to unvote |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Unvote our witness vote for @pixtopia
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestWitnessVote(null, 'pixtopia', false, (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestProxySets a proxy to vote for the account.
| Parameter | Type | What it is |
|---|---|---|
username (optional) | String | Pixa account to perform the request. If null, user can choose the account from a dropdown |
proxy | String | Account to become the proxy. Empty string ('') to remove a proxy |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Let @pixtopia use our voting power in governance votes
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestProxy(null, 'pixtopia', (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}
// Remove voting proxy
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestProxy(null, '', (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestCreateProposalCreates a proposal for the Pixa Fund.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
receiver | String | Account receiving the funding if the proposal is voted |
subject | String | Title of the proposal |
permlink | String | Permlink to the proposal description |
daily_pay | String | Daily amount to be received by receiver, such as '10.000 PXS' |
start | String | Starting date, such as '2027-01-01T00:00:00' |
end | String | Ending date, in the same form |
extensions | String | Stringified Array of extensions |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestCreateProposal('pixtopia', 'pixtopia', 'PIXA Keychain development', 'pixa-keychain-proposal', '10.000 PXS', '2027-01-01T00:00:00', '2027-12-31T00:00:00', JSON.stringify([]), (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestRemoveProposalRemoves the account’s own proposals.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
proposal_ids | String | Stringified Array of ids of the proposals to be removed |
extensions | String | Stringified Array of extensions |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestRemoveProposal(username, JSON.stringify([216]), JSON.stringify([]), (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestUpdateProposalVoteVotes for proposals, or takes the vote back.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
proposal_ids | String | Stringified Array of Ids of the proposals to be voted |
approve | boolean | Set to true to support the proposal, false to remove a vote |
extensions | String | Stringified Array of extensions |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Approve a proposal
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestUpdateProposalVote(username, JSON.stringify([216]), true, JSON.stringify([]), (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}
// Unapprove a proposal
if (window.pixa_keychain) {
const keychain = window.pixa_keychain;
keychain.requestUpdateProposalVote(username, JSON.stringify([216]), false, JSON.stringify([]), (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}Accounts and who controls them
requestAddAccountOffers to add an account’s keys to the wallet.
| Parameter | Type | What it is |
|---|---|---|
username | String | username of the account to be added |
keys | Object | private keys of the account : {active:'...',posting:'...',memo:'...'}. At least one must be specified. Alternatively, authorized accounts can be specified with @${username}. |
callback | function | Function that handles the wallet’s response to the request |
if (window.pixa_keychain) {
const postingKey = '...';
const keychain = window.pixa_keychain;
keychain.requestAddAccount(username, {
posting: postingKey
}, (response) => {
console.log(response);
});
} else {
alert('PIXA Keychain is not installed');
}requestCreateClaimedAccountCreates an account with an account ticket.
| Parameter | Type | What it is |
|---|---|---|
username | String | Pixa account to perform the request |
new_account | String | New account to be created |
owner | String | Owner authority, as JSON |
active | String | Active authority, as JSON |
posting | String | Posting authority, as JSON |
memo | String | public memo key |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
requestAddAccountAuthorityGives another account authority over this one.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
authorizedUsername | String | Authorized account |
role | String | Type of authority. Can be 'Posting' or 'Active' |
weight | number | Weight of the authority |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Gives @pixtopia active authority with weight 2 to `account`
const keychain = window.pixa_keychain
keychain.requestAddAccountAuthority(account, 'pixtopia', 'Active', 2, (response) => {
console.log(response);
});requestRemoveAccountAuthorityTakes an account’s authority away.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
authorizedUsername | String | Account to lose authority |
role | String | Type of authority. Can be 'Posting' or 'Active' |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
// Removes @pixtopia's active authority from `account`
const keychain = window.pixa_keychain;
keychain.requestRemoveAccountAuthority(account, 'pixtopia', 'Active', (response) => {
console.log(response);
});requestAddKeyAuthorityAdds a public key to this account’s authority.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
authorizedKey | String | New public key to be associated with the account |
role | String | Type of authority. Can be 'Posting' or 'Active' |
weight | number | Weight of the key authority |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestAddKeyAuthority(username, publicKey, 'Posting', 1, (response) => {
console.log(response);
});requestRemoveKeyAuthorityTakes a public key out of this account’s authority.
| Parameter | Type | What it is |
|---|---|---|
account | String | Pixa account to perform the request |
authorizedKey | String | Key to be removed (public key). |
role | String | Type of authority. Can be 'Posting' or 'Active' |
callback | function | Function that handles the wallet’s response to the request |
rpc (optional) | String | Ignored. The wallet always uses the person's own node |
const keychain = window.pixa_keychain;
keychain.requestRemoveKeyAuthority(username, publicKey, 'Posting', (response) => {
console.log(response);
});Stuck, or found a gap?
Open an issue, or send a fix. It’s all on GitHub. If you’ve built something with it, we’d love to see it: find us at @pixtopia on Pixa.