Confidential Document Sharing
Learn how to store and share confidential documents on the EVM using Secret Network.
Introduction
In this tutorial you will learn how to implement the @secret-network/share-document SDK to store, view, and share confidential documents on the EVM using Secret Network as a confidential storage layer.
By using our SDK, you will have the possibility to:
Store a new document
See the contents of this document
Grant/Revoke access to the document to another wallet address
Note that when you want to share a document with another wallet address, you need to provide the Secret Network address of the person you want to share it with.
Getting Started
Create an empty wagmi project:
npm create wagmiDuring the install process, wagmi will ask you to select a framework and a variant. To follow along with this tutorial, select React for framework, and Next for variant. Once you have installed your wagmi project, cd into your project:
cd <your project name>Install the dependencies & the sdk:
npm i @secret-network/share-documentThis tutorial will teach you how to use the SDK on Polygon Mainnet. Update your wagmi.ts file for Polygon Mainnet configuration like so:
Create a .env file with the following content since we are interacting with the Polygon Mainnet contract:
Custom chain
Storage API Keys
Next, navigate to Pinata and generate a new API key + JWT token to use for storing documents. Make sure you save the credentials in a safe place because we will use them shortly :D
React Imports & State Variables
Navigate to /src/page.tsx.
Configure your React imports + state viarables like so:
Your environment is now configured to store confidential documents on Polygon Mainnet using Secret Network!
Initialize the Client
Configure the SDK client like so:
Store a File
View a File
Download a File
Share a File
Summary
This documentation provides a step-by-step guide on how to implement the @secret-network/share-document SDK to securely store, view, and share confidential documents on the EVM using Secret Network as a confidential storage layer. You learned how to create a new wagmi project, configure it for Polygon Mainnet, and integrate the Secret Network SDK. By following this guide, you can now store documents, view their content, and manage access permissions all on the EVM chain of your choosing.
Special Thanks
Special thanks to the FiftyWei team for building out this SDK as part of the Secret Network Q1 2024 grants cohort :D
Last updated
Was this helpful?