Integrating or building solely on the blockchain doesn't require permission from Public Mint or anybody else. You can connect to the Public Mint blockchain by remotely connecting to it and only takes a few steps.
Developing blockchain-based applications usually requires work on two domains:
Smart contract development: code which gets deployed to the blockchain, written in Solidity in the case of Public Mint (and Ethereum);
Web or app development: code deployed on the web as an interface to read and write data from the blockchain/smart contracts.
Even though you can connect your web app directly to a client using JSON-RPC calls, you can use a wrapper to make your life easier when trying to connect the two domains and create a full-fledged interface.
Connecting to the blockchain takes just a few steps:
The Public Mint client is based on Hyperledger Besu, and likewise it includes a command line interface and JSON-RPC API for running and monitoring nodes.
Our client also supports smart contract deployment and operational tools (such as Remix, web3.js, or MyCrypto). Apart from a few key differences, the interface should be quite familiar to Ethereum developers.
Start by installing publicmint-web3.js. From the terminal, type:
$ mkdir myDappProject && cd $_$ npm init .$ npm install @publicmint/publicmint-web3$ touch index.js
index.js start by requiring web3:
import PublicMint from 'publicmint-web3';// For JS es5 use:const PublicMint = require('publicmint-web3').default;
This variable will now allow you to create a connection to a Public Mint node.
Next, it's time to connect. Depending on whether your are connecting to our TestNet (blockchain used by Public Mint Sandbox environment) or to our MainNet (Public Mint production environment), you should enter the following:
const web3 = new PublicMint('testNet'); // or chainId 2019
const web3 = new PublicMint(); // default 'mainNet' or chainId 2020
See more about providers here.
This step will create a normal web3 instance excluding modules not working for now (excluded modules), and create a new namespace
web3.pm that contains all contracts and basic features for interface with PublicMint client.
Learn more about
You're almost done. Now it's time to test it.
To make sure everything went smoothly, let's query the blockchain for the latest block:
> web3.eth.getBlockNumber().then(console.log);> 3141 // Most recent block number
Congratulations! You are connected to the Public Mint blockchain. Read on to go through examples of some of the operations you can perform.