LogoLogo
  • Overview
  • Basics
    • Architecture
  • Key Concepts
    • EVM Ledger
    • UTXO Chain
      • Confidential transfers
        • Overview
        • Concepts
        • Technical Specifications
    • Prism++ Transfer
    • Triple Masking
      • Overview
      • SDK Installation
      • Bar to Abar
      • Abar to Bar
      • Abar Transfer
    • Staking
      • Overview
      • EVM Staking
        • UTXO Staking and EVM Staking
        • EVM Staking Portal User Guide
      • Consensus
      • Rewards
      • Penalties
  • Developers
    • Acquire Testnet FRA
    • EVM Tools & Tutorials
      • Contract Deployment
        • Ganache
        • Hardhat
        • Remix
        • Truffle
        • Waffle
      • The Graph
      • Band Protocol
      • Mint NFTs
        • Deploy NFT Contract (1 of 3)
        • Mint NFT (2 of 3)
        • View NFT (3 of 3)
    • Developer SDKs
      • UTXO Native Chain SDK
        • UTXO Native Chain SDK Installation
        • Developer Tools
          • Findora CLI Tool
        • UTXO API Reference
          • Account
          • Keypair
          • Network
          • Asset
          • Staking
          • Transaction
          • Helpers
      • ZkRouting SDK
      • zkDID SDK
        • zkDID SDK Installation
        • zkDID API Reference
        • zkDID Example Code
      • Prism++ SDK
    • EVM References
      • Metamask
      • Local Development Network Setup
      • EVM API Reference
      • Precompiled Contracts
    • Resources
      • Bug Bounties
      • Events
        • 🏗️ETH San Francisco 2022
          • zkDID and Credentials
        • 🏗️ETH Denver 2023
    • Game-Specific Chains
      • GSC Highlights
      • User Guide
      • Developer Tools
  • Network Settings
    • Contract Addresses
    • Network Settings
  • General User Materials
    • Acquire FRA
    • Acquire FRA (Testnet)
    • Stake FRA
    • Use Wallets
      • MetaMask
        • Download
        • Configure (Auto)
        • Configure (Manual)
      • Findora Wallet
        • Download
        • New Wallet
        • Transfer
        • Prism++
        • Adding Assets to the Findora Wallet
        • Manage Assets
      • Ledger Hardware Wallet
    • Bridging Tokens to Findora
    • Use Block Explorers
    • Explore Testnet
      • Triple Masking
        • Triple Masking Demo
      • EVM Staking
      • Prism++
        • Prism++ Testing Campaign
          • 💰Testnet Wallet Setup/Funding
          • 👨‍🌾👨🌾 Peasant: Prism++ Campaign Signup
          • 🧒Pupil: FRC20 Token Transfers
          • 🧑‍🎨🧑🎨 Pilgrim: FRC 721 Token Transfers
          • 🧑‍🎓🧑🎓 Prodigy: FRC1155 Token Transfers
          • 🧑‍🚀🧑🚀 Pioneer: Mainnet Transfers
          • Prism++ Testnet Campaign FAQs
    • Gaxle Events
      • Game Chain Challenges
        • Getting Started
        • The Campaigns
        • The Reward Raffles
  • Validator Materials
    • Findora's University Program
    • Validator Setup Guides
      • System Requirements
      • Acquire a Server
      • Validator Toolbox Setup
        • New Build
        • Existing Build
        • Additional Info
      • Manual Setup
      • Automated Setup (Deprecated)
    • Upgrade Guides
      • Node Upgrade (Toolbox)
      • Node Upgrade (Manual)
      • fn CLI Upgrade (Wallet)
    • Operational Guides
      • Emergency Recovery
      • Data Backup
      • CLI Staking
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Key Concepts
  2. Triple Masking

Abar to Bar

Below you can see an example of how to perform abar to bar operation.

// An instance of the Anonymous wallet, where `abar to bar` would be sent from
const anonKeysSender = {
  axfrPublicKey: "-Gdf_hulMdWPeC2dG3RG-Hjo8yLTdWnPfB5csEGkbmg=",
  axfrSecretKey:
    "z4atlAssg_PcVa05__EXB5VbT23JF4mSdAuCUa2-fQn4Z2P-G6UzNY94LbcbdEb4eOhbItPZac8AHlywQaRbaA==",
  decKey: "1Js-MFSVJipTNL-y09zkSBakd15WLK-SfAUTTfsUInE=",
  encKey: "bim4EWU_PnClrNiVpKen4DZ0v-RwsVLSUtZy7PXCOCc=",
};

const abarToBar = async () => {
  // First, we would create an instance of a Findora Wallet using given password
  // and wallet private key. This object would be our "reciever" wallet
  const password = "1234qwe!weUR^";
  const pkey = "YOUR_WALLET_PRIVATE_KEY";
  const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);

  // Next we need to provide a commitment string which we would `transfer` to our wallet
  const givenCommitmentOne = "7TVrrpvFgH5C5jSYXxfyYZVS5ZGLVH7oWMuAMSjH8Nsg";

  // `abarToBar` operation would require instances of abars, which will be created (restored)
  // using given commitment strings
  // In the lines below we create `ownedAbarToUseAsSource` and `ownedAbarToUseAsFee` which
  // represents two abars, created from the given commitments
  const ownedAbarsResponseOne = await TripleMasking.getOwnedAbars(
    givenCommitmentOne
  );

  // This abar would be sent to the user wallet
  const [ownedAbarToUseAsSource] = ownedAbarsResponseOne;

  const ownedAbarsResponseTwo = await TripleMasking.getOwnedAbars(
    givenCommitmentTwo
  );

  // Next is a key method, which returns 2 things:
  // - an instance of the transactionBuilder, which would be used to submit the generated tx to the network
  // - an object with the information about the new commitment, which contains remanined funds after paying the fee
  // NOTE: since the abar which was used to pay the fee is being decoded and used, and its amount might be way
  // more then it was needed to cover the fee, in order to NOT lose the remained balance of that abar,
  // user must save the new commitment, available in abarToBarData.commitments property
  const { transactionBuilder, abarToBarData } = await TripleMasking.abarToBar(
    anonKeysSender,
    walletInfo.publickey,
    [ownedAbarToUseAsSource]
  );

  // Then we retrieve transaction data (to be broadcasted)
  const submitData = transactionBuilder.transaction();

  // Finally, we submut the transaction to the network to finalize the `abar to bar` operation
  // and, as a result we receive a transaction hash
  const result = await Network.submitTransaction(submitData);
  const { response: resultHandle } = result;

  // Here we simply wait for 17s until next block is produced by the network
  await sleep(17000);
};
PreviousBar to AbarNextAbar Transfer

Last updated 2 years ago

Was this helpful?