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

Advanced Operation - Withdraw All Your Asset From PCse

PSce creates automatically below function for each PSce for providing to withdraw all asset type from Smart Scenario Balance.

Is it necessary to use? Its not necessary to use at each PSce. But if you remove this function before creation of PSce. No one can withdraw assets from PSce if you didn't code different withdrawal approach .

async function WithdrawAllAssetToOwnerWallet(asset_ID)
{
    if (OWNER_ADDRESS!==EXECUTER_ADDRESS)
    // Only PSce owner execute this function. otherwise return an error.
    return {error:1,data:'Only scenario owner can execute this method!'};
    
    if (asset_ID) // check asset_ID has value
    {
        if (!isNaN(parseInt(asset_ID))) // check asset_ID is numeric.
        {
            const myBalanceObject=await Transaction.getBalance(EXECUTER_SCENARIOADDRESS,-1); 
            // get Balance from PSce.
            let myBalance=parseFloat(myBalanceObject.balance);
            if (asset_ID===-1) // if its PIRI
            {
                if (myBalance<0.1) // check the balance minimum 0.1 PIRI for fee
                    return {error:1,data:'Your Piri Coin is not enough to transfer!'};
                myBalance-=0.1; // seperate for fee
                    return await Transaction.sendPIRI(OWNER_ADDRESS,myBalance); 
                    // Send asset to PSce owner wallet
            }
            else // if its a token 
            {
                if (myBalance<0.1) 
                // check the balance minimum 0.1 PIRI for fee
                    return {error:1,data:'Your Piri Coin is not enough to transfer!'};             
                const myTokenBalanceObject=await Transaction.getBalance(EXECUTER_SCENARIOADDRESS,asset_ID);
                // check PSce balance 
                let myTokenBalance=parseFloat(myTokenBalanceObject.balance);
                if (myTokenBalance>0) // check the token balance 
                    return await Transaction.sendToken(OWNER_ADDRESS,myTokenBalance,asset_ID);
                else
                return {error:1,data:'You dont have enough token balance!'};
            }

        }
    }
}

PreviousA new approach dependency factor using with PSceNextTask Diversification and Transaction Proof (TDTP)

Last updated 1 year ago

➿
🔔
🍁