Minting

Yep, we mint assets...

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:

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.

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:

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.

Last updated