> For the complete documentation index, see [llms.txt](https://docs.oceanprotocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oceanprotocol.com/developers/ocean.js/mint-datatoken.md).

# Mint Datatokens

This tutorial guides you through the process of minting datatokens and sending them to a receiver address. The tutorial assumes that you already have the address of the datatoken contract which is owned by you.

#### Prerequisites

* [Obtain an API key](/developers/get-api-keys-for-blockchain-access.md)
* [Set up the .env file](/developers/ocean.js/configuration.md#create-a-env-file)
* [Install the dependencies](/developers/ocean.js/configuration.md#setup-dependencies)
* [Create a configuration file](/developers/ocean.js/configuration.md#create-a-configuration-file)

#### Create a script to mint datatokens

Create a new file in the same working directory where configuration file (`config.js`) and `.env` files are present, and copy the code as listed below.

{% tabs %}
{% tab title="mint\_datatoken.js" %}
{% code title="mint\_datatoken.js" overflow="wrap" %}

```javascript
// Note: Make sure .env file and config.js are created and setup correctly
const { oceanConfig } = require('./config.js');
const { amountToUnits } = require ('@oceanprotocol/lib');
const ethers = require('ethers');

// Define a function createFRE()
const createMINT = async () => {

    let config = await oceanConfig();
    const publisher = config.publisherAccount
    const publisherAccount = await config.publisherAccount.getAddress()

    const minAbi = [
        {
        constant: false,
        inputs: [
            { name: 'to', type: 'address' },
            { name: 'value', type: 'uint256' }
        ],
        name: 'mint',
        outputs: [{ name: '', type: 'bool' }],
        payable: false,
        stateMutability: 'nonpayable',
        type: 'function'
        }
    ]

    const tokenContract = new ethers.Contract(config.oceanTokenAddress, minAbi, publisher)
    const estGasPublisher = await tokenContract.estimateGas.mint(
        publisherAccount,
        amountToUnits(null, null, '1000', 18)
    )
    const trxReceipt = await sendTx(
        estGasPublisher,
        publisher,
        1,
        tokenContract.mint,
        publisherAccount,
        amountToUnits(null, null, '1000', 18)
    )
    
    return {
        trxReceipt
    };
};

// Call the createFRE() function 
createMINT()
  .then(({ trxReceipt }) => {
    console.log(`TX Receipt ${trxReceipt}`);
    process.exit(1);
  })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });
```

{% endcode %}

**Execute script**

```bash
node mint_datatoken.js
```

{% endtab %}
{% endtabs %}


---

# 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://docs.oceanprotocol.com/developers/ocean.js/mint-datatoken.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.
