Fractal
  • Overview
  • Basics
    • Architecture
  • Key Concepts
    • Fractal Confluence: The EVM Layer
    • The Confluence Bridge
    • Fractal Spring: The UTXO Layer
      • Concepts
      • Technical Specifications
    • Staking
      • Overview
      • EVM Staking
        • UTXO Staking and EVM Staking
      • Consensus
      • Rewards
      • Penalties
  • Developers
    • Acquire Testnet FRA
    • EVM Tools & Tutorials
      • Contract Deployment
        • Ganache
        • Hardhat
        • Remix
        • Truffle
        • Waffle
      • The Graph
    • Developer SDKs
      • UTXO Native Chain SDK
        • Fractal Spring (UTXO Layer) SDK Installation
        • Developer Tools
          • Fractal CLI Tool
        • UTXO API Reference
          • Account
          • Keypair
          • Network
          • Asset
          • Staking
          • Transaction
          • Helpers
      • The Confluence Bridge SDK
    • EVM References
      • Metamask
      • Local Development Network Setup
      • EVM API Reference
      • Precompiled Contracts
  • Network Settings
    • Contract Addresses
    • Network Settings
  • User Guides
    • Fractal Wallet Guides
      • MetaMask
        • Download
        • Configure (Auto)
        • Configure (Manual)
      • Fractal Wallet
        • Download
        • New Wallet
        • Transfer Tokens in the Fractal Wallet
        • The Confluence Bridge
        • Adding Custom Assets to the Fractal Wallet
        • Manage Assets
      • Ledger Hardware Wallet
    • Acquire FRA
    • Explore Testnet
    • Acquire FRA (Testnet)
    • Stake FRA
    • How to Use Block Explorers
    • Bridging Tokens to Fractal
  • Validator Materials
    • 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
  1. Developers
  2. Developer SDKs

The Confluence Bridge SDK

The Confluence Bridge SDK is a development kit for integrating Confluence to DApps/Apps and utilize the privacy features from the Findora Native chain. Here are some basic examples for using the Confluence Bridge SDK. More details of the usage can be found here.

  1. SDK Initialization

import * as dotenv from 'dotenv';
import { initSdk } from './utils/sdkInit';

dotenv.config();
async function main() {
  console.log('Init SDK...');
  await initSdk();
}
  1. Send assets from the UTXO layer (Fractal Spring) to the EVM layer (Fractal Confluence):

import * as dotenv from 'dotenv';
import { initSdk } from './utils/sdkInit';
import { getNativeWallet, getEvmWallet } from './utils/getWallet';
import { nativeToEvm } from './prism';
import { NETWORK_CONFIG } from './config';

dotenv.config();

async function main() {
  console.log('Init SDK...');
  await initSdk();

  const findoraSdk = await import('@findora-network/findora-sdk.js');
  const { Asset: AssetApi } = findoraSdk.Api;

  console.log('Get Wallet...');
  const nativeWallet = await getNativeWallet();
  const evmWallet = await getEvmWallet();
  console.log('Run - Native To Evm');
  
  // Send FRA
  console.log('1、[send FRA]');
  await nativeToEvm(nativeWallet, evmWallet, await AssetApi.getFraAssetCode());
  // Send FRC20
  console.log('2、[send FRC20]');
  const frc20AssetCode = await findoraSdk.Api.Evm.hashAddressTofraAddress(
    NETWORK_CONFIG.tokens.FRC20,
    );
  await nativeToEvm(nativeWallet, evmWallet, frc20AssetCode);
  // Send FRC721
  console.log('3、[send FRC721]');
  const frc721AssetCode = await findoraSdk.Api.Evm.hashAddressTofraAddressByNFT(
    NETWORK_CONFIG.tokens.FRC721, //  NFT contract address on EVM
    '1', // nft tokenID on EVM
    );
  await nativeToEvm(nativeWallet, evmWallet, frc721AssetCode);
  // Send FRC1155
  console.log('4、[send FRC1155]');
  const frc1155AssetCode =
      await findoraSdk.Api.Evm.hashAddressTofraAddressByNFT(
          NETWORK_CONFIG.tokens.FRC1155, // NFT contract address on EVM
          '0', // nft tokenID on EVM
        );
  await nativeToEvm(nativeWallet, evmWallet, frc1155AssetCode);
  
  console.log('End!');
}

main().catch((err) => console.log(err.message));
  1. Send asset from EVM chain to UTXO chain

import * as dotenv from 'dotenv';
import { initSdk } from './utils/sdkInit';
import { getNativeWallet, getEvmWallet } from './utils/getWallet';
import {
  evmToNativeOfToken,
  evmToNativeOfFRC721,
  evmToNativeOfFRC1155,
} from './prism';
import { NETWORK_CONFIG } from './config';

dotenv.config();

async function main() {
  console.log('Init SDK...');
  await initSdk();

  const findoraSdk = await import('@findora-network/findora-sdk.js');
  const { Asset: AssetApi } = findoraSdk.Api;

  console.log('Get Wallet...');
  const nativeWallet = await getNativeWallet();
  const evmWallet = await getEvmWallet();
  
  console.log('Run - Evm To Native');
  
  // Send FRA
  console.log('1、[send FRA]');
  await evmToNativeOfToken(
      nativeWallet,
      evmWallet,
      '0x0000000000000000000000000000000000001000',
      'FRA',
  );
  // Sned FRC20
  console.log('2、[send FRC20]');
  await evmToNativeOfToken(
      nativeWallet,
      evmWallet,
      NETWORK_CONFIG.tokens.FRC20,
      'FRC20',
  );
  //Send FRC721
  console.log('3、[send FRC721]');
  await evmToNativeOfFRC721(
      nativeWallet,
      evmWallet,
      NETWORK_CONFIG.tokens.FRC721,
      '0', // tokenID
  );
  // Send FRC1155
  console.log('4、[send FRC1155]');
  await evmToNativeOfFRC1155(
      nativeWallet,
      evmWallet,
      NETWORK_CONFIG.tokens.FRC1155,
      '0', // tokenID
      '1', // token amount ,  amount of nft 1155 to be transffered
  );
  
  console.log('End!');
}

main().catch((err) => console.log(err.message));
PreviousHelpersNextEVM References

Last updated 1 year ago