TradeFlows
  • TradeFlows
    • What is the Core Protocol?
    • Benefits of using TradeFlows
    • Innovations
    • Flows - Programmed Liquidity
    • Dharma - Collaborative Ratings
    • Smart Contracts
  • Guides
    • Getting Started
      • Assets
        • Minting
        • Agreeing
        • Composing
      • Payment Streams
        • Create
        • Pause
      • Escrows
        • Increase Collateral
        • Decrease Collateral
      • Ratings
      • Withdraw Funds
  • Use Cases
    • Web3
      • DAO Management
    • Web2
      • Building & Construction
      • Gig Economy
      • Small Business
  • Links
    • Website
    • Twitter
    • Discord
Powered by GitBook
On this page
  • Approval
  • Initiate
  • Members
  1. Guides
  2. Getting Started
  3. Assets

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.

PreviousAssetsNextAgreeing

Last updated 2 years ago