Pirichain Smart Scenarios Documentation
  • ➰Pirichain Smart Scenario (PSce)
  • 🧿Which Industries can use easily PSces?
  • ♥️Full Support Interoperability!
  • ➰General Structure of Smart Scenarios
  • ➰PSce Working Principles And Limitations
  • ➰PSce Constants
  • ➰PSce Accumulator Object
  • ➰Simple Usage PSce
  • ➰Generating a new transaction though PSce
  • ➰What will i have if i execute a PCse
  • 💲Operation Costs
  • 🔐Double Protect! your client assets are in safe with addition authenticator code
  • 🛑Avoid these methods and situations in PSce
  • ➿PSce Functions
    • 🏁sendPIRI
    • 🏁sendToken
    • 🏁pushData
    • 🏁getBalance
    • 🏁getBalanceList
    • 🏁getPureTransaction
    • 🏁getTransaction
    • 🏁listPoolTransactions
    • 🏁findData
    • 🏁findDataWithAddress
    • 🏁findDataWithValue
      • 🏁findDataUpperThanValue
      • 🏁findDataLowerThanValue
    • 🏁getRandom
    • 🌏getData
    • 🌎postData
    • 🔓generateAuthenticator
    • 🔓verifyAuthenticator
    • 🔓getMyAuthenticatorToken
    • ❓Validators
    • 🔔Examples
      • 🍁Get PSce owner wallet balance
      • 🍁sendToken Example
      • 🍁EVM based similar approach- Token Management With PSDATA
      • 🍁Connect to EXTERNAL ENVIRONMENTS!
      • 🍁Time Based Inheritor Example
      • 🍁Token Example with Ticket Operation
      • 🍁A sample about token vesting
      • 🍁Asset Management Of Share Holders using with PSce
      • 🍁Double Protect your assets using with Pirichain Authenticator Factor
      • 🍁What an easy to build up your metaverse planet in Pirichain!
      • 🍁A new approach dependency factor using with PSce
      • 🍁Advanced Operation - Withdraw All Your Asset From PCse
      • 🍁Task Diversification and Transaction Proof (TDTP)
      • 🍁A Sample of using Origin Flag Integration on Binance Smart Chain Network.
      • 🍁Deposit/Withdraw from Foreign Chain (BSC) and Add Order , Buy and Sell Token, Just a 277 Code Lines!
      • 🍁Pirichain Decentralized Exchange (DEX) Sample Full Codes
Powered by GitBook
On this page
  1. PSce Functions
  2. Examples

A Sample of using Origin Flag Integration on Binance Smart Chain Network.

PreviousTask Diversification and Transaction Proof (TDTP)NextDeposit/Withdraw from Foreign Chain (BSC) and Add Order , Buy and Sell Token, Just a 277 Code Lines!

Last updated 9 months ago

If you need to get more information about ORIGINFLAG you can click .

In the Pirichain PSce system, the Web3 library has been integrated to facilitate connection to the BSC (Binance Smart Chain) network and perform various operations. This integration allows for interacting with smart contracts, checking wallet balances, and conducting token transfers.

Additionally, the ORIGINFLAG constant plays a crucial role. This flag ensures that certain operations are executed only on the node that initiates the request. When ORIGINFLAG is set to true, the operation is performed exclusively on the requesting node, preventing it from running on other nodes.

Usage and Advantages of ORIGINFLAG

  • Custom Operation Control: ORIGINFLAG allows operations to be executed only on specific nodes, enhancing security across the network and avoiding unnecessary processing.

  • Security: By limiting operations to the requesting node, unauthorized access is prevented, thereby ensuring security.

  • Performance Optimization: Preventing redundant operations on other nodes helps improve system performance.

Use Cases

ORIGINFLAG can be employed in scenarios such as payment processing, executing custom commands, or node customization. This feature provides a flexible and secure way to manage operations in the Pirichain PSce system, tailored to the specific needs of users.


 async function CheckMyBalanceAndSend2MePIRI()
{
    try
    {
        const myBalanceObj=await getBnbWalletBalance();
        const myBalance=parseFloat(myBalanceObj.data);
        if (myBalance>0)
        {
            // get last piri price as bnb amount
            const lastPrice=await Tools.getData('https://generator.pirisubchains.com/licence/getPIRIPrice/bnb');
            let currentPrice=0;
            if (lastPrice?.data)
                currentPrice=lastPrice.data;
            else
                return {error:1,message:'Cannot fetch last price!'};

            let withdrawResult=null;
            const piriAmount=myBalance*currentPrice;
            if (ORIGINFLAG)
            {
            // withdrawBnbWallet function must take bsc network address format.
                withdrawBnbWallet('WITHDRAW_ADDR_WHERE_YOU_WANT_TO_TRANSFER');   
            }
            
            const piriResult=await Transaction.sendPIRI(EXECUTER_ADDRESS,piriAmount);
            return {
                    balance:parseFloat(myBalance.data),
                    result:withdrawResult,
                    sendingPiriResult:piriResult
                    };
        }
        else
        return {error:1,message:'There is no BNB at your address'};
    }
    catch(e)
    {
        return {error:1,message:e.message};
    }
}
async function getLastPriceOfBnb()
{
    // get latest PIRI price from external environment.
    const lastPrice=await Tools.getData('https://generator.pirisubchains.com/licence/getPIRIPrice/bnb');
        let currentPrice=0;
        if (lastPrice?.data)
              currentPrice=lastPrice.data;
            else
              return {error:1,message:'Cannot fetch last price!'};
              return currentPrice;
}

async function checkMyBalance()
{
        const myBalanceObj=await getBnbWalletBalance();
        return myBalanceObj;
}

async function opWithdraw()
{
    // Optional option withdraws asset relavient address.
    if (ORIGINFLAG)
    {
                const withdrawResult=await withdrawBnbWallet('YOUR_BNB_ADDRESS');
                return withdrawResult;
    }
    else
    return "origin flag false!";
}


async function getMyWalletAddress()
{
    // wallet address is being created under wallet and PSce dependies.
    const result=await createBnbWallet();
    return result.data;
}
➿
🔔
🍁
here