<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Developers Forum for XinFin XDC Network: Justin White</title>
    <description>The latest articles on Developers Forum for XinFin XDC Network by Justin White (@justin_white_abe82e7f9bb4).</description>
    <link>https://www.xdc.dev/justin_white_abe82e7f9bb4</link>
    <image>
      <url>https://www.xdc.dev/images/p60tF5Y2Uac4paMl3EJDCFdnsbHgPFxsvWNEOqtjRAg/rs:fill:90:90/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL3VzZXIvcHJv/ZmlsZV9pbWFnZS82/MDcyL2NhNjk4Nzdi/LTI5NDYtNDg3MC05/ZTZmLWE5MDkyMjM0/Y2YxNi5wbmc</url>
      <title>Developers Forum for XinFin XDC Network: Justin White</title>
      <link>https://www.xdc.dev/justin_white_abe82e7f9bb4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://www.xdc.dev/feed/justin_white_abe82e7f9bb4"/>
    <language>en</language>
    <item>
      <title>Deploying a Paycheck Calculator DApp on XDC Network</title>
      <dc:creator>Justin White</dc:creator>
      <pubDate>Tue, 19 Aug 2025 12:52:59 +0000</pubDate>
      <link>https://www.xdc.dev/justin_white_abe82e7f9bb4/deploying-a-paycheck-calculator-dapp-on-xdc-network-3bkn</link>
      <guid>https://www.xdc.dev/justin_white_abe82e7f9bb4/deploying-a-paycheck-calculator-dapp-on-xdc-network-3bkn</guid>
      <description>&lt;p&gt;Blockchain isn’t just for trading tokens. Developers are finding new ways to bring everyday applications onto decentralized infrastructure. One example is payroll. Instead of using opaque systems, you can build a decentralized app (DApp) that calculates paychecks, handles deductions, and logs results transparently on-chain.&lt;/p&gt;

&lt;p&gt;In this tutorial, we’ll walk through how to build and deploy a simple Paycheck Calculator DApp on the XDC Network. By the end, you’ll understand how to write the smart contract, deploy it using developer tools, and interact with it from a frontend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why XDC for a Payroll DApp?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The XDC Network is an EVM-compatible blockchain with features that make it attractive for enterprise and real-world applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ultra-low fees: Transactions cost a fraction of a cent, which matters if you’re calculating salaries for dozens or hundreds of employees.&lt;/li&gt;
&lt;li&gt;High throughput: With 2-second block times, paycheck operations confirm quickly.&lt;/li&gt;
&lt;li&gt;EVM compatibility: If you know Solidity, Hardhat, or Truffle, you’re already halfway there.&lt;/li&gt;
&lt;li&gt;Real-world focus: XDC positions itself as an enterprise blockchain, which aligns perfectly with payroll and finance apps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These advantages make it an excellent choice for a DApp that needs to handle frequent calculations without racking up costs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up Your Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since XDC is EVM-compatible, you can use the same development stack you’d use for Ethereum.&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;/p&gt;

&lt;p&gt;Node.js and npm installed&lt;/p&gt;

&lt;p&gt;MetaMask (with XDC testnet added)&lt;/p&gt;

&lt;p&gt;Hardhat or Truffle&lt;/p&gt;

&lt;p&gt;Some XDC testnet tokens (available via faucet at apothem.network)&lt;/p&gt;

