Page cover

III. For Developers: Building on Pruv Network

1. Why Build on Pruv Network?

Benefits of Developing on Pruv Network

Pruv Network is a robust blockchain platform designed to support the development of decentralized applications (dApps) and smart contracts, catering to a diverse range of industries and use cases. Developers choose Pruv Network for its high-performance, secure infrastructure, and unique developer-focused benefits.

  • High Scalability and Performance: Pruv Network's architecture is optimized for handling a large volume of transactions, making it ideal for dApps that require high throughput and low latency.

  • Interoperability: Pruv Network facilitates cross-chain compatibility, allowing developers to build applications that can interact with other blockchain networks, enhancing the versatility and user reach of their dApps.

  • Developer Tools and Documentation: Pruv Network provides an extensive suite of developer tools, SDKs, and thorough documentation, reducing the time needed to build, test, and deploy applications.

  • Lower Transaction Costs: Transactions on Pruv Network are cost-effective, making it an attractive option for developers who want to create applications with high user engagement and frequent transactions.

  • Strong Security Protocols: Pruv Network employs advanced security measures to protect applications and user data, giving developers peace of mind when building critical financial and data-sensitive applications.

  • Comprehensive Support for Compliance: With Pruv Network's compliance framework, developers can create applications that align with regulatory requirements, such as KYC/AML, helping them gain acceptance in regulated industries.

2. Developer Guide

Getting Started

Pruv Network provides a streamlined process for developers to start building quickly and efficiently. To begin, developers can follow these steps:

  • Set Up a Development Environment: Install Pruv Network's SDK and other tools required to begin coding and interacting with Pruv Network's network. The setup guide on Pruv Network's developer portal walks you through configuring your environment for maximum efficiency.

  • Access the Developer Portal: Pruv Network's developer portal offers comprehensive resources, including documentation, API references, smart contract templates, and sample code. This portal serves as a central hub for all the tools and resources needed to build on Pruv Network.

  • Smart Contract Development: Pruv Network supports Solidity and other widely used languages, allowing developers to leverage existing skills. Smart contracts on Pruv Network enable the automation of complex processes, making applications highly efficient and scalable.

  • Testing and Deployment: Utilize Pruv Network's testnet to develop and thoroughly test applications before mainnet deployment. This environment mimics the mainnet conditions, ensuring that applications perform as expected.

  • Access Developer Tools: Pruv Network provides various tools such as block explorers, gas fee estimators, and debugging utilities to support development, testing, and ongoing maintenance.

Developer Guide

ChainId

  • Testnet: 7336 (0x1ca8)

  • Mainnet: 7337 (0x1ca9)

RPC

Faucet

Explorer

Deploying Smart Contract

This quickstart guide is designed for web developers interested in building decentralized applications (dApps) on the Pruv Network network. No prior experience with Ethereum, Arbitrum, or Solidity is required, though familiarity with JavaScript and Yarn is recommended. If you are new to Ethereum, reviewing the Ethereum documentation may be helpful before you begin.

Prerequisites

  • VS Code: The integrated development environment (IDE) we’ll use to build the vending machine dApp. Install it from code.visualstudio.com.

  • Metamask: A crypto wallet for interacting with the vending machine dApp. Download it at metamask.io.

  • Yarn: The package manager for managing project dependencies. Install it from yarnpkg.com.

Create and Deploy your Smart Contract

1

Connect with Pruv Network by RPC url

To interact with the Pruv Network network, you’ll need to connect your application or wallet using the Pruv Network’s RPC URL. The RPC (Remote Procedure Call) URL allows your application to send transactions, read data, and interact with the blockchain. The RPC URLs for the testnet and mainnet are provided above <provide link to section>.

For development purposes:

  • Add the RPC URL in your configuration file (such as hardhat.config.js in Hardhat or directly in your code if using web3 or ethers.js).

For wallet applications like MetaMask:

  • Open MetaMask and go to Settings > Networks.

  • Click Add Network and enter the Pruv Network RPC URL, Chain ID, and currency symbol as provided by the Pruv Network.

For more detailed steps on adding a custom network in MetaMask, refer to the MetaMask Support Guide.

This step is essential for establishing a connection to the Pruv Network blockchain, enabling your application to interact with the network.

2

Request Pruv Network from faucet

You’ll need Pruv Network tokens to pay for transaction fees. Visit the Pruv Network testnet faucet, enter your wallet address, and request some test Pruv Network tokens.

Mainnet transactions are processed with zero gas fees.

3

Check your balance

