What is Metaplex's Fusion tool?
Written by Aguchukwu Emmanuel Ebube
Reviewed by Brady Werkheiser
As a Solana launchpad, Metaplex helps creators launch and scale their NFTs and their Fusion program builds and expands on this vision. Fusion is one of Metaplex's endeavors to bring more functionality around NFTs for creators on the Solana blockchain. This article will give a detailed overview of how the Fusion program works and how to set it up.
What is Fusion?
Fusion is an NFT composability feature, that builds on the Trifle program, that allows NFTs to be reassembled or rearranged based on individual components. The Trifle program is an extension of one of Metaplex's most used programs called Token metadata. With Token metadata, the Trifle adds flexibility, the ability to create complex models NFT ownership, and adding features like on-chain tracking to NFT projects.
What are Composable NFTs?
Composable NFTs are flexible NFTs that allow individual NFT components to be rearranged to build complex models.
A prominent example of composability would be a brick Lego — it has a structure that permits connection with other lego bricks and this, in turn, permits the formation of complex models. Thus, composability is the components' ability to support or permit inter-relationships with one another to be re-assembled or rearranged to form a more complex structure. Composable NFTs build on the Trifle Program.
What are the use cases of Fusion by Metaplex?
Fusion by Metaplex has use cases in multiple crypto ecosystems such as gaming, NFTs and decentralized finance.
1. Gaming
Fusion's flexibility and composability features are perfect for asset gamification in modern web3 games. In-game assets can be combined to form other Tokens in real-time. For example, if you have two stars in a game and the value of these two stars equals 1 diamond, you can combine both tokens and track them on-chain.
2. NFTs
Using Fusion, compatible NFT images can become composable to form new images. For instance, individual NFTs can be puzzle pieces, or parts of a car that can be combined together to create an entirely new NFT.
3. DeFi
NFTs can now be bundled or composed together and sold on decentralized exchange platforms.
How does Fusion by Metaplex work?
Fusion uses Trifle which is an NFT composability program built as an extension to the Token Metadata program. The Fusion program is made up of different Metaplex programs, which are made to bring more functionality to NFTs built on Solana. Fusion can be used to enhance dapps and NFT marketplaces, and it also empowers creators to specify rules around NFT trading and ownership.
What is the Trifle Program?
The Trifle program, which is an extension of the Token Metadata program by Metaplex, powers NFT composability by using Creator-Owned Accounts, which is a type of NFT Escrow account that extends the Token metadata program.
There are two types of Escrow accounts, TOE (Token owned escrow) and COE (Creator owned escrow). The Trifle program uses COEs and designates a Program Derived Address (PDA) as the creator of the NFT, giving a PDA the benefits and features ascribed to creators to and other functionalities like on-chain tracking.
What are token ownership rules?
These are three types of rules and constraints associated with the ownership of a token that a creator can set — none, Metaplex certified collections, and Token set. Every other constraint comes under these three main types.
1. None
This is set when no requirements or rules are necessary, and it permits the transfer of any token. See these as allowing guests to an event without a gate pass.
2. Metaplex Certified Collections
This is set when tokens are required to belong to a specific collection.
3. Token Set
This is set when a minted token is required to match one token in the set.
What are Solana accounts used with Fusion?
Metaplex Fusion uses two accounts — the escrow constraint model account which is an extension of the Token metadata program/Contract, and a Trifle account.
What is the escrow constraint model account?
An escrow constraint model account outlines requirements that must be met before an instruction can be used to access a Trifle account. The Escrow account uses a hashmap to implement its data structure, where it maps keys to values by passing them through a hash function.
With the escrow model account, the key is the Constraint/slot name while the value is the constraint type, which can only be (None/ Collection or TokenSet) and the Token limit (the maximum amount of tokens in the escrow account).
A unique feature of the constraint model account is NFTs for similar use cases can be connected to the same escrow constraint model. Additionally, the constraint model can be used as a bank to store the fees paid by Trifle users for each instruction.
What is a Trifle account?
The Trifle account manages and tracks tokens stored in the COE accounts on-chain, and is linked to the Escrow constraint account during execution. The Trifle account uses a hashmap to manage these tokens.
Instructions associated with the escrow constraint and Trifle account:
Create Escrow Constraint Model Account - this creates an escrow model account
Create Trifle Account - this is used to create a Trifle account
Transfer In - this is used to transfer a token to the COE managed by the Trifle account
Transfer Out - this is used to transfer a token out of the COE that is managed by the Trifle account
The transfer in instruction checks the constraint model to verify that the token about to be transferred in meets the specified requirements, and the transfer out instruction checks the constraint model to verify that the token about to be transferred out meets the specified requirements.
How to Use Metaplex Fusion
At the program level, using Fusion involves three steps: creating a parent NFT, defining the schema of your NFT, and setting up the Trifle account.
Step 1: Create a Parent NFT
Here’s a typical code example that creates a parent NFT.
const findTriflePda = async (
mint: PublicKey,
authority: PublicKey,
) => {
return await PublicKey.findProgramAddress(
[
Buffer.from("Trifle"),
mint.toBuffer(),
authority.toBuffer(),
],
new PublicKey(PROGRAM_ADDRESS),
);
};
const METAPLEX_BUCKET = "Jf27xwhv6bH1aaPYtvJxvHvKRHoDe3DyQVqe4CJyxsP";
let nftMint = Keypair.generate();
let TrifleAddress = await findTriflePda(nftMint.publicKey, updateAuthority);
let result;
result = await metaplex!.nfts().create({
uri: "https://shdw-drive.genesysgo.net/" + METAPLEX_BUCKET + "/" + TrifleAddress[0].toString() + ".json",
name: "Fusion NFT",
sellerFeeBasisPoints: 0,
useNewMint: nftMint
});
Here’s what the code does:
a. Generate a new KeyPair object
The KeyPair object consists of a public key and a private key, and assign it to the nftMint variable. This will be used as the mint (issuer) of the NFT.
b. Call the findTriflePda function
Next, call the with the findTriflePda function public key of the nftMint object and the updateAuthority object as arguments. The findTriflePda function returns a program address that will be used as the Trifle account for the NFT.
c. Call the create method of the NFT
Call the create method of the NFTs property of the Metaplex object, passing an object with the following properties as an argument:
URI - a string that will be used as the static URI for the NFT
name - a string that represents the name of the NFT
sellerFeeBasisPoints - a number that represents the seller fee for the NFT in basis points
useNewMint - the nftMint object, which will be used as the mint (issuer) of the NFT
Note: the URI string is constructed by concatenating the following items separated by slashes:
METAPLEX_BUCKET constant
the first element of the TrifleAddress array
the string ".json"
After the create method is called, it returns a value that represents the parent NFT.
Step 2: Define Schema
A schema is a blueprint of how data is organized in a database. With Fusion, the constraint model has a field/slot called the schema field, which determines how some attributes of the NFT are organized.
{
"type": "layering",
"layers": ["base", "neck", "mouth", "nose"],
"defaults": {
"metadata": "https://shdw-drive.genesysgo.net/G6yhKwkApJr1YCCmrusFibbsvrXZa4Q3GRThSHFiRJQW/default.json"
}
}
Here is what each schema attribute represents:
type - represents what type of schema it is
layers - represents the different slots in the Trifle account
defaults - this shows the default metadata to use when comparing and combining Fusion’s metadata
Step 3: Set up a Trifle Account
The final step is to set up a Trifle account, but according to the Metaplex documentation, the instructions for setting up a Trifle account are not yet available.
Start Developing on Solana Today
Fusion by Metaplex is used to create composable NFTs on Solana. To start developing on Solana, sign up for a free Solana RPC node account with Alchemy today!
Related overviews
Learn About Compressed NFTs and How They Work
Learn What an Associated Token Account Is, How it Works, and How to Create One
Learn What SFTs Are, How They Work, and What Makes Them Different from NFTs and SPL Tokens