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
  1. Guides
  2. Getting Started
  3. Assets

Composing

Grouping of NFTs to create one NFT

Composing Assets / NFTs is the process of assigning owner of sub Assets / NFTs to a main Asset / NFT. The owner of the main NFT is then the beneficiary owner of the sub NFTs, but when the owner transfers the main NFT to another wallet, the sub NFTs go with it.

To compose two NFTs, they must have the same owner. Prior to composing them, the owner must approve a transfer of the sub NFT's token id to the Asset Contract.

await seller.invoke(
    txAssetContract, 
    'approve', 
    { to: txAssetContract.address, tokenId: toUint256WithFelts("1") }, 
    { maxFee: FEE}
)

As previously stated, composing the assets means assigning ownership of the sub NFT to the main NFT. This happens by calling a custom function as per the code below:

const txHash = await seller.invoke(
      txAssetContract, 
      "composeSubTokens", 
      { 
        tokenId: toUint256WithFelts("0"),
        subTypes: [starknet.shortStringToBigInt('type 1')],
        subTokenIds: [ toUint256WithFelts("1") ]
      },
      { maxFee: FEE}
    )

The result is that if the owner of the main NFT transfers it to another wallet, then both NFTs are transfered to the new owner.

PreviousAgreeingNextPayment Streams

Last updated 2 years ago