After receiving Pruv Network tokens from the faucet, check your balance to confirm you have funds for deploying and interacting with the contract.Here’s how to check your PRUV token balance using curl to make an RPC request directly:

1. Replace <PRUV_RPC_URL> with the actual RPC URL of the Pruv Network.

2. Replace <Your_Wallet_Address> with your wallet address.

curl -X POST \
  <PRUV_RPC_URL> \
-H "Content-Type: application/json" \
-d '{
    "jsonrpc": "2.0",
    "method": "eth_getBalance",
    "params": ["<Your_Wallet_Address>", "latest"],
    "id": 1
  }'

Example Response

The response will look something like this:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1bc16d674ec80000"
}

The result field shows your balance in Wei (smallest unit of Pruv Network). To convert it to PRUV, you can use a converter, as 1 PRUV = 10^18 Wei.

4

Init hardhat project

Begin by creating a dedicated directory for your project and initializing a new Hardhat project within it. Hardhat will guide you through setting up essential files and configurations, including sample contracts, scripts, and a basic configuration file. This setup will provide the foundation for writing, compiling, testing, and deploying your smart contract.

As you go through this setup, Hardhat will create a hardhat.config.js file, which you’ll later modify to connect to the Pruv Network. This file is essential, as it lets you specify network settings, compiler options, and other project-specific configurations.

For detailed setup instructions, refer to the official Hardhat Project Setup Guide.

5

Config url and account in hardhat project

After setting up the Hardhat project, configure it to connect to the Pruv Network. Open the hardhat.config.js file generated during the initialization. In this file, you’ll add your Pruv Network network’s RPC URL and the private key of your wallet. These configurations allow Hardhat to deploy and interact with smart contracts on Pruv Network.

The hardhat.config.js file includes options for specifying network parameters, such as RPC URLs, chain IDs, and accounts. Be cautious with your private key and avoid exposing it in public repositories.

Once configured, your Hardhat project will be ready to compile, test, and deploy contracts directly to the Pruv Network.

For reference on network configuration options, you may consult the Hardhat Network Guide.

6

Write smart contract

Now, create your first smart contract to deploy on the Pruv Network. In the contracts directory of your Hardhat project, add a new file, such as HelloWorld.sol. This file will define the structure and functionality of your smart contract.

For example, here’s a simple HelloWorld contract:

// SPDX-License-Identifier: MIT
// Compiler version must be greater than or equal to 0.8.26 and less than 0.9.0
pragma solidity ^0.8.26;
contract HelloWorld {
    string public greet = "Hello World!";
}

This contract includes:

• A string variable, greet, initialized with the message “Hello World!”.

• The greet variable is marked as public, allowing any user to read this message directly from the contract.

This basic example helps you get familiar with Solidity syntax and smart contract structure. For more details on writing smart contracts in Solidity, refer to the Solidity Documentation, where you can explore syntax, data types, and contract features.

Once this contract is complete, you’ll be ready to move to the next step and compile it.

7

Compile smart contract

With your smart contract written, the next step is to compile it using Hardhat. Compilation converts the Solidity code into bytecode that can be deployed to the Pruv Network. Hardhat will check your code for syntax errors, ensure compatibility with the specified Solidity version, and generate the necessary artifacts for deployment.

To compile your contract, run the following command in your project directory:

npx hardhat compile

Hardhat will automatically detect the Solidity files in the contracts folder and compile them. After a successful compilation, you’ll find the compiled files in the artifacts directory. These artifacts include the bytecode and the contract’s ABI (Application Binary Interface), which will be essential for deploying and interacting with your contract.

If you encounter any errors, verify that the Solidity version specified in your hardhat.config.js file is compatible with your contract code.

For more details on compiling contracts with Hardhat, refer to the Hardhat Compilation Guide.

8

Write script to deploy contract

With your contract compiled, the next step is to create a deployment script to deploy it to the Pruv Network. This script will use Hardhat’s ethers.js integration to interact with your contract and deploy it to the blockchain.

In the scripts folder of your project, create a new file (for example, deploy.js) where you’ll write the deployment logic. This script will:

• Retrieve the contract’s compiled code and ABI from the artifacts directory.

• Connect to the specified Pruv Network using your configuration in hardhat.config.js.

• Deploy the contract and output its address.

Here’s an example deployment script for a simple contract like HelloWorld:

// scripts/deploy.js
async function main() {
  const [deployer] = await ethers.getSigners();
  console.log("Deploying contract with account:", deployer.address);
  // Retrieve the contract factory
  const HelloWorld = await ethers.getContractFactory("HelloWorld");
  // Deploy the contract
  const helloWorld = await HelloWorld.deploy();
  await helloWorld.deployed();
  console.log("HelloWorld contract deployed at:", helloWorld.address);
}
main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

