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

What an easy to build up your metaverse planet in Pirichain!

PreviousDouble Protect your assets using with Pirichain Authenticator FactorNextA new approach dependency factor using with PSce

Last updated 1 year ago

We know that blockchain systems can support to metaverse systems. And we will show how to easily establish your metaverse planet via Pirichain Smart Scenarios. Of course this model can be transformed to more and more complicated structure. This is the one of simplest model of using metaverse concept.

First system needs to generate the metaverse properties to use. We explained the this structure in below code lines (generateMyMetaVersePlanet). As we see that system will have coordinates such a x and y. And system defined the PSce owner address as a coordinate each place owner. And price has been defined 10 PIRI default.


async function generateMyMetaVersePlanet()
 {
     if (PSDATA["metaCreated"]!=undefined)
     return {error:1,message:'Metaverse Planet has been already generated!'};
        PSDATA["metaCreated"]=true;
        for (let x=1;x<10;x++)
            for (let y=1;y<10;y++)
            // has been sold?
            {
                PSDATA["coordinate_x_"+x+'_y_'+y]=false;
                // opening price!
                PSDATA["coordinate_x_"+x+'_y_'+y+"_PRICE"]=10;
                // Owner Address which has belong to this place
                PSDATA["coordinate_x_"+x+'_y_'+y+'_ownerAddress']=OWNER_ADDRESS;
            }
        return await Map.saveMap(JSON.stringify(PSDATA));
 }

Second method is key maker because all of operation will be done via buyMetaversePlace Method. It has 4 parameters ;

x: Desired place x coordinate to buy, y: Desired place y coordinate to buy , receiptAddress: new Metaverse place owner address and newamount: Last Price which will defined from new owner.

 async function buyMetaversePlace(x,y,receiptAddress,newAmount)
 {
        if (PSDATA["coordinate_x_"+x+'_y_'+y+'_ownerAddress']!=EXECUTER_ADDRESS)
            return {error:1,message:'This place is not belong your address!'};
        if (AMOUNT<0)
        return {error:1,message:'Please Send Metaverse Place Amount! ('+PSDATA["coordinate_x_"+x+'_y_'+y+"_PRICE"]+')'};
        if (!AMOUNT)
        return {error:1,message:'Please Send Metaverse Place Amount! ('+PSDATA["coordinate_x_"+x+'_y_'+y+"_PRICE"]+')'};

        if (AMOUNT<parseFloat(PSDATA["coordinate_x_"+x+'_y_'+y+"_PRICE"]))
            return {error:1,message:'This place is higher than '+minPIRIQuantity+' !'};
            
            PSDATA["coordinate_x_"+x+'_y_'+y+"_PRICE"]=parseFloat(newAmount);
            let metaverOwnerAddress=PSDATA["coordinate_x_"+x+'_y_'+y+'_ownerAddress'];
            if (PSDATA[metaverOwnerAddress]==undefined)
                PSDATA[metaverOwnerAddress]=0;

            PSDATA[metaverOwnerAddress]+=parseFloat(AMOUNT);
            PSDATA["coordinate_x_"+x+'_y_'+y+'_ownerAddress']=receiptAddress;
            return await Map.saveMap(JSON.stringify(PSDATA));
 }

In explanation of above code lines, If PIRI is sent at the price requested by the owner of the previous commodity universe, the system will automatically sell the place. Otherwise, it will give the warning in Line 30 and the sale will not occur. On the other hand, the smart scenario is a kind of custodian. And sends the relevant amount to the owner of the metaverse location. New owner can change last sell price how much he wants to sell current place.

The former owner can withdraw the PIRI asset arising from the place of sale to his own wallet whenever he wants. Explained in below sample (withdrawMySoldPlacePIRI function).

async function withdrawMySoldPlacePIRI()
 {
     if (parseFloat(PSDATA[EXECUTER_ADDRESS])>0)
     {
         PSDATA[EXECUTER_ADDRESS]=0;
        return await Transaction.sendPIRI(EXECUTER_ADDRESS,parseFloat(PSDATA[EXECUTER_ADDRESS]));
     }
        else
        return {error:1,message:'Your Amount is not upper than zero!'};

 }

If you want to see all metaver details , you can use the below code lines (listAllMetaVersePlaces).

 async function listAllMetaVersePlaces()
 {
     return PSDATA;
 }

You have seen how easily the design and sales operations of the metaverse world on the coordinate plane can be modeled through Pirichain. You can design operations like this or more complex ones very easily and effectively via Pirichain.

➿
🔔
🍁
A sample Metaverse Planet