Skip to content

bchavez/Pinata.Client

Repository files navigation

Build status Nuget Users

Pinata.Client for .NET/C# Library

Project Description

A .NET implementation for Pinata Cloud.

Minimum Requirements

  • .NET Standard 2.0 or later
  • .NET Framework 4.5 or later
  • TLS 1.2 or later

Crypto Tip Jar

Download & Install

Nuget Package Pinata.Client

Install-Package Pinata.Client

Getting Started

var config = new Config
   {
      ApiKey = "2981f1eb1813daf...",
      ApiSecret = "42281fa28de32fe3c..."
   };

var client = new PinataClient(config);

var html = @"
<html>
   <head>
      <title>Hello IPFS!</title>
   </head>
   <body>
      <h1>Hello World</h1>
   </body>
</html>
";

var metadata = new PinataMetadata // optional
   {
      KeyValues =
         {
            {"Author", "Brian Chavez"}
         }
   };

var options = new PinataOptions(); // optional

options.CustomPinPolicy.AddOrUpdateRegion("NYC1", desiredReplicationCount: 1);

var response = await this.client.Pinning.PinFileToIpfsAsync(content =>
      {
         var file = new StringContent(html, Encoding.UTF8, MediaTypeNames.Text.Html);

         content.AddPinataFile(file, "index.html");
      },
   metadata,
   options);

if( response.IsSuccess )
{
   //File uploaded to Pinata Cloud and can be accessed on IPFS!
   var hash = response.IpfsHash; // QmR9HwzakHVr67HFzzgJHoRjwzTTt4wtD6KU4NFe2ArYuj
}

Now your file can be accessed over IPFS and accessed via Cloudflare's IPFS gateway!

https://cloudflare-ipfs.com/ipfs/QmR9HwzakHVr67HFzzgJHoRjwzTTt4wtD6KU4NFe2ArYuj

Find more examples here.


Magic! Easy peasy! Happy file sharing! 🎉

Reference

Building

  • Download the source code.
  • Run build.cmd.

Upon successful build, the results will be in the \__compile directory. If you want to build NuGet packages, run build.cmd pack and the NuGet packages will be in __package.

Contributors

Created by Brian Chavez.

A big thanks to GitHub and all contributors!


Note: This application/third-party library is not directly supported by Pinata Technologies, Inc. Pinata Technologies, Inc. makes no claims about this application/third-party library. This application/third-party library is not endorsed or certified by Pinata Technologies, Inc.