In this example:

  • ethers.getSigners() provides the deployer account for deployment.

  • ethers.getContractFactory("HelloWorld") loads the compiled contract so it’s ready for deployment.

  • helloWorld.deploy() deploys the contract to the network, and await helloWorld.deployed() waits until deployment is confirmed.

Once this script is complete, you’ll be ready to execute it to deploy your contract to the Pruv Network.

For more details on writing and managing deployment scripts, see the Hardhat Scripting Guide.

This step explains the purpose of the deployment script, provides an example, and includes a link to further resources.

9

Deploy smart contract to Pruv Network

Deploying your contract is essential to make it accessible on the Pruv Network, where it can interact with other accounts and handle transactions. Once deployed, the contract’s functions can be called by users, allowing it to perform its intended role within the decentralized application (dApp).

In Hardhat, you can deploy your contract using Ignition, which provides a structured approach for deploying and managing smart contracts on a blockchain network. Ignition simplifies the process by letting you define deployment modules that automate contract deployment.

For detailed instructions on setting up and using Hardhat Ignition, refer to the Hardhat Development Guide

10

Verifying Smart Contract

To verify your deployed contract, you have two main approaches:

  1. Verifying Within Your Hardhat Project

Hardhat provides a built-in verification feature to simplify the process. To verify using Hardhat, follow the instructions in the Hardhat Verification Guide.

Alternatively, you can automate verification directly in your deployment script by adding the following

code after deploying your contract:

await run("verify:verify", {
  address: accountIngressAddress, // Replace with your contract's deployed address
  contract: "contracts/AccountIngress.sol:AccountIngress", // Replace with your contract path and name
});

This method integrates verification as part of your deployment process, ensuring the contract is verified as soon as it’s deployed.

  1. Manual Verification on the Explorer

If you prefer or need to verify manually, navigate to your contract’s page on the blockchain explorer. Locate your contract and select Verify & Publish. Follow the prompts to complete the verification process by uploading the contract source code and any required metadata.

Both approaches will make the contract’s source code visible and allow users to interact with it directly on the explorer.

Integration and APIs

Pruv Network offers a range of APIs to facilitate seamless integration with other systems, whether for data exchange, transaction processing, or user authentication. Developers can leverage these APIs to extend their applications’ functionality and integrate Pruv Network's features into existing platforms.

Documentation and Support

  • API Documentation: Full API documentation with examples to streamline integrations with Pruv Network, covering transaction processing, data retrieval, and user management.

  • Smart Contract Documentation: Guides for developing secure and optimized smart contracts, including code samples, best practices, and audit considerations.

  • Community and Developer Forums: Connect with Pruv Network's developer community to share knowledge, get feedback, and access peer support for complex development issues.

3. Developer FAQs

Frequently Asked Questions

This section addresses common questions from developers looking to build on Pruv Network, providing quick answers to get started effectively.

  • What programming languages are supported on Pruv Network? Pruv Network is compatible with Solidity, making it easy for developers experienced in Ethereum-based development to transition their skills. Other languages may be supported through interoperability and external tooling.

  • How do I test my application before deploying to the mainnet? Developers can deploy and test their applications on Pruv Network's testnet, which mirrors mainnet conditions and allows for thorough testing of transactions, smart contracts, and integrations.

  • Are there any fees to develop on Pruv Network? Currently PRUV network does not incur gas fee for any transaction within the network. The only fee users need to pay is when bridging tokens to another chain. However, in the future Pruv network will introduce a native PRUV token for all transaction fees in the network.

  • How can I ensure my smart contract is secure? Pruv Network provides a guide on smart contract security best practices, along with optional audit resources to help ensure that contracts are optimized and secure. Additionally, testing tools are available to identify and mitigate vulnerabilities.

  • What APIs are available for integration? Pruv Network offers APIs covering essential functions like asset transfers, data querying, and identity verification, which help integrate blockchain functionality into applications seamlessly.

  • Can I migrate an existing application to Pruv Network? Yes, applications built on compatible blockchain platforms (such as Ethereum) can be migrated to Pruv Network. Documentation is available to guide developers through the migration process, including steps for redeploying contracts and adjusting integrations.

  • Is there a developer community I can join? Absolutely! Pruv Network has an active community forum where developers can collaborate, share insights, and seek support from other network developers.

  • How do I stay updated on Pruv Network developments? Pruv Network provides updates through its developer portal, newsletters, and social media channels, ensuring developers stay informed about new features, tools, and security patches.

Last updated