Coder Social home page Coder Social logo

solnet.metaplex's People

Contributors

barelooksrare avatar bifrosttitan avatar hoakbuilds avatar mariomatic avatar pcarvalho75 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

solnet.metaplex's Issues

UpdateMetadataAccount not working

I did not find an example of how exactly to use UpdateMetadataAccount correctly and tried it out.

In MetadataProgramData.cs Line 171

writer.Write( (byte) MetadataProgramInstructions.Values.CreateMetadataAccount );

should maybe be

writer.Write( (byte) MetadataProgramInstructions.Values.UpdateMetadataAccount );

instead of

writer.Write( (byte) MetadataProgramInstructions.Values.CreateMetadataAccount );

?
I tried it out using

var tx = MetadataProgram.UpdateMetadataAccount(mintMetadataPublicKey, updateAuthority, updateAuthority, new MetadataParameters()
            {
                creators = new List<Solnet.Metaplex.Creator>()
                  {
                       new Solnet.Metaplex.Creator(updateAuthority, 100)
                  },
                name = "customname",
                sellerFeeBasisPoints = 200,
                symbol = "",
                uri = "customurl"
               
            }, false);
            
            
var blockHash = _client.GetRecentBlockHash();
byte[] TX1 = new TransactionBuilder()
                .SetRecentBlockHash(blockHash.Result.Value.Blockhash)
                .SetFeePayer(wallet.Account)
                .AddInstruction(tx)
                .Build(new List<Account> { wallet.Account });
                
                var txSim = _client.SimulateTransaction(TX1);

and I get following error:

{"jsonrpc":"2.0","result":{"context":{"slot":99070261},"value":{"accounts":null,"err":{"InstructionError":[0,"InvalidError"]},"logs":["Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]","Program log: Error: BorshIoError","Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 3732 of 200000 compute units","Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: program returned invalid error code"]}},"id":3}

What I'm doint wrong and could you please share an working example?

Add new Metadata contract instructions ( v 1.1)

Add new instructions ( v1.1.0 of Metadata program )

  • UpdateMetadataAccountV2
  • CreateMetadataAccountV2
  • CreateMasterEditionV3
  • VerifyCollection
  • Utilize
  • ApproveUseAuthority
  • RevokeUseAuthority
  • UnverifyCollection
  • ApproveCollectionAuthority
  • RevokeCollectionAuthority
  • SetAndVerifyCollection

Encode payload data for CreateMetadataAccountV3 (with Collections Details)

I am aware that there has not yet been released a version which takes into account certified collections. Anyway, I do plan to make the necessary adjustments to the existing code so as to allow creating a collection.

From my understanding, for creating a certified collection, the following are needed:

private static byte[] EncodeCreateMetadataAccountData(MetadataParameters parameters, int? collectionDetailsSize = null, bool isMutable = true)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(parameters.name);
            byte[] bytes2 = Encoding.UTF8.GetBytes(parameters.symbol);
            byte[] bytes3 = Encoding.UTF8.GetBytes(parameters.uri);
            MemoryStream memoryStream = new MemoryStream();
            BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
            binaryWriter.Write((byte)0);
            binaryWriter.Write(bytes.Length);
            binaryWriter.Write(bytes);
            binaryWriter.Write(bytes2.Length);
            binaryWriter.Write(bytes2);
            binaryWriter.Write(bytes3.Length);
            binaryWriter.Write(bytes3);
            binaryWriter.Write((ushort)parameters.sellerFeeBasisPoints);
            int num;
            if (parameters.creators != null)
            {
                List<Creator> creators = parameters.creators;
                num = ((creators != null && creators.Count < 1) ? 1 : 0);
            }
            else
            {
                num = 1;
            }

            if (num != 0)
            {
                binaryWriter.Write((byte)0);
            }
            else
            {
                binaryWriter.Write((byte)1);
                binaryWriter.Write(parameters.creators.Count);
                foreach (Creator creator in parameters.creators)
                {
                    byte[] buffer = creator.Encode();
                    binaryWriter.Write(buffer);
                }
            }

            // collection - ADDED BY ME
            binaryWriter.Write((byte)0);

            // uses  - ADDED BY ME
            binaryWriter.Write((byte)0);

            binaryWriter.Write(isMutable);

            // - whole below if-else block ADDED BY ME
            if (collectionDetailsSize != null)
            {
                binaryWriter.Write((byte)1);

                byte[] collectionDetailsByteArray = new byte[8];
                var collectionDetailsSizeBytes = BitConverter.GetBytes(collectionDetailsSize.Value);

                collectionDetailsSizeBytes.CopyTo(collectionDetailsByteArray, 0);

                binaryWriter.Write(collectionDetailsByteArray);
            }
            else
            {
                binaryWriter.Write((byte)0);
            }

            return memoryStream.ToArray();
        }

I always get a deserialization exception from the on-chain program. I am using testnet at the moment. Can you help me get the encoding of the collectionDetails right until the feature will be implemented in this repo? Also, as I am in the need of using this quite often, I will be delighted to also contribute to the project.

Thank you very much!