&lt;p&gt;For this guide, we’ll use Hardhat.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir paycheck-dapp
cd paycheck-dapp
npm init -y
npm install --save-dev hardhat @nomiclabs/hardhat-ethers ethers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize Hardhat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx hardhat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose “Create a basic sample project”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Writing the Smart Contract&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our contract will let employers calculate employee net salary after deductions like tax or insurance. This is simplified but demonstrates the principle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract PaycheckCalculator {
    struct Employee {
        uint256 baseSalary;
        uint256 taxRate; // percentage (e.g., 10 = 10%)
        uint256 insurance;
    }

    mapping(address =&amp;gt; Employee) public employees;

    function setEmployee(
        address _employee,
        uint256 _baseSalary,
        uint256 _taxRate,
        uint256 _insurance
    ) public {
        employees[_employee] = Employee(_baseSalary, _taxRate, _insurance);
    }

    function calculatePaycheck(address _employee) public view returns (uint256) {
        Employee memory emp = employees[_employee];
        uint256 tax = (emp.baseSalary * emp.taxRate) / 100;
        uint256 netSalary = emp.baseSalary - tax - emp.insurance;
        return netSalary;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;setEmployee() stores employee details on-chain.&lt;/li&gt;
&lt;li&gt;calculatePaycheck() computes the net salary dynamically.&lt;/li&gt;
&lt;li&gt;The data is transparent and immutable—great for auditability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Deploying on XDC Testnet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add XDC’s Apothem Testnet to your Hardhat config. In &lt;code&gt;hardhat.config.js:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require("@nomiclabs/hardhat-ethers");

module.exports = {
  solidity: "0.8.0",
  networks: {
    apothem: {
      url: "https://rpc.apothem.network",
      accounts: ["YOUR_PRIVATE_KEY_HERE"]
    }
  }
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;YOUR_PRIVATE_KEY_HERE&lt;/code&gt; with your MetaMask private key (never use your mainnet key for testing).&lt;/p&gt;

&lt;p&gt;Now create a deployment script in &lt;code&gt;scripts/deploy.js:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function main() {
  const PaycheckCalculator = await ethers.getContractFactory("PaycheckCalculator");
  const calculator = await PaycheckCalculator.deploy();
  await calculator.deployed();
  console.log("Contract deployed to:", calculator.address);
}

main()
  .then(() =&amp;gt; process.exit(0))
  .catch((error) =&amp;gt; {
    console.error(error);
    process.exit(1);
  });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see your contract address printed. That’s your live &lt;a href="https://joinotto.com/calculator/paycheck"&gt;Paycheck Calculator&lt;/a&gt; on XDC testnet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Interacting With the Contract&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can test it with Hardhat’s console or through a frontend app.&lt;/p&gt;

&lt;p&gt;Example with Hardhat Console&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx hardhat console --network apothem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Inside the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Contract = await ethers.getContractFactory("PaycheckCalculator");
const contract = await Contract.attach("YOUR_DEPLOYED_CONTRACT_ADDRESS");

// Set employee data
await contract.setEmployee("0xEmployeeWallet", 5000, 10, 200);

// Calculate paycheck
const net = await contract.calculatePaycheck("0xEmployeeWallet");
console.log("Net Salary:", net.toString());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the calculated net salary returned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Adding a Simple Frontend&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most payroll DApps will have a UI. For a simple React frontend:&lt;/p&gt;

&lt;p&gt;Install dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app paycheck-frontend
cd paycheck-frontend
npm install ethers

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example component &lt;code&gt;(App.js):&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from "react";
import { ethers } from "ethers";

const contractAddress = "YOUR_DEPLOYED_CONTRACT_ADDRESS";
const abi = [
  "function setEmployee(address _employee, uint256 _baseSalary, uint256 _taxRate, uint256 _insurance) public",
  "function calculatePaycheck(address _employee) public view returns (uint256)"
];

function App() {
  const [netPay, setNetPay] = useState("");

  async function getPaycheck(employee) {
    const provider = new ethers.providers.Web3Provider(window.ethereum);
    const contract = new ethers.Contract(contractAddress, abi, provider);
    const result = await contract.calculatePaycheck(employee);
    setNetPay(result.toString());
  }

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;XDC Paycheck Calculator&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; getPaycheck("0xEmployeeWallet")}&amp;gt;
        Get Net Salary
      &amp;lt;/button&amp;gt;
      &amp;lt;p&amp;gt;Net Pay: {netPay}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Connect MetaMask to XDC Testnet, and your app can now query paycheck results.&lt;/p&gt;

&lt;p&gt;Step 6: Next Steps and Improvements&lt;/p&gt;

&lt;p&gt;This is just the beginning. A real-world payroll DApp could add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automated payments: Integrate stablecoins or tokenized assets on XDC.&lt;/li&gt;
&lt;li&gt;Role-based access: Limit setEmployee() to employer accounts.&lt;/li&gt;
&lt;li&gt;Batch payroll: Calculate and distribute payments for multiple employees in one transaction.&lt;/li&gt;
&lt;li&gt;Gasless transactions: Explore XDC’s subnet staking for fee-less user experience.&lt;/li&gt;
&lt;li&gt;Integration with off-chain logic: Calculate complex payroll scenarios off-chain and only log results on-chain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why This Matters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Payroll is a classic use case where transparency and efficiency matter. By building it on XDC:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Employers cut costs on processing fees.&lt;/li&gt;
&lt;li&gt;Employees gain trust in transparent, immutable salary calculations.&lt;/li&gt;
&lt;li&gt;Auditors can verify paycheck records without intermediaries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This aligns with XDC’s broader mission of bringing blockchain to real-world finance and enterprise use cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We’ve walked through how to build and deploy a simple Paycheck Calculator DApp on the XDC Network using Solidity and Hardhat. With ultra-low fees, fast confirmations, and EVM compatibility, XDC is an ideal platform for payroll and other enterprise apps.&lt;/p&gt;

&lt;p&gt;Whether you expand this into a full payroll management system or keep it as a demo, the core idea is clear: blockchain isn’t just for trading—it can power practical, everyday business processes.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
