# Minting

The buyer creates a representation in JSON format of the entire trade. We are still defining the JSON structure but it will be something like this:

```javascript
let tradeInfo = {
  counterPart: '0xSomeCountearpart',
  description: 'Show me the money',
  payments: [
    {
      amount: 100,
      collateral: 10,
      type: 'stream',
      startDate: '2022-12-12',
      endDate: '2023-12-12'
    }
  ]
}
```

### Approval

When minting an asset, the seller pays a fee to the DAO. This fee is dependent on the tokens the asset is linked to. If an asset deals in two tokens, then a fee is paid for each token.

Prior to minting the asset, the seller must approve a transfer for each token.

```javascript
await seller.invoke(
    txFlowContract, 
    'approve', 
    { spender: txAssetContract.address, amount: toUint256WithFelts("5") }, 
    { maxFee: FEE}
)
```

### Initiate

As previously stated, initiating the asset means we are minting an NFT. This minting happens by calling a custom function as per the code below:

```javascript
const txHash = await seller.invoke(
    txAssetContract, 
    "init", 
    { 
      counterpart: buyer.starknetContract.address, 
      agreementTerms: strToFeltArr(JSON.stringify(tradeInfo)),
      tokens: [txFlowContract.address],
      members: [member1.starknetContract.address, member2.starknetContract.address],
      weights: [2, 1]
    },
    { maxFee: FEE}
  )

let txReceipt = await starknet.getTransactionReceipt(txHash)
let tokenId = fromUint256WithFelts({ low: BigInt(txReceipt['events'][0]['data'][0]), high: BigInt(txReceipt['events'][0]['data'][1]) })
```

Minting the asset results in a **tokenId** which is used to identify the asset in the platform.

### Members

Assets can have beneficial members different to the owner of the asset. These members are able to withdraw tokens that are in the balance of the Asset / NFT. The percentage of the tokens that the members are able to withdraw are defined by the weights. In the case above, member 1 is able to withdraw 2 / 3 the total tokens while member 2 can withdraw 1 / 3.


---

# Agent Instructions: 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:

```
GET https://docs.tradeflows.io/guides/getting-started/assets/minting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
