> For the complete documentation index, see [llms.txt](https://smartscenarios.pirichain.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smartscenarios.pirichain.com/psce-functions/examples/what-an-easy-to-build-up-your-metaverse-planet-in-pirichain.md).

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

<figure><img src="/files/5I8nvC6ZjnnfYlr04Gw1" alt=""><figcaption><p>A sample Metaverse Planet </p></figcaption></figure>

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.

```javascript

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.

```javascript
 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**).

```javascript
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).

```javascript
 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.\ <br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://smartscenarios.pirichain.com/psce-functions/examples/what-an-easy-to-build-up-your-metaverse-planet-in-pirichain.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