implement Vault contract

  • InitVault
  • AddTokenToInactiveVault
  • ActivateVault
  • CombineVault
  • RedeemShares
  • WithdrawTokenFromSafetyDepositBox
  • MintFractionalShares
  • WithdrawSharesFromTreasury
  • AddSharesToTreasury
  • UpdateExternalPriceAccount
  • SetAuthority

Metaplex v2 Minting

I'm trying to replicate a metaplex v2 minting made with the metaplex js cli, here is a sample transaction: https://solscan.io/tx/2qgQRycQLf3mQi9QP1vMidod9XK1rWfhp9eDQss4ME1gFEuHVfWfDxuspsxdFBwf8no5xYj8Ly5H1MqZGntTbE8F?cluster=devnet

With the following solnet code I'm able to recreate it until the MintTo step:

var tokenAMint = new Account();
var fromAccount = new Account();
PublicKey associatedTokenAccount = AssociatedTokenAccountProgram.DeriveAssociatedTokenAccount(fromAccount.PublicKey, tokenAMint.PublicKey);
            
var transaction = new TransactionBuilder()
                .SetRecentBlockHash(blockHash.Result.Value.Blockhash)
                .SetFeePayer(fromAccount)
                .AddInstruction(
                    SystemProgram.CreateAccount(
                        fromAccount,
                        tokenAMint,
                        devnetRpc.GetMinimumBalanceForRentExemption(TokenProgram.MintAccountDataSize).Result,
                        TokenProgram.MintAccountDataSize,
                        TokenProgram.ProgramIdKey))
                .AddInstruction(
                    TokenProgram.InitializeMint(
                        tokenAMint,
                        0,
                        fromAccount,
                        fromAccount))
                .AddInstruction(
                    AssociatedTokenAccountProgram.CreateAssociatedTokenAccount(
                        fromAccount,
                        fromAccount.PublicKey,
                        tokenAMint.PublicKey))
                .AddInstruction(
                    TokenProgram.MintTo(
                        tokenAMint.PublicKey,
                        associatedTokenAccount,
                        1,
                        fromAccount.PublicKey))
                .Build(new List<Account>()
                {
                    fromAccount,
                    tokenAMint
                });

Here is the partial transaction: https://solscan.io/tx/3KCg8GmNMXRh1GaHUUnGs5GjeDFfNdEiF5DthdW313TJC4RGw5eXVsQ9mTyJvLkg1PC8SRGSBDfLyfzgMos1sH26?cluster=devnet

I am now stuck on calling the Metaplex NFT Candy Machine V2, I have not found the functionality to do this. Is it possible to do this with the current version of solnet.metaplex? Otherwise anyone has any suggestions, tips to implement it?

[Bug] Could not load type 'Solnet.Rpc.Utilities.AddressExtensions' from assembly 'Solnet.Rpc

Describe the bug
Getting the following excepton:

Unhandled exception. System.TypeLoadException: Could not load type 'Solnet.Rpc.Utilities.AddressExtensions' from assembly 'Solnet.Rpc, Version=6.0.6.0, Culture=neutral, PublicKeyToken=null'.
   at Solana.Metaplex.MetadataAccount.GetAccount(IRpcClient client, PublicKey pk)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Solana.Metaplex.MetadataAccount.GetAccount(IRpcClient client, PublicKey pk)

To Reproduce

    var rpcClient = ClientFactory.GetClient(Cluster.DevNet, null);
    var tokenAccounts = rpcClient.GetTokenAccountsByOwner("A4dqTiSyoQPYaYKgz7KMC4KbsA7Hw4o1W9edXa949zzT", null,
        "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");

    Task.Run(async () =>
    {
        foreach (TokenAccount accountPk in tokenAccounts.Result.Value)
        {
            var mint = accountPk.Account.Data.Parsed.Info.Mint;
            var account = await MetadataAccount.GetAccount(rpcClient, new PublicKey(mint));
        }
    }).GetAwaiter().GetResult();

Installed versions:

image

Expected behavior
Not to crash.

Desktop (please complete the following information):
Macbook Pro latest OS.

implement Metaplex contract

  • RedeemBid
  • RedeemFullRightsTransferBid
  • StartAuction
  • ClaimBid
  • EmptyPaymentAccount
  • SetStore
  • SetWhitelistedCreator
  • RedeemUnusedWinningConfigItemsAsAuctioneer
  • DecommissionAuctionManager
  • RedeemPrintingV2Bid
  • WithdrawMasterEdition
  • InitAuctionManagerV2
  • ValidateSafetyDepositBoxV2
  • RedeemParticipationBidV3

Update Metadata Account Fields

Hi. I was trying to update Metadata Account fields' value, but the following error shows up!
{"jsonrpc":"2.0","error":{"code":-32602,"message":"invalid transaction: Transaction failed to sanitize accounts offsets correctly"},"id":2}

Could you provide me a sample?

[Bug] MetadataAccount invalid parsing

Describe the bug
{"Specified argument was out of the range of valid values. (Parameter 'offset')"} exception in ParseData.

Reproduce
Create nft without creators but with primarySaleHappened.

