Skip to main content
.NETStandard2.0

Solana.Metaplex is the .NET integration library for the Metaplex protocol on Solana

Published
Mar 2, 2023
3y ago
Total Downloads
85.6K
85,576

Install

dotnet add package Solana.Metaplex --version 4.8.0
ProductVersions
.NET Standard
netstandard2.0

README

What is Solnet.Metaplex?

Solnet is Solana's .NET integration library, a number of packages that implement features to interact with Solana from .Net applications.

Solnet.Metaplex is a package within the same Solnet. namespace that implements a Client for Metaplex, this project is in a separate repository so it is contained, as the goal for Solnet was to be a core SDK.

Features

Requirements

  • net 6.0

Backport to .NET standard 2.0 is available on Nuget under version 4.0.0

Dependencies

  • Solnet

Examples

Create & Mint a Fungible, Semi-Fungible, Non-Fungible, or Programmable metadata token

        var client = ClientFactory.GetClient( Cluster.DevNet);
        var exampleWallet = new Wallet.Wallet(pk);

        //Get your account either by the wallet or directly from the private key
        Account ownerAccount = exampleWallet.Account;
        Account mintAccount = exampleWallet.GetAccount(75);

        Console.WriteLine("Using account public key : {0}", ownerAccount.PublicKey );

        //Create the creator list
        List creatorList = new List
        {
            new Creator(ownerAccount.PublicKey, 100, true)
        };

        //If there is more than one then you can add more

        //creatorList.Add(new Creator(new PublicKey("")))

        Metadata tokenMetadata = new Metadata
        {
            name = "SolNET NFT",
            symbol = "SOLNET",
            sellerFeeBasisPoints = 500,
            uri = "arweave link",
            creators = creatorList,

            //If your NFT has a parent collection NFT. You can specify it here
            //collection = new Collection(collectionAddress),

            uses = new Uses(UseMethod.Single, 5, 5),

            //If your NFT is programmable and has a ruleset then specify it here
            //programmableConfig = new ProgrammableConfig(rulesetAddress)
        }; 

        //Easily create any type of metadata token. Any nullable parameters can be overrided to provide the data needed to create complex metadata tokens or use legacy instructions
        MetaplexClient metaplexClient = new MetaplexClient(client);
       
        await metaplexClient.CreateNFT(ownerAccount, mintAccount, TokenStandard.NonFungible, tokenMetadata, false, true);

Get the metadata of a token

    string pk = "token address here"
    Console.WriteLine("### Get Metadata example ###");
    Console.WriteLine("Getting account {0}", pk );

    var client = ClientFactory.GetClient( Cluster.MainNet);
    var account = await MetadataAccount.GetAccount( client, new PublicKey(pk ));

    Console.WriteLine( $"Owner: {account.owner}");
    Console.WriteLine( $"Authority key: {account.updateAuthority}");
    Console.WriteLine( $"Mint key: {account.mint}");
    Console.WriteLine( $"Name: {account.metadata.name}");
    Console.WriteLine( $"Symbol: {account.metadata.symbol}");
    Console.WriteLine( $"Uri: {account.metadata.uri}");
    Console.WriteLine( $"SellerFeeBasisPoints: {account.metadata.sellerFeeBasisPoints}");

    Console.WriteLine( $"---Creators---");
    foreach( Creator c in account.metadata.creators)
    {
        Console.WriteLine( $"Creator Key: {c.key}");
        Console.WriteLine( $"Creator Share: {c.share}");
        Console.WriteLine( $"Creator is verified: {c.verified}");
    }

    Console.WriteLine(  "-------Metadata-------");
    Console.WriteLine($"Name: {account.offchainData.name}");
    Console.WriteLine($"Description: {account.offchainData.description}");
    Console.WriteLine($"Symbol: {account.offchainData.symbol}");
    Console.WriteLine($"Collection: {account.offchainData.collection}");
    Console.WriteLine($"Default Image: { account.offchainData.default_image }" );
    Console.WriteLine($"Animation url: {account.offchainData.animation_url}");

    foreach (var attribute in account.offchainData.attributes)
    {
        if(attribute != null)
           Console.WriteLine($"Attribute: { attribute.trait_type } | { attribute.value }");
    }
        
    Console.WriteLine ( "------------------");

Contribution

Open in Gitpod

We encourage everyone to contribute, submit issues, PRs, discuss. Every kind of help is welcome.

Contributors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Changes from Previous Version

v3.0.0v4.8.0
Added Frameworks
.NETStandard2.0
Removed Frameworks
net6.0
Added Dependencies
Newtonsoft.Json(.NETStandard2.0)
System.Memory(.NETStandard2.0)

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.