> 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/evm-based-similar-approach-token-management-with-psdata.md).

# EVM based similar approach-  Token Management With PSDATA

*<mark style="color:red;">**Attention! , Below code lines are only sample. And Pirichain has more powerful token management using with**</mark>* [*<mark style="color:red;">**sendToken**</mark>*](/psce-functions/sendtoken.md) *<mark style="color:red;">**or**</mark>* [*<mark style="color:red;">**sendPIRI**</mark>*](/psce-functions/sendpiri.md) *<mark style="color:red;">**functions. If you want to create a new token which used under code lines , its up your decision. But commission might be more than classic sendToken and sendPIRI functions.**</mark>*

*<mark style="color:red;">**Accumulator can serve many of different conditions and situations that you can use.**</mark>*

{% code lineNumbers="true" %}

```javascript
const myTokenName="WhateverTokenName";
const tokenTotalSupply=10000000;
const decimal=18;

async function transfer(to,amount)
{
    if (isNaN(parseFloat(amount)) || parseFloat(amount)<=0)
        return {error:1,message:'Amount cannot be wrong format or negative or zero!'};
    
    
    let myBalance=PSDATA[EXECUTER_ADDRESS];
    if (myBalance!==undefined)
    {
        if (!isNaN(parseFloat(myBalance)))
        {
            myBalance=parseFloat(myBalance);
            if (parseFloat(myBalance)-parseFloat(amount)<0)
            {
                return {error:1,message:'Insufficent Balance '+myTokenName};
            }
            else
            {
                let receiptBalance=PSDATA[to];
                if (receiptBalance===undefined)
                    receiptBalance=0;
                    receiptBalance+=parseFloat(amount);
                    
                PSDATA[to]=receiptBalance;
                PSDATA[EXECUTER_ADDRESS]-=parseFloat(amount);
                return await Map.saveMap(JSON.stringify(PSDATA));
                
            }
        }
        else return {error:1,message:'Balance is not true format!'};
    }
    else
        return {error:1,message:'Insufficent Balance '+myTokenName};
}

async function mint(mintAmount)
{
    if (isNaN(parseFloat(mintAmount)) || parseFloat(mintAmount)<=0)
        return {error:1,message:'mintAmount cannot be wrong format or negative or zero!'};
    
    if (EXECUTER_ADDRESS!=OWNER_ADDRESS)
        return {error:1,message:'This function can only be executed by Scenario Owner!'}
    else
    {
        let totalMint=PSDATA['totalMinted']==undefined?0:parseFloat(PSDATA['totalMinted']);
        totalMint+=mintAmount;
        
        if (totalMint>=tokenTotalSupply)
            return {error:1,message:'Total mint cannot be increased!'};
        else
        {
             let ownerBalance=PSDATA[OWNER_ADDRESS]==undefined
             ?
             0
             :
             parseFloat(PSDATA[OWNER_ADDRESS]);
             
             ownerBalance+=mintAmount;
             PSDATA['totalMinted']=totalMint;
             PSDATA[OWNER_ADDRESS]=ownerBalance;
             return await Map.saveMap(JSON.stringify(PSDATA));

        }
    }
}
async function listTokenTransactions(skip,limit)
{
    return await Transaction.listTransactions(EXECUTER_SCENARIOADDRESS,skip,limit);

}
async function getBalance(address)
{
    return PSDATA[address]===undefined
    ?
    0
    :
    PSDATA[address];
}

async function getBalanceExecuter()
{
    return getBalance(EXECUTER_ADDRESS);
}

async function getBalance(address)
{
    return PSDATA[address]===undefined
    ?
    0
    :
    PSDATA[address];
}
async function getCirculationSupply()
{
    return PSDATA['totalMinted']==undefined?0:PSDATA['totalMinted'];
}
async function getTokenName()
{
    return myTokenName;
}
async function getTotalSupply()
{
    return tokenTotalSupply;
}
async function getDecimal()
{
    return decimal;
}
```

{% endcode %}


---

# 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/evm-based-similar-approach-token-management-with-psdata.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.
