Getting Started
Note: this guide assumes publishing on verifyTestnet (opens in a new tab) using a sandbox (opens in a new tab) env . Using testnet or mainnet requires a whitelist from the VERIFY team. Please reach out to VERIFY (opens in a new tab) for more information.
Configure
To start publishing the sdk needs to be configured with some settings. It can be done either by setting environment variables in the execution context or by passing it as parameters to init config function.
- Create a .env file at the root of
test-verifymedia-client
(created during quick start (opens in a new tab)) project and add the following env variables.
DEBUG=0 # 0 if false and 1 is true with default false. When true print debug logs
RPC_URL=https://rpc.verify-testnet.gelato.digital # allows for a developer to interact with an Ethereum node via HTTP(S)
STAGE=sandbox # stage of the VERIFY Protocol
CHAIN_ID=1833 # chain id for the network
CHAIN=verifyTestnet # network name
MAX_GAS_PRICE=0 #if set a transaction will not be performed if network gas is above this limit
ROOT_PVT_KEY=<root_pvt_key> # private key for the root wallet which acts as the publishers identity
PVT_KEY=<intermediate_pvt_key> # private key for the intermediate wallet which acts as the signer, there could be more than one signer wallets hence its preferred to pass this value as a parameter instead
WALLET_EXPIRY_DAYS=3 # number for days for which the intermediate wallet is active and authorized
ORG_NAME=<org_name> # name of the publisher
- We recommend installing dotenv (opens in a new tab) npm module so that the env vars can be made available in the execution context. Modify index.mjs to add the following.
import dotenv from 'dotenv'
dotenv.config()
- The VERIFY client sdk now can start using these settings.
import {init, getConfig} from '@verify-media/verify-client'
init()
const config = getConfig()
console.log(config.stage)
-
Since content gets uploaded to ipfs and then published to blockchain you would need the following:
- A wallet funded with at least 0.1 matic. (a private / public key pair required to sign transactions on the blockchain).
- Pinata (opens in a new tab) (an IPSF service) credentials. (storage for the content).
Setup
-
Wallets
- VERIFY Protocol expects a publisher to have a root identity (opens in a new tab) and an intermediate identity (opens in a new tab) which are represented by wallets (opens in a new tab).
- If you don't have a wallet already, you could set one up using
- MetaMask (opens in a new tab) (Note: this is NOT recommended in production / mainnet environments).
- OR gen-wallet script from the examples folder (opens in a new tab)
You should now have a public / private key pair generated. Do keep the public key handy because that is the wallet address.
npm run gen-wallet
-
Copy private key and add it to
.env
againstROOT_PVT_KEY
. -
Repeat the same steps to add an intermediate wallet and configure the private key in
.env
againstPVT_KEY
. -
Now that the wallet is created, add funds to it. Note: funds always need to be added to the intermediate wallet (public key) only, since this is all on testnet (not real money). The intermediate wallet (public key) can be funded using a bridge to transfer MATIC from AMOY to verifyTestnet. Please refer to the bridge (opens in a new tab) documentation for more details.
-
All content published on VERIFY Protocol is stored on IPFS. VERIFY client sdk supports this via Pinata (opens in a new tab) or your own IPFS cluster setup using Kubo (opens in a new tab). For the purpose of this example please set up a free (opens in a new tab) Pinata account. Configure the Pinata API key and Pinata secret, and then add that to
.env
asPINATA_KEY=<PINATA_KEY> PINATA_SECRET=<PINATA_SECRET>
-
Finally please set the ORG_NAME in the
.env
file to the name of the publisher.
Publishing
To run these examples please follow the env setup (opens in a new tab) for examples folder.
Note: The examples provided below illustrate a specific workflow for publishing content. The Verify protocol does not endorse any particular workflow; publishers are free to implement processes based on their individual requirements. The following example is intended to showcase one possible workflow.-
Setting up the publisher identities and org structure
Prerequisite:
- Root wallet exists and is configured with the VERIFY client sdk.
- Intermediate wallet exists and is configured with VERIFY client sdk.
- Intermediate wallet is funded.
Steps Performed:
- Register root wallet on VERIFY Protocol.
- Link intermediate wallet with root wallet on VERIFY Protocol.
- Create
orgNode
andOriginalMaterialNode
on VERIFY Protocol for the intended publisher. This is a one time configuration for a publisher on the protocol, please update theorgNodeId
andoriginalMaterialNodeId
in the.env
file for future use as follows.
ORG_NODE=<orgNodeId> OG_NODE=<ogNodeId>
Execute:
-
env setup (opens in a new tab) for examples folder
npm run init-publisher
./examples/src/sdk/init.ts
for each individual step -
Publishing an Article
Prerequisite:
orgNode
exists and is passed as input.OriginalMaterialNode
exists and is passed as input.- Intermediate wallet is funded.
Steps Performed:
- Encrypt content.
- Upload content to IPFS if it does not exist on VERIFY Protocol.
- Upload content meta to IPFS if it is new content, or if metadata has changed for an existing content. (Note: content metadata holds the location to actual content on IPFS).
- Sign content metadata.
- Publish on VERIFY Protocol with the correct hierarchy.
Execute:
env setup (opens in a new tab) for examples folder
Checkout the script in ./examples/src/sdk/publish-article.ts for each individual steps.npm run publish-article <orgNodeId> <ogNodeId> # npm run publish-article 0x20601de6e456a9819d83f58573beaa49315dfd3af31bb030e4d85e19c3beb07f 0xeb6a6499ad57495ca0687e648821fe3b64df8a3c661eea30c2aed2f00eb1fdd8
Examples
- Refer to the examples (opens in a new tab) folder to see how operations are performed by the VERIFY client sdk.