Why
(binData.GetU16(MetadataAccountLayout.creatorsOffset) gives 256

  1. MetadataAccountLayout creatorsOffset must be 321, not 322
  2. creators is optional field.

Also, next fields missing

  • primarySaleHappened (not set)
  • isMutable (not set)
  • editionNonce (not set)
  • tokenStandard
  • collection
  • uses

P.S.
Current used manual deserializing is so bad, better use schema (like here), possible also code generator.

NuGet version bump

Hello,

Is there going to be a NuGet version bump after @BifrostTitan' latest merges? Last one was #47, but the NuGet package was lastly updated 4 months ago.

He did way too many amazing things to not get that in the NuGet package manager.

Thanks a lot @BifrostTitan!

error":{"code":-32003

Transaction sim:
{"jsonrpc":"2.0","error":{"code":-32003,"message":"Transaction signature verification failure"},"id":1}

I cant mint nft.

This is my code:

`

       var rpcClient = ClientFactory.GetClient(Cluster.MainNet); 
        var blockHash = rpcClient.GetRecentBlockHash();
        var wallet = new Wallet(MnemonicWords);

        var fromAccount = wallet.Account;
        var mintAccount = wallet.GetAccount(0);
        var tokenAccount = wallet.GetAccount(0);

        byte[] metadataAddress = new byte[32];
        int nonce;
        AddressExtensions.TryFindProgramAddress(
            new List<byte[]>() {
                Encoding.UTF8.GetBytes("metadata"),
                MetadataProgram.ProgramIdKey,
                mintAccount.PublicKey
            },
            MetadataProgram.ProgramIdKey,
            out metadataAddress,
            out nonce
        );

        Console.WriteLine($"PDA METADATA: {new PublicKey(metadataAddress)}");
        byte[] masterEditionAddress = new byte[32];
        //int nonce;
        AddressExtensions.TryFindProgramAddress(
            new List<byte[]>() {
                Encoding.UTF8.GetBytes("metadata"),
                MetadataProgram.ProgramIdKey,
                mintAccount.PublicKey
            },
            MetadataProgram.ProgramIdKey,
            out masterEditionAddress,
            out nonce
        );
        Console.WriteLine($"PDA MASTER: {new PublicKey(masterEditionAddress)}");

      
        var c1 = new Creator(fromAccount.PublicKey, 100);
     
  
        var data = new MetadataParameters()
        {
            name = "Test 2",
            symbol = "",
            image = "https://i.resmim.net/hddxqQ.jpg",
            uri = "http://foodi.com",
            creators = new List<Creator>() { c1 },
            sellerFeeBasisPoints = 5
        };

        byte[] TX2 = new TransactionBuilder()
            .SetRecentBlockHash(blockHash.Result.Value.Blockhash)
            .SetFeePayer(fromAccount)
            .AddInstruction(
                MetadataProgram.CreateMetadataAccount(
                    new PublicKey(metadataAddress), //PDA
                    mintAccount.PublicKey,  //MINT
                    fromAccount.PublicKey,  //mint AUTHORITY
                    fromAccount.PublicKey,  //PAYER
                    fromAccount.PublicKey,
                    data,                   //DATA
                    true,
                    false                    //ISMUTABLE
                )
            )
            .AddInstruction(
                MetadataProgram.PuffMetada(
                    new PublicKey(metadataAddress)
                )
            )
            .AddInstruction(
                MetadataProgram.CreateMasterEdition(
                    1,
                    new PublicKey(masterEditionAddress),
                    mintAccount.PublicKey,
                    fromAccount.PublicKey,
                    fromAccount.PublicKey,
                    fromAccount.PublicKey,
                    new PublicKey(metadataAddress)
                )
            )
            .Build(new List<Account> { fromAccount, wallet.GetAccount(0) });
        var txSim2 = rpcClient.SendTransaction(TX2);
        Console.WriteLine($"Transaction sim: \n { txSim2.RawRpcResponse }");`

[Bug] SystemProgram.SysVarRentKey

if i update library i have this error:

AccountMeta.ReadOnly(SystemProgram.SysVarRentKey, false)

SystemProgram.SysVarRentKey not found

Metadata Account decoding

Is your feature request related to a problem? Please describe.

  • I want to decode a NFT account.

Describe the solution you'd like

  • I would like a method that takes a NFT address and returns a parsed account.

Describe alternatives you've considered

  • It would be nice to have a method that returns a NFT account by name, , or a list of accounts if the name is common.

implement Metadata contract

Implement the missing MetadataProgram instructions.

  • CreateMetadataAccount
  • UpdateMetadataAccount
  • UpdatePrimarySaleHappenedViaToken
  • SignMetadata
  • CreateMasterEdition
  • MintNewEditionFromMasterEditionViaToken
  • ConvertMasterEditionV1ToV2
  • MintNewEditionFromMasterEditionViaVaultProxy
  • PuffMetadata

Metadata (json) fetch

Given a token address , we would need to fetch the json metadata from the uri field of the metadata account data.

Maybe implement metadataJson as a class?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.