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.

JavaScript
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 null as the account and the person picks one in the wallet. The answer says which, in data.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.username is only a claim until the signature proves it.
In the browser
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,
  });
});
On your server (Node)
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.

Sign a test message

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.

  • requestVote for likes, weight from -10000 to 10000.
  • requestCustomJson for follows and your app’s own data. It shows your message, the ID and the data.
  • requestPost for posts and replies.
  • requestTransfer and the other money requests.
  • requestBroadcast for any other operations.
  • requestSignTx if 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.

A follow
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);
  },
);
A transaction you broadcast yourself
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.

FieldWhat it is
successtrue if it worked
resultWhat the request produced, such as a signature or the broadcast’s result
errorWhy it didn’t work
messageA sentence you can show
dataThe request as the wallet received it
publicKeyThe public key that signed, when there is one
request_idThe number of this request

The errors you’ll want to handle

user_cancelThe person said no. Say nothing more.
incompleteThe request wasn’t valid. message says why.
ignoredA newer request from this page replaced this one.
busyThe last request is already being sent. Wait for it.
A promise, one request at a time
// 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 with busy if the last one is already being sent.
  • Amounts are strings with three decimals ("1.000"), in PIXA and PXS. Delegations are in PP or VESTS. A request in HIVE or HBD is 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. rpc is still accepted, but ignored.
  • Titles are the wallet’s. title in requestSignBuffer is 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_json sent through requestBroadcast or requestSignTx, unless it’s a follow or a portal action. Send your app’s own data with requestCustomJson instead, 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 PIXA and PXS, and pixa and pxs in field names like percent_pxs.
  • Public keys start with PIX, and the node is api.pixagram.com.
  • requestSignedCall is disabled. Use requestBroadcast or requestSignTx.
  • There’s no Hive Engine, swaps, multisig or HiveAuth here.
The one line that changes most
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.

Terminal
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.
ParameterTypeWhat it is
callbackfunctionConfirms Keychain installation (has no parameters)
requestSignBufferSigns a message, which is how you sign someone in.
ParameterTypeWhat it is
account (optional)StringPixa account to perform the request. If null, user can choose the account from a dropdown
messageStringMessage to be signed by the account
keyStringType of key. Can be 'Posting','Active' or 'Memo'
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
title (optional)StringIgnored. The wallet writes its own title
requestVerifyKeyAsks the wallet to decode a message, to show it holds a key.
ParameterTypeWhat it is
accountStringPixa account to perform the request
messageStringMessage to be decoded by the account
keyStringType of key. Can be 'Posting','Active' or 'Memo'
callbackfunctionFunction that handles the wallet’s response to the request
Example
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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
receiverStringAccount that will decode the string
messageStringMessage to be encrypted. It has to start with #
keyStringType of key. Can be 'Posting','Active' or 'Memo'
callbackfunctionFunction that handles the wallet’s response to the request
Example
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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
publicKeysArray<String>Key that can decode the string
messageStringMessage to be encrypted. It has to start with #
keyStringType of key. Can be 'Posting','Active' or 'Memo'
callbackfunctionFunction that handles the wallet’s response to the request
Example
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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
titleStringTitle of the blog post
bodyStringContent of the blog post
parent_permStringPermlink of the parent post. Main tag for a root post
parent_accountStringAuthor of the parent post. Pass '' for a root post
json_metadataStringThe post's metadata, as JSON
permlinkStringPermlink of the blog post
comment_optionsStringReward settings for this post, as JSON, or ''. They must name this author and permlink, and they're shown in the review
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
permlinkStringPermlink of the blog post
authorStringAuthor of the blog post
weightNumberWeight of the vote, comprised between -10,000 (-100%) and 10,000 (100%)
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
account (optional)StringPixa account to perform the request. If null, user can choose the account from a dropdown
idStringType of custom_json to be broadcasted
keyStringType of key. Can be 'Posting' or 'Active'
jsonStringStringified custom json
display_msgStringMessage to display to explain to the user what this broadcast is about
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
operationsArrayArray of operations to be broadcasted
keyStringType of key. Can be 'Posting' or 'Active'
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
txObjectUnsigned transaction
keyStringType of key. Can be 'Posting' or 'Active'
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
toStringPixa account to receive the transfer
amountStringAmount to be transferred. Requires 3 decimals.
memoStringThe 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
currencyString'PIXA' or 'PXS'
callbackfunctionFunction that handles the wallet’s response to the request
enforce (optional)booleanIf set to true, the person can’t choose to make the transfer from another account
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
const keychain = window.pixa_keychain;
keychain.requestTransfer(username, toUsername, '1.000', '', 'PIXA', (response) => {
  console.log(response)
}, true);
requestRecurrentTransferSets up a transfer that repeats.
ParameterTypeWhat it is
username (optional)StringPixa account to perform the request
toStringPixa account receiving the transfers.
amountStringamount to be sent on each execution.
currencyStringPIXA or PXS on mainnet.
memoStringtransfer memo
recurrenceNumberHow often will the payment be triggered (in hours) - minimum 24.
executionsNumberThe times the recurrent payment will be executed - minimum 2.
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
pair_id (optional)NumberPair id of the recurrent transfer
Example
// 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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
toStringAccount to receive the savings transfer
amountStringAmount to be transferred. Requires 3 decimals.
currencyString'PIXA' or 'PXS'
operationString'deposit' or 'withdraw'
memo (optional)StringMemo attached to the savings operation
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
const keychain = window.pixa_keychain;
keychain.requestSavingsOperation(username, toUsername, '1.000', 'PXS', 'deposit', 'test memo', (response) => {
  console.log(response);
});
requestConversionConverts between PXS and PIXA.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
amountStringamount to be converted.
collaterizedBooleantrue to convert PIXA to PXS. false to convert PXS to PIXA.
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
recipientStringAccount to receive the power up
hiveStringAmount of PIXA to be powered up
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
hive_powerStringAmount of PIXA to be powered down
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
username (optional)StringPixa account to perform the request. If null, user can choose the account from a dropdown
delegateeStringAccount to receive the delegation
amountStringAmount to be transferred. Requires 3 decimals for PP, 6 for VESTS.
unitStringPP or VESTS
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
username (optional)StringPixa account to perform the request. If null, user can choose the account from a dropdown
witnessStringAccount to receive the witness vote
votebooleanSet to true to vote for the witness, false to unvote
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
username (optional)StringPixa account to perform the request. If null, user can choose the account from a dropdown
proxyStringAccount to become the proxy. Empty string ('') to remove a proxy
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
receiverStringAccount receiving the funding if the proposal is voted
subjectStringTitle of the proposal
permlinkStringPermlink to the proposal description
daily_payStringDaily amount to be received by receiver, such as '10.000 PXS'
startStringStarting date, such as '2027-01-01T00:00:00'
endStringEnding date, in the same form
extensionsStringStringified Array of extensions
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
proposal_idsStringStringified Array of ids of the proposals to be removed
extensionsStringStringified Array of extensions
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
proposal_idsStringStringified Array of Ids of the proposals to be voted
approvebooleanSet to true to support the proposal, false to remove a vote
extensionsStringStringified Array of extensions
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
usernameStringusername of the account to be added
keysObjectprivate keys of the account : {active:'...',posting:'...',memo:'...'}. At least one must be specified. Alternatively, authorized accounts can be specified with @${username}.
callbackfunctionFunction that handles the wallet’s response to the request
Example
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.
ParameterTypeWhat it is
usernameStringPixa account to perform the request
new_accountStringNew account to be created
ownerStringOwner authority, as JSON
activeStringActive authority, as JSON
postingStringPosting authority, as JSON
memoStringpublic memo key
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
requestAddAccountAuthorityGives another account authority over this one.
ParameterTypeWhat it is
accountStringPixa account to perform the request
authorizedUsernameStringAuthorized account
roleStringType of authority. Can be 'Posting' or 'Active'
weightnumberWeight of the authority
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
authorizedUsernameStringAccount to lose authority
roleStringType of authority. Can be 'Posting' or 'Active'
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
// 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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
authorizedKeyStringNew public key to be associated with the account
roleStringType of authority. Can be 'Posting' or 'Active'
weightnumberWeight of the key authority
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.
ParameterTypeWhat it is
accountStringPixa account to perform the request
authorizedKeyStringKey to be removed (public key).
roleStringType of authority. Can be 'Posting' or 'Active'
callbackfunctionFunction that handles the wallet’s response to the request
rpc (optional)StringIgnored. The wallet always uses the person's own node
Example
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.