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
  • Installing the Findora SDK​
  • Setting Up the Findora SDK​
  • Using the most commonly called wallet features​

Was this helpful?

Edit on GitHub
  1. Developers
  2. Developer SDKs
  3. UTXO Native Chain SDK

UTXO Native Chain SDK Installation

PreviousUTXO Native Chain SDKNextDeveloper Tools

Last updated 2 years ago

Was this helpful?

This guide will enable developers to integrate Findora Protocol features into a their wallet and discusses two key parts of this process:

  • Installing the Findora SDK

  • Setting Up the Findora SDK

  • Using the most commonly called wallet features

Developers should be able to integrate Findora features such as sending FRA to another wallet, checking the FRA balance, etc. into their crypto wallet, crypto exchange or Dapp by following this guide.

Installing the Findora SDK

To install the Findora SDK we only need to run one single command:

yarn add @findora-network/findora-sdk.js

Setting Up the Findora SDK

  • 1. Setup the Findora SDK

    // First, we need to import the findora sdk package
    const findoraSdk = await import("@findora-network/findora-sdk.js");
    
    // Before using the sdk, we need to configure it so it knows which server to connect to
    const sdkEnv = { hostUrl: "http://127.0.0.1" };
    const { Sdk } = findoraSdk;
    Sdk.default.init(sdkEnv);
    
    // That is it! after that Findora sdk is ready to use!
  • 2. Create a Findora wallet

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    // To create an account we would use one of the Findora SDK APIs.
    // In this example, we use Keypair API to create a Findora wallet
    const { Keypair: KeypairApi } = findoraSdk.Api;
    
    // This wallet info below will be used for any operation related to the SDK
    const walletInfo = await KeypairApi.createKeypair(password);
  • 3. Restore a previously created Findora wallet

    A previoulsy created wallet can be restored either using a mnemonic or a private key. Both examples are shown below.

  • Restore from a mnemonic

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
  • Restore from a private key

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
  • 4. Send FRA to another wallet

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // First step is to restore your wallet using a mnemonic phrase or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // We are going to use a native FRA asset code since we are sending FRA
    const assetCode = await AssetApi.getFraAssetCode();
    
    // Next, we create an instance of the transaction builder - that is what is going to be broadcast to the network
    const transactionBuilder = await TransactionApi.sendToAddress(
      walletInfo,
      address,
      numbers,
      assetCode,
      assetBlindRules
    );
    
    // Then we retrieve transaction data (to be broadcasted)
    const submitData = transactionBuilder.transaction();
    
    // Finally, we will be broadcasting this transaction to the network
    const result = await Network.submitTransaction(submitData);
    const { response: resultHandle } = result;
  • 5. Send FRA to multiple wallets

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // The first step is to restore your wallet using a mnemonic phrase, or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // We are going to use a native FRA asset code, since we are sending FRA
    const assetCode = await AssetApi.getFraAssetCode();
    
    // Specify how much FRA to send to each recipient
    const numbersForAlice = "0.1";
    const numbersForPeter = "0.2";
    
    // Use `getAddressPublicAndKey` helper to prepare an object with an address and public key,
    // as both values would be needed by the transaction api
    const aliceWalletInfo = await KeypairApi.getAddressPublicAndKey(aliceAddress);
    const peterWalletInfo = await KeypairApi.getAddressPublicAndKey(peterAddress);
    
    // Prepare the receipient data
    const recieversInfo = [
      { reciverWalletInfo: aliceWalletInfo, amount: numbersForAlice },
      { reciverWalletInfo: peterWalletInfo, amount: numbersForPeter },
    ];
    
    // Create an instance of the transaction builder - that is what is going to be broadcast to the network
    const transactionBuilder = await TransactionApi.sendToMany(
      walletInfo,
      recieversInfo,
      assetCode,
      assetBlindRules
    );
    
    // Then we retrieve transaction data (to be broadcasted)
    const submitData = transactionBuilder.transaction();
    
    // Finally, we will be broadcasting this transaction to the network
    const result = await Network.submitTransaction(submitData);
    const { response: resultHandle } = result;
  • 6. Create a custom asset

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // First step is to restore your wallet using a mnemonic phrase or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // Generate a random asset code to ensure it is unique and it does not yet exist
    // It should return something like 'W4-AkZy73UGA6z8pUTv4YOjRNuFwD03Bpk0YPJkKPzs=' (i.e. it will be random)
    // but it follows a certain format and that is why we need to use that helper
    const tokenCode = await AssetApi.getRandomAssetCode();
    
    // Then we create an instance of the transaction builder - that is what is going to be broadcast to the network
    const assetBuilder = await AssetApi.defineAsset(walletInfo, tokenCode);
    
    // Then we retrieve transaction data (to be broadcasted)
    const submitData = assetBuilder.transaction();
    
    // Finally, we will be broadcasting this transaction to the network
    const result = await Network.submitTransaction(submitData);
    const { response: resultHandle } = result;
  • 7. Issue Asset (Note: after creating a new asset, it has no balance. You must first "issue" the asset)

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // First, restore your wallet using a mnemonic phrase or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // Pass the asset code which you want to issue
    const tokenCode = "W4-AkZy73UGA6z8pUTv4YOjRNuFwD03Bpk0YPJkKPzs=";
    
    // Specify how much of the asset to issue?
    const amountToIssue = "5000";
    
    // Optionally, you can hide the transaction amount (i.e. the issued amount would be hidden on the block explorer)
    // For that we use AssetBlindRules - but again, it is completely optional!
    const assetBlindRules = { isAmountBlind: true };
    
    // Create an instance of the transaction builder - this is what will be broadcast to the network
    const issueAssetBuilder = await AssetApi.issueAsset(
      walletInfo,
      tokenCode,
      amountToIssue,
      assetBlindRules
    );
    
    // Then we retrieve transaction data (to be broadcasted)
    const submitData = issueAssetBuilder.transaction();
    
    // Finally, we will be broadcasting this transaction to the network
    const result = await Network.submitTransaction(submitData);
    const { response: resultHandle } = result;
  • 8. Send custom asset to another wallet

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    // This is nearly identical to sending FRA but use the custom asset code instead
    // (i.e. 'W4-AkZy73UGA6z8pUTv4YOjRNuFwD03Bpk0YPJkKPzs=') instead of using FRA asset code from AssetApi.getFraAssetCode()
    // See details below:
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // First, restore your wallet using a mnemonic phrase or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // Below is the only difference from sending FRA - the rest is exactly the same
    // const assetCode = await AssetApi.getFraAssetCode(); // <- that is to send FRA
    const assetCode = "W4-AkZy73UGA6z8pUTv4YOjRNuFwD03Bpk0YPJkKPzs="; // <- that is to send this particular asset
    
    // Create an instance of the transaction builder - that is what will be broadcast to the network
    const transactionBuilder = await TransactionApi.sendToAddress(
      walletInfo,
      address,
      numbers,
      assetCode,
      assetBlindRules
    );
    
    // Then we retrieve transaction data (to be broadcasted)
    const submitData = transactionBuilder.transaction();
    
    // Finally, we will be broadcasting this transaction to the network
    const result = await Network.submitTransaction(submitData);
    const { response: resultHandle } = result;
  • 9. Send tokens confidentially

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // First, restore your wallet using a mnemonic phrase or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // Use the native FRA asset code
    const assetCode = await AssetApi.getFraAssetCode(); // <- that is to send FRA
    // or, if we want to send custom asset, we would use smth like this
    // const assetCode = 'W4-AkZy73UGA6z8pUTv4YOjRNuFwD03Bpk0YPJkKPzs='; // <- that is to send this particular asset
    
    // Specify how much of this asset to send to recipients
    const numbersForAlice = "0.1";
    const numbersForPeter = "0.2";
    
    // We use `getAddressPublicAndKey` helper to prepare an object with an address and public key
    // as both values would be needed by the transaction api
    const aliceWalletInfo = await KeypairApi.getAddressPublicAndKey(aliceAddress);
    const peterWalletInfo = await KeypairApi.getAddressPublicAndKey(peterAddress);
    
    // Preparing receipients' data
    const recieversInfo = [
      { reciverWalletInfo: aliceWalletInfo, amount: numbersForAlice },
      { reciverWalletInfo: peterWalletInfo, amount: numbersForPeter },
    ];
    
    // Define this transaction to have a confidential value, or asset type, or both
    // For that we are creating an object with AssetBlindRules.
    // In this example we are only "hiding" the amount, and keeping the type visible.
    const assetBlindRulesForSend = { isTypeBlind: false, isAmountBlind: true };
    // If you do not want to enable a particular asset blind rule, (i.e. you are not hiding asset type)
    // then you can drop this option and keep as below:
    // const assetBlindRulesForSend = { isAmountBlind: true };
    
    // Create an instance of the transaction builder - that is what will be broadcast to the network
    const transactionBuilder = await TransactionApi.sendToMany(
      walletInfo,
      recieversInfo,
      assetCode,
      assetBlindRules
    );
    
    // Then we retrieve transaction data (to be broadcasted)
    const submitData = transactionBuilder.transaction();
    
    // Finally, we will be broadcasting this transaction to the network
    const result = await Network.submitTransaction(submitData);
    const { response: resultHandle } = result;
  • 10. Check token balance

    // Note: The SDK must be setup before you can proceed with the instructions below (i.e. see step #1)
    
    const {
      Keypair: KeypairApi,
      Asset: AssetApi,
      Transaction: TransactionApi,
    } = findoraSdk.Api;
    
    // First, restore your wallet using a mnemonic phrase or, alternatively, a private key
    // a. Restore from mnemonic
    const walletInfo = await KeypairApi.restoreFromMnemonic(
      yourMnenomic,
      password
    );
    // b. Or, alternatively, restore from private key
    const anotherWalletInfo = await KeypairApi.restoreFromPrivateKey(
      pkey,
      password
    );
    
    // By default, `getBalance` checks for FRA balance,
    // but we can pass an additional argument to check a custom asset balance
    const balance = await AccountApi.getBalance(walletInfo);
    
    const assetCode = "W4-AkZy73UGA6z8pUTv4YOjRNuFwD03Bpk0YPJkKPzs=";
    const anotherBalance = await AccountApi.getBalance(walletInfo, assetCode);

Using the most commonly called wallet features

NOTE: You can always find more examples .

​
​
​
here