How to use the @polkadot/extrinsics.default.staking function in @polkadot/extrinsics

To help you get started, we’ve selected a few @polkadot/extrinsics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / api / docs / examples / deprecated-rpc / 06_craft_extrinsic / index.js View on Github external
async function transfer (keyRingFrom, addressTo, amount) {
  const accountIndex = await getAccountIndex(keyRingFrom.address());

  console.log(`Current accountIndex: ${accountIndex}`);

  // encode the call for signing
  const message = encodeExtrinsic(
    keyRingFrom.publicKey(),
    accountIndex,
    extrinsics.staking.public.transfer,
    [addressTo, amount]
  );

  // get the signature
  const signature = keyRingFrom.sign(message);

  // encode the extrinsic for submission, adding the length (prefix) and the
  // signature (postfix)Rödl
  const encoded = encodeLength(
    // When working with publicKeys, the prefix is 0xff for poc-2+
    new Uint8Array([0xff]),
    message,
    signature
  );

  return api.author.submitExtrinsic(encoded);
github polkadot-js / api / docs / examples / deprecated-rpc / 07_transfer_dots / index.js View on Github external
async function transfer (keyRingFrom, addressTo, amount) {
  const nextAccountIndex = await getAccountIndex(keyRingFrom.address());

  // encode the call for signing
  const encoded = encodeExtrinsic(
    keyRingFrom,
    nextAccountIndex,
    extrinsics.staking.public.transfer,
    [addressTo, amount]
  );

  await api.author.submitExtrinsic(encoded)
    .catch(e => console.log);
}