<?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: Rushabh Parmar</title>
    <description>The latest articles on Developers Forum for XinFin XDC Network by Rushabh Parmar (@rushabh_parmar).</description>
    <link>https://www.xdc.dev/rushabh_parmar</link>
    <image>
      <url>https://www.xdc.dev/images/BuO1Ma9lh4SI9q-Gh3VwMWGvxEkW10_Kxv1hixfAWwY/rs:fill:90:90/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL3VzZXIvcHJv/ZmlsZV9pbWFnZS84/Mi8xNTIzZTZkZC1l/MTcyLTRmY2YtYTBi/Ni0yOWQzOTdkZjcy/MDAuanBn</url>
      <title>Developers Forum for XinFin XDC Network: Rushabh Parmar</title>
      <link>https://www.xdc.dev/rushabh_parmar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://www.xdc.dev/feed/rushabh_parmar"/>
    <language>en</language>
    <item>
      <title>Understanding the XDC Network Slashing Mechanism: Ensuring Network Stability</title>
      <dc:creator>Rushabh Parmar</dc:creator>
      <pubDate>Tue, 05 May 2026 06:23:02 +0000</pubDate>
      <link>https://www.xdc.dev/rushabh_parmar/understanding-the-xdc-network-slashing-mechanism-ensuring-network-stability-471o</link>
      <guid>https://www.xdc.dev/rushabh_parmar/understanding-the-xdc-network-slashing-mechanism-ensuring-network-stability-471o</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The XDC Network, powered by its XDC 2.0 consensus mechanism, employs a slashing mechanism to maintain network stability and ensure validator accountability. Unlike punitive slashing systems in other blockchains, XDC's approach focuses on corrective measures that balance network efficiency with fairness to node operators.&lt;/p&gt;

&lt;p&gt;This article explores how slashing works, its impact on network performance, and practical solutions for masternode operators to avoid slashing events.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Slashing is Critical for Network Performance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Timeout Problem
&lt;/h3&gt;

&lt;p&gt;In XDPoS, masternodes create blocks in a round-robin fashion. When a masternode fails to create a block during its designated turn, the entire network experiences a &lt;strong&gt;10-second timeout&lt;/strong&gt; before the next masternode proceeds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impact Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If 27 masternodes (25% of the 108-node network) are underperforming:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wasted time per epoch&lt;/strong&gt;: 27 nodes × 6 average turns × 10 seconds = 1,620 seconds&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normal epoch duration&lt;/strong&gt;: 1,800 seconds
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance degradation&lt;/strong&gt;: 47.4%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network throughput&lt;/strong&gt;: Reduced from 2,000+ TPS to ~1,050 TPS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without slashing, these underperforming masternodes would continue degrading network performance indefinitely. With slashing, the network automatically excludes them, restoring full operational efficiency.&lt;/p&gt;




&lt;h2&gt;
  
  
  How XDC Slashing Works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Slashing Trigger
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Primary Condition&lt;/strong&gt;: A masternode that fails to sign &lt;strong&gt;any block&lt;/strong&gt; during an &lt;strong&gt;entire epoch&lt;/strong&gt; (900 blocks) will be slashed.&lt;/p&gt;

&lt;p&gt;The system evaluates complete inactivity over an epoch, not isolated missed blocks. This prevents false positives from temporary network hiccups while identifying genuinely unresponsive masternodes.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Slashing Cycle
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Phase 1: Performance Monitoring&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Each epoch consists of 900 blocks (approximately 30 minutes):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Epoch N (900 blocks, ~1800 seconds)
├── Masternodes take turns creating blocks
├── Block Signer smart contract records all signatures
└── Block 900 (Checkpoint): Performance evaluation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Phase 2: Detection and Slashing&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;At the checkpoint block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="n"&gt;masternode&lt;/span&gt; &lt;span class="n"&gt;M&lt;/span&gt; &lt;span class="kr"&gt;in&lt;/span&gt; &lt;span class="n"&gt;MasternodeSet&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;signatures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BlockSigner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getSignatureCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;currentEpoch&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signatures&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;slashMasternode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;addToSlashedList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;currentEpoch&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Point&lt;/strong&gt;: Zero signatures = automatic slashing. Partial participation = no slashing.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Phase 3: Exclusion Period (4 Epochs)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Once slashed, a masternode enters a 4-epoch exclusion period (~2 hours):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Epoch N: Masternode slashed (0 signatures)
├── Epochs N+1 to N+4: Excluded from block creation
│   └── Can still verify/sign blocks created by others
└── Epoch N+5: Eligible for reinstatement
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;During Exclusion:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cannot create blocks&lt;/li&gt;
&lt;li&gt;Can verify and sign blocks (demonstrates liveness)&lt;/li&gt;
&lt;li&gt;This activity is required for recovery&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Phase 4: Automatic Reinstatement&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;After 4 epochs, the masternode automatically rejoins if:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It signed blocks during the exclusion period&lt;/li&gt;
&lt;li&gt;Stake remains locked in the smart contract&lt;/li&gt;
&lt;li&gt;No additional slashing events occurred&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Byzantine Fault Tolerance and Network Safety
&lt;/h2&gt;

&lt;p&gt;The XDC Network maintains Byzantine Fault Tolerance through its 75% finality requirement:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BFT Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Finality requires&lt;/strong&gt;: 81 validator signatures (75% of 108)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network tolerates&lt;/strong&gt;: Up to 27 faulty/offline masternodes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Critical threshold&lt;/strong&gt;: If 28+ masternodes are slashed, finality becomes impossible&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Slashed Nodes&lt;/th&gt;
&lt;th&gt;Active Nodes&lt;/th&gt;
&lt;th&gt;BFT Status&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0-10&lt;/td&gt;
&lt;td&gt;98-108&lt;/td&gt;
&lt;td&gt;✅ Excellent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11-27&lt;/td&gt;
&lt;td&gt;81-97&lt;/td&gt;
&lt;td&gt;✅ Safe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;27&lt;/td&gt;
&lt;td&gt;81&lt;/td&gt;
&lt;td&gt;⚠️ Critical&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;28+&lt;/td&gt;
&lt;td&gt;&amp;lt;81&lt;/td&gt;
&lt;td&gt;❌ Broken&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Double Validation Integration
&lt;/h2&gt;

&lt;p&gt;XDC's slashing mechanism integrates with its Double Validation system:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Block Creator&lt;/strong&gt;: Creates block per round-robin schedule&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Block Verifier&lt;/strong&gt;: Randomly selected to verify and co-sign&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Finalization&lt;/strong&gt;: Requires both signatures&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Slashing Impact:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slashed masternodes are excluded from block creator rotation&lt;/li&gt;
&lt;li&gt;Can still participate as random block verifiers&lt;/li&gt;
&lt;li&gt;Allows demonstration of liveness for recovery&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Solutions to Avoid Slashing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Alternative: Third-Party Masternode Services
&lt;/h3&gt;

&lt;p&gt;If you do not have the technical resources, infrastructure, or time to maintain a masternode yourself, there are several third-party services and volunteers willing to provide professional masternode hosting and management services. These providers handle all technical aspects including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Infrastructure setup and maintenance&lt;/li&gt;
&lt;li&gt;24/7 uptime management&lt;/li&gt;
&lt;li&gt;Security hardening and updates&lt;/li&gt;
&lt;li&gt;Failover and redundancy&lt;/li&gt;
&lt;li&gt;Technical support and troubleshooting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Available Third-Party Services:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IndSoft&lt;/strong&gt; - Professional masternode hosting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NODE FORGE&lt;/strong&gt; - Managed validator services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zeeve&lt;/strong&gt; - Enterprise blockchain infrastructure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BlockDaemon&lt;/strong&gt; - Institutional-grade node operations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tatum&lt;/strong&gt; - Blockchain infrastructure platform&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NOWNodes&lt;/strong&gt; - Node hosting and API services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asternodes&lt;/strong&gt; - Validator management services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ankr&lt;/strong&gt; - Decentralized node infrastructure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;thirdweb&lt;/strong&gt; - Web3 infrastructure provider&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GOLDSKY&lt;/strong&gt; - Blockchain data infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important Considerations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When selecting a third-party service provider:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Research their track record and uptime history&lt;/li&gt;
&lt;li&gt;Understand their fee structure&lt;/li&gt;
&lt;li&gt;Verify their security practices&lt;/li&gt;
&lt;li&gt;Check their support responsiveness&lt;/li&gt;
&lt;li&gt;Review client testimonials&lt;/li&gt;
&lt;li&gt;Ensure they have experience with XDC Network&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;DISCLAIMER:&lt;/strong&gt; &lt;em&gt;XDC Network does not officially endorse any third-party services. Please perform due diligence and research before proceeding with any service provider. You remain responsible for your staked XDC and masternode performance.&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  For Self-Hosted Masternodes:Infrastructure Requirements
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Hardware Specifications
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Minimum Requirements:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CPU&lt;/strong&gt;: 12+ core&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAM&lt;/strong&gt;: 32 GB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: 2 TB NVMe SSD&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network&lt;/strong&gt;: 100 Mbps (1 Gbps recommended)&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Insufficient CPU → slow block processing&lt;/li&gt;
&lt;li&gt;Insufficient RAM → system swapping and delays&lt;/li&gt;
&lt;li&gt;HDD instead of SSD → missed signing windows&lt;/li&gt;
&lt;li&gt;Unstable network → failed peer communication&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Network Infrastructure
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Critical Requirements:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static Public IP (mandatory)&lt;/li&gt;
&lt;li&gt;99.99%+ uptime SLA (use tier-3+ data centers)&lt;/li&gt;
&lt;li&gt;DDoS protection&lt;/li&gt;
&lt;li&gt;Low latency (&amp;lt;100ms to network peers)&lt;/li&gt;
&lt;li&gt;Redundant connectivity&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. Proper Node Setup
&lt;/h3&gt;

&lt;p&gt;Follow the official setup guide:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repository&lt;/strong&gt;: &lt;a href="https://github.com/XinFinOrg/XinFin-Node"&gt;https://github.com/XinFinOrg/XinFin-Node&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setup Steps:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Clone the official repository&lt;/span&gt;
git clone https://github.com/XinFinOrg/XinFin-Node
&lt;span class="nb"&gt;cd &lt;/span&gt;XinFin-Node

&lt;span class="c"&gt;# Run the setup script&lt;/span&gt;
./setup.sh

&lt;span class="c"&gt;# Key configuration parameters:&lt;/span&gt;
&lt;span class="c"&gt;# - Static IP address&lt;/span&gt;
&lt;span class="c"&gt;# - Port 30303 open for P2P&lt;/span&gt;
&lt;span class="c"&gt;# - Proper keystore and password&lt;/span&gt;
&lt;span class="c"&gt;# - Adequate system resources&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Essential Configuration:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--syncmode "full"&lt;/code&gt;: Complete blockchain sync&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--mine&lt;/code&gt;: Enable block creation&lt;/li&gt;
&lt;li&gt;Firewall: Open port 30303, restrict RPC access&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Implement Hot Standby Architecture
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────┐         ┌─────────────────────┐
│  Primary Masternode │         │  Hot Standby Node   │
│  - Active mining    │◄───────►│  - Synced, ready    │
│  - Signing blocks   │         │  - Not mining       │
└─────────────────────┘         └─────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Critical Rules:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Never run both nodes with same key simultaneously&lt;/strong&gt; (causes double-signing → 100% rewards loss)&lt;/li&gt;
&lt;li&gt;Keep standby fully synced at all times&lt;/li&gt;
&lt;li&gt;Document failover procedure&lt;/li&gt;
&lt;li&gt;Practice failover monthly&lt;/li&gt;
&lt;li&gt;Target failover time: &amp;lt;5 minutes&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  3. Regular Maintenance
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Update Schedule:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Critical patches&lt;/strong&gt;: Within 24 hours&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocol upgrades&lt;/strong&gt;: Per XDC Team announcements&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular updates&lt;/strong&gt;: Monthly maintenance windows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Planned Maintenance:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update procedure&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;XinFin-Node &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git pull origin master
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;

&lt;span class="c"&gt;# Restart (target: &amp;lt;10 minutes downtime)&lt;/span&gt;
docker-compose down
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;

&lt;span class="c"&gt;# Verify node is signing blocks within 5 minutes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Security Hardening
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Firewall Configuration:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic firewall setup&lt;/span&gt;
ufw default deny incoming
ufw default allow outgoing

&lt;span class="c"&gt;# Allow P2P (essential)&lt;/span&gt;
ufw allow 30303/tcp

&lt;span class="c"&gt;# Allow RPC only from localhost&lt;/span&gt;
ufw allow from 127.0.0.1 to any port 8545

&lt;span class="c"&gt;# Allow SSH from trusted IPs only&lt;/span&gt;
ufw allow from YOUR_ADMIN_IP to any port 22

ufw &lt;span class="nb"&gt;enable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Protection:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use strong passwords (25+ characters)&lt;/li&gt;
&lt;li&gt;Store keys in encrypted files with restricted permissions (&lt;code&gt;chmod 600&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Never store unencrypted private keys on servers&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Verify Network Connectivity
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Check Peer Connections:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check peer count (should be &amp;gt;10)&lt;/span&gt;
docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; xinfinnetwork_xdcnode_1 geth attach /work/xdcchain/XDC.ipc &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--exec&lt;/span&gt; &lt;span class="s1"&gt;'admin.peers.length'&lt;/span&gt;

&lt;span class="c"&gt;# Add peers manually if needed&lt;/span&gt;
docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; xinfinnetwork_xdcnode_1 geth attach /work/xdcchain/XDC.ipc &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--exec&lt;/span&gt; &lt;span class="s1"&gt;'admin.addPeer("enode://PEER_ID@IP:PORT")'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Target&lt;/strong&gt;: Maintain 15-30 peer connections for optimal resilience.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Ensure Continuous Sync
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Verify Sync Status:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check current block number&lt;/span&gt;
docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; xinfinnetwork_xdcnode_1 geth attach /work/xdcchain/XDC.ipc &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--exec&lt;/span&gt; &lt;span class="s1"&gt;'eth.blockNumber'&lt;/span&gt;

&lt;span class="c"&gt;# Compare to network: https://xinfin.network&lt;/span&gt;

&lt;span class="c"&gt;# Check sync status&lt;/span&gt;
docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; xinfinnetwork_xdcnode_1 geth attach /work/xdcchain/XDC.ipc &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--exec&lt;/span&gt; &lt;span class="s1"&gt;'eth.syncing'&lt;/span&gt;
&lt;span class="c"&gt;# Should return "false" if fully synced&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Action Guidelines:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;lt;10 blocks behind → Monitor&lt;/li&gt;
&lt;li&gt;10-100 blocks behind → Check peers and connectivity&lt;/li&gt;
&lt;li&gt;&amp;gt;100 blocks behind → Investigate immediately, may need restart&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Pre-Launch Checklist
&lt;/h3&gt;

&lt;p&gt;Before activating your masternode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Hardware meets recommended specifications&lt;/li&gt;
&lt;li&gt; Static IP configured and tested&lt;/li&gt;
&lt;li&gt; Node deployed from official repository&lt;/li&gt;
&lt;li&gt; Full blockchain sync completed&lt;/li&gt;
&lt;li&gt; Firewall configured correctly&lt;/li&gt;
&lt;li&gt; Hot standby node synced&lt;/li&gt;
&lt;li&gt; Failover procedure documented and tested&lt;/li&gt;
&lt;li&gt; Keys secured properly&lt;/li&gt;
&lt;li&gt; 10,000,000 XDC staked&lt;/li&gt;
&lt;li&gt; KYC completed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Daily Operational Checks
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Daily:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify sync status (within 10 blocks)&lt;/li&gt;
&lt;li&gt;Check peer count (&amp;gt;10 peers)&lt;/li&gt;
&lt;li&gt;Review system logs for errors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Weekly:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify standby node is synced&lt;/li&gt;
&lt;li&gt;Test failover readiness&lt;/li&gt;
&lt;li&gt;Check for software updates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Monthly:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update node software&lt;/li&gt;
&lt;li&gt;Test complete failover&lt;/li&gt;
&lt;li&gt;Security audit&lt;/li&gt;
&lt;li&gt;Backup configurations&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Recovery After Slashing
&lt;/h2&gt;

&lt;p&gt;If your masternode gets slashed, follow this recovery process:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Confirm Slashing (5 Minutes)
&lt;/h3&gt;

&lt;p&gt;Check your status:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit &lt;a href="https://xdcscan.com"&gt;https://xdcscan.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Enter your masternode address&lt;/li&gt;
&lt;li&gt;Verify epoch performance shows 0 signatures&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Diagnose Root Cause (30 Minutes)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Solution&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Node offline&lt;/td&gt;
&lt;td&gt;Service status&lt;/td&gt;
&lt;td&gt;Restart service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Out of sync&lt;/td&gt;
&lt;td&gt;Sync progress&lt;/td&gt;
&lt;td&gt;Wait for completion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No peers&lt;/td&gt;
&lt;td&gt;Peer count&lt;/td&gt;
&lt;td&gt;Add peers manually&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Disk full&lt;/td&gt;
&lt;td&gt;Disk usage&lt;/td&gt;
&lt;td&gt;Clear space&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory issues&lt;/td&gt;
&lt;td&gt;System resources&lt;/td&gt;
&lt;td&gt;Restart, upgrade RAM&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 3: Fix the Issue (1 Hour)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Restart Node:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose restart
docker-compose logs &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nt"&gt;--tail&lt;/span&gt; 100

&lt;span class="c"&gt;# Verify sync resumption&lt;/span&gt;
docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; xinfinnetwork_xdcnode_1 geth attach /work/xdcchain/XDC.ipc &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--exec&lt;/span&gt; &lt;span class="s1"&gt;'eth.syncing'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add Peers:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check firewall&lt;/span&gt;
ufw status

&lt;span class="c"&gt;# Verify P2P port&lt;/span&gt;
netstat &lt;span class="nt"&gt;-tuln&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;30303

&lt;span class="c"&gt;# Add peers&lt;/span&gt;
bash peer.sh

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Demonstrate Liveness (4 Epochs)
&lt;/h3&gt;

&lt;p&gt;During the 4-epoch exclusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your node can verify and sign blocks (even though it can't create them)&lt;/li&gt;
&lt;li&gt;This demonstrates operational status&lt;/li&gt;
&lt;li&gt;Target: Sign &amp;gt;50% of blocks during exclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Automatic Reinstatement (Epoch N+5)
&lt;/h3&gt;

&lt;p&gt;Your masternode automatically rejoins if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You signed blocks during exclusion&lt;/li&gt;
&lt;li&gt;Stake remains locked&lt;/li&gt;
&lt;li&gt;No additional slashing occurred&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Verify Recovery:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node creates blocks again within first few hundred blocks of epoch N+5&lt;/li&gt;
&lt;li&gt;Check your signatures in Block Signer contract&lt;/li&gt;
&lt;li&gt;Confirm address in active masternode list&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Best Practices Summary
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Do's ✅
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Use tier-3+ data centers or reputable cloud providers&lt;/li&gt;
&lt;li&gt;Maintain a fully synced hot standby node&lt;/li&gt;
&lt;li&gt;Follow official setup guide: &lt;a href="https://github.com/XinFinOrg/XinFin-Node"&gt;https://github.com/XinFinOrg/XinFin-Node&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Keep software updated with security patches&lt;/li&gt;
&lt;li&gt;Use strong security practices (firewall, key protection)&lt;/li&gt;
&lt;li&gt;Verify sync status daily&lt;/li&gt;
&lt;li&gt;Document all procedures&lt;/li&gt;
&lt;li&gt;Test failover monthly&lt;/li&gt;
&lt;li&gt;Maintain adequate system resources&lt;/li&gt;
&lt;li&gt;Keep &amp;gt;10 peer connections&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Don'ts ❌
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Never run two nodes with same key simultaneously&lt;/li&gt;
&lt;li&gt;Don't use unreliable infrastructure&lt;/li&gt;
&lt;li&gt;Don't ignore software updates&lt;/li&gt;
&lt;li&gt;Don't skip regular maintenance&lt;/li&gt;
&lt;li&gt;Don't store unencrypted private keys&lt;/li&gt;
&lt;li&gt;Don't let node fall &amp;gt;100 blocks behind&lt;/li&gt;
&lt;li&gt;Don't operate without failover plan&lt;/li&gt;
&lt;li&gt;Don't use insufficient hardware&lt;/li&gt;
&lt;li&gt;Don't neglect firewall configuration&lt;/li&gt;
&lt;li&gt;Don't skip pre-launch checklist&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The XDC Network's slashing mechanism maintains network stability through:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Correction over punishment&lt;/strong&gt; - Technical issues allow recovery&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparent enforcement&lt;/strong&gt; - Automated via smart contracts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network efficiency&lt;/strong&gt; - Excludes underperforming nodes to maintain throughput&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Byzantine fault tolerance&lt;/strong&gt; - Ensures security up to 25% faulty nodes&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Key Takeaways
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For Prevention:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Robust infrastructure eliminates slashing risk&lt;/li&gt;
&lt;li&gt;Proper configuration and maintenance are critical&lt;/li&gt;
&lt;li&gt;Hot standby provides failover capability&lt;/li&gt;
&lt;li&gt;Regular checks catch issues early&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For Recovery:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slashing is temporary, not permanent&lt;/li&gt;
&lt;li&gt;Demonstrate liveness during exclusion&lt;/li&gt;
&lt;li&gt;Automatic reinstatement after 4 epochs&lt;/li&gt;
&lt;li&gt;Fix root cause to prevent recurrence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these guidelines, masternode operators can avoid slashing while contributing to a stable, high-performance XDC Network.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Masternode Setup&lt;/strong&gt;: &lt;a href="https://github.com/XinFinOrg/XinFin-Node"&gt;https://github.com/XinFinOrg/XinFin-Node&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation&lt;/strong&gt;: &lt;a href="https://docs.xdc.network"&gt;https://docs.xdc.network&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network Explorer&lt;/strong&gt;: &lt;a href="https://xdc.blocksscan.io/"&gt;https://xdc.blocksscan.io/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical Whitepaper&lt;/strong&gt;: &lt;a href="https://xinfin.org/docs/whitepaper-tech.pdf"&gt;https://xinfin.org/docs/whitepaper-tech.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community&lt;/strong&gt;: &lt;a href="https://xdc.dev"&gt;https://xdc.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Telegram&lt;/strong&gt;: &lt;a href="https://t.me/xinfintalk"&gt;https://t.me/xinfintalk&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>xdc</category>
      <category>masternode</category>
      <category>slashing</category>
      <category>network</category>
    </item>
    <item>
      <title>Integrating AI with Smart Contracts on XDC Network</title>
      <dc:creator>Rushabh Parmar</dc:creator>
      <pubDate>Sat, 02 May 2026 05:44:09 +0000</pubDate>
      <link>https://www.xdc.dev/rushabh_parmar/integrating-ai-with-smart-contracts-on-xdc-network-5e1n</link>
      <guid>https://www.xdc.dev/rushabh_parmar/integrating-ai-with-smart-contracts-on-xdc-network-5e1n</guid>
      <description>&lt;h2&gt;
  
  
  🎯 What You Will Build
&lt;/h2&gt;

&lt;p&gt;In this guide you will manually deploy a &lt;strong&gt;real, working AI-powered smart contract&lt;/strong&gt; on XDC Apothem Testnet step by step. Here is the contract we deployed live while writing this article:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Contract Address&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/address/0xE031843227668f530DC0E59Bb093ED6763Dcd84D"&gt;&lt;code&gt;0xE031843227668f530DC0E59Bb093ED6763Dcd84D&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Deploy TX&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/tx/0x7fa75b52a379b20a1c3a4d8966a7c78f1ac29ba69eb25dded01185dcc66c7843"&gt;&lt;code&gt;0x7fa75b52...c7843&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Loan Application TX&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/tx/0xe95ba3312aa0e710fb45cc6980c271a499570c65d89eb45cadda118719d64387"&gt;&lt;code&gt;0xe95ba331...4387&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AI Score Submission TX&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/tx/0xcf230923452c8d054435b685ce67f7ad138e4b37e1688e2e8a6852b8af12edf9"&gt;&lt;code&gt;0xcf230923...edf9&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Network&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;XDC Apothem Testnet (Chain ID 51)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AI Score&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;711 / 1000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Risk Category&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MEDIUM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Decision&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ APPROVED&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can verify every transaction right now on &lt;a href="https://testnet.xdcscan.com/address/0xE031843227668f530DC0E59Bb093ED6763Dcd84D"&gt;XDCScan Testnet&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Blockchain and Artificial Intelligence are two of the most transformative technologies of our time. Separately they are powerful. Together they unlock entirely new possibilities — smarter contracts, automated decision-making, and decentralized intelligence.&lt;/p&gt;

&lt;p&gt;XDC Network is a perfect platform for this combination:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;EVM compatible&lt;/strong&gt; — write contracts in Solidity, use standard tools like Hardhat&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Near-zero gas fees&lt;/strong&gt; (~$0.00001 per transaction)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2-second finality&lt;/strong&gt; — AI decisions confirmed almost instantly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2,000 TPS&lt;/strong&gt; — scales to high-frequency AI-triggered actions&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Are We Building?
&lt;/h2&gt;

&lt;p&gt;An &lt;strong&gt;AI-Powered Loan Approval System&lt;/strong&gt; — a real-world pattern used in trade finance and credit scoring:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ User calls applyForLoan() on-chain ]
              ↓
[ AI model analyzes applicant off-chain ]
              ↓
[ Oracle submits credit score on-chain ]
              ↓
[ Contract automatically APPROVES or REJECTS ]
              ↓
[ Decision is permanent and publicly verifiable ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called the &lt;strong&gt;oracle pattern&lt;/strong&gt; — the standard way to connect AI (off-chain) with smart contracts (on-chain). The AI runs off-chain because it is too expensive to run ML models on-chain. A trusted "oracle" wallet then submits the result to the smart contract.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Install&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Node.js&lt;/td&gt;
&lt;td&gt;v18+&lt;/td&gt;
&lt;td&gt;&lt;a href="https://nodejs.org"&gt;nodejs.org&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;v3.10+&lt;/td&gt;
&lt;td&gt;&lt;a href="https://python.org"&gt;python.org&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MetaMask&lt;/td&gt;
&lt;td&gt;Latest&lt;/td&gt;
&lt;td&gt;&lt;a href="https://metamask.io"&gt;metamask.io&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Git&lt;/td&gt;
&lt;td&gt;Any&lt;/td&gt;
&lt;td&gt;&lt;a href="https://git-scm.com"&gt;git-scm.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Step 1 — Add XDC Apothem Testnet to MetaMask
&lt;/h2&gt;

&lt;p&gt;Open MetaMask → Settings → Networks → Add Network and fill in:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Network Name&lt;/td&gt;
&lt;td&gt;XDC Apothem Testnet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RPC URL&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://erpc.apothem.network&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chain ID&lt;/td&gt;
&lt;td&gt;&lt;code&gt;51&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Currency Symbol&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TXDC&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Block Explorer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://testnet.xdcscan.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then get free test XDC from the faucet:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://faucet.apothem.network"&gt;https://faucet.apothem.network&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; You need &lt;strong&gt;two wallets&lt;/strong&gt; for this tutorial — one as the &lt;strong&gt;Deployer&lt;/strong&gt; (contract owner) and one as the &lt;strong&gt;Oracle&lt;/strong&gt; (the AI result submitter). Create both in MetaMask and fund both from the faucet.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 2 — Set Up the Project
&lt;/h2&gt;

&lt;p&gt;Open your terminal (Command Prompt on Windows) and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;xdc-ai-demo
&lt;span class="nb"&gt;cd &lt;/span&gt;xdc-ai-demo
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; hardhat@2.22.19 @nomicfoundation/hardhat-ethers@3 ethers@6 dotenv &lt;span class="nt"&gt;--legacy-peer-deps&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, initialise Hardhat:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;When prompted, select &lt;strong&gt;"Create a JavaScript project"&lt;/strong&gt; and accept all defaults.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3 — Configure Hardhat for XDC Apothem
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in the root of your project — &lt;strong&gt;never commit this to Git:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DEPLOYER_KEY=your_deployer_private_key_here
ORACLE_KEY=your_oracle_private_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;To export a private key from MetaMask: click your account → Account Details → Export Private Key. Use test-only wallets only.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Add &lt;code&gt;.env&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;".env"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now update &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 javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@nomicfoundation/hardhat-ethers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;solidity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0.8.20&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;apothem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://erpc.apothem.network&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;accounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DEPLOYER_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ORACLE_KEY&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;chainId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

      &lt;span class="c1"&gt;// ⚠️  XDC-specific settings — required for successful deployment&lt;/span&gt;
      &lt;span class="c1"&gt;// After the XDC 2.0 upgrade, Apothem minimum gas price is 12.5 gwei&lt;/span&gt;
      &lt;span class="c1"&gt;// XDC does NOT support EIP-1559 — always use gasPrice (not maxFeePerGas)&lt;/span&gt;
      &lt;span class="na"&gt;gasPrice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12500000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// 12.5 gwei in wei&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4 — Write the Smart Contract
&lt;/h2&gt;

&lt;p&gt;Delete the default &lt;code&gt;contracts/Lock.sol&lt;/code&gt; and create &lt;code&gt;contracts/AIScoreOracle.sol&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="c1"&gt;// SPDX-License-Identifier: MIT
&lt;/span&gt;&lt;span class="k"&gt;pragma&lt;/span&gt; &lt;span class="n"&gt;solidity&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;/// @title AIScoreOracle
/// @notice AI-powered loan approval contract on XDC Network
/// @dev Live on Apothem: 0xE031843227668f530DC0E59Bb093ED6763Dcd84D
&lt;/span&gt;&lt;span class="k"&gt;contract&lt;/span&gt; &lt;span class="n"&gt;AIScoreOracle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;trustedOracle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// Wallet that submits AI scores
&lt;/span&gt;    &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;approvalThreshold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Minimum score to get approved (0–1000)
&lt;/span&gt;    &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;totalApplications&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;aiScore&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// AI credit score (0–1000)
&lt;/span&gt;        &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="n"&gt;riskCategory&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// "LOW", "MEDIUM", "HIGH", "PENDING"
&lt;/span&gt;        &lt;span class="kt"&gt;bool&lt;/span&gt;    &lt;span class="n"&gt;approved&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;bool&lt;/span&gt;    &lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;mapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;address&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;applicantList&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;LoanApplied&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;AIScoreSubmitted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="n"&gt;risk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;bool&lt;/span&gt;    &lt;span class="n"&gt;approved&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;modifier&lt;/span&gt; &lt;span class="n"&gt;onlyOwner&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="s"&gt;"Only owner"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;modifier&lt;/span&gt; &lt;span class="n"&gt;onlyOracle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;trustedOracle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Only oracle"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_oracle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_threshold&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;owner&lt;/span&gt;             &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;trustedOracle&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_oracle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;approvalThreshold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_threshold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;/// @notice Any user can apply for a loan (once per address)
&lt;/span&gt;    &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;applyForLoan&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Already applied"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;aiScore&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;riskCategory&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"PENDING"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;approved&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="n"&gt;applicantList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;totalApplications&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;emit&lt;/span&gt; &lt;span class="n"&gt;LoanApplied&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;/// @notice Oracle submits the AI credit score for an applicant
&lt;/span&gt;    &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;submitAIScore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="n"&gt;onlyOracle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                          &lt;span class="s"&gt;"Score must be 0-1000"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"No application found"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="s"&gt;"Already processed"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="k"&gt;storage&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aiScore&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;approved&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;approvalThreshold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt;      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;               &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;riskCategory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"LOW"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;approvalThreshold&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;riskCategory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"MEDIUM"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;                                 &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;riskCategory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"HIGH"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;emit&lt;/span&gt; &lt;span class="n"&gt;AIScoreSubmitted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;riskCategory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;approved&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;/// @notice Read the loan decision for any address
&lt;/span&gt;    &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getDecision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="k"&gt;memory&lt;/span&gt; &lt;span class="n"&gt;risk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;bool&lt;/span&gt;    &lt;span class="n"&gt;approved&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;bool&lt;/span&gt;    &lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;appliedAt&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="k"&gt;memory&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;applications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;applicant&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aiScore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;riskCategory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;approved&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;/// @notice Total number of applicants ever
&lt;/span&gt;    &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getApplicantCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;applicantList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What each function does
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Who Calls It&lt;/th&gt;
&lt;th&gt;What It Does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;applyForLoan()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Any user&lt;/td&gt;
&lt;td&gt;Registers a loan application on-chain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;submitAIScore(address, uint256)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Oracle only&lt;/td&gt;
&lt;td&gt;Submits AI score, triggers approve/reject&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;getDecision(address)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Anyone&lt;/td&gt;
&lt;td&gt;Reads the stored decision for any address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;getApplicantCount()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Anyone&lt;/td&gt;
&lt;td&gt;Returns total number of applicants&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Step 5 — Compile the Contract
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compiled 1 Solidity file successfully (evm target: paris).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 6 — Write the Deploy Script
&lt;/h2&gt;

&lt;p&gt;Delete &lt;code&gt;scripts/deploy.js&lt;/code&gt; and recreate it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// scripts/deploy.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hardhat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;deployer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getSigners&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Deploying AIScoreOracle to XDC Apothem...&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Deployer :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deployer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Oracle   :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deployerBalance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getBalance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deployer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Balance  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;formatEther&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deployerBalance&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TXDC&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Deploy: pass oracle address and approval threshold of 700 out of 1000&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AIScoreOracle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getContractFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AIScoreOracle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;AIScoreOracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;gasLimit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nx"&gt;_000_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// Set manually — XDC estimateGas is unreliable&lt;/span&gt;
    &lt;span class="na"&gt;gasPrice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parseUnits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;12.5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gwei&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// Apothem minimum after XDC 2.0&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;waitForDeployment&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;contractAddress&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getAddress&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deployTx&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deploymentTransaction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Contract deployed!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Address  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;contractAddress&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TX Hash  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deployTx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Explorer :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`https://testnet.xdcscan.com/address/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;contractAddress&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TX Link  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`https://testnet.xdcscan.com/tx/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;deployTx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 7 — Deploy to XDC Apothem
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx hardhat run scripts/deploy.js &lt;span class="nt"&gt;--network&lt;/span&gt; apothem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see output like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Deploying AIScoreOracle to XDC Apothem...

Deployer : 0x2D9305d0c20106beDA3C19d9B8ac8f8AD061b0D5
Oracle   : 0xE65AbC44aa93B25320D9BB9eB6B5cEa3C0a21872
Balance  : 1000.0 TXDC

Contract deployed!
Address  : 0xE031843227668f530DC0E59Bb093ED6763Dcd84D
TX Hash  : 0x7fa75b52a379b20a1c3a4d8966a7c78f1ac29ba69eb25dded01185dcc66c7843
Explorer : https://testnet.xdcscan.com/address/0xE031843227668f530DC0E59Bb093ED6763Dcd84D
TX Link  : https://testnet.xdcscan.com/tx/0x7fa75b52a379b20a1c3a4d8966a7c78f1ac29ba69eb25dded01185dcc66c7843
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the Explorer link — your contract is live on XDC Apothem! 🎉&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 8 — User Applies for a Loan
&lt;/h2&gt;

&lt;p&gt;Write an interaction script. Create &lt;code&gt;scripts/apply.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// scripts/apply.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hardhat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CONTRACT_ADDRESS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR_DEPLOYED_CONTRACT_ADDRESS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;deployer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getSigners&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AIScoreOracle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getContractFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AIScoreOracle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;AIScoreOracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CONTRACT_ADDRESS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Applying for a loan from:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deployer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyForLoan&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;gasLimit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="nx"&gt;_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;gasPrice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parseUnits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;12.5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gwei&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Application submitted!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TX Hash  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TX Link  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`https://testnet.xdcscan.com/tx/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Check pending status&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;risk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;approved&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getDecision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deployer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;On-chain status:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  Risk      :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;risk&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;       &lt;span class="c1"&gt;// PENDING&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  Processed :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// false&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  Score     :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Waiting for AI oracle to score this application...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx hardhat run scripts/apply.js &lt;span class="nt"&gt;--network&lt;/span&gt; apothem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output from our live deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Applying for a loan from: 0x2D9305d0c20106beDA3C19d9B8ac8f8AD061b0D5
Application submitted!
TX Hash  : 0xe95ba3312aa0e710fb45cc6980c271a499570c65d89eb45cadda118719d64387
TX Link  : https://testnet.xdcscan.com/tx/0xe95ba3312aa0e710fb45cc6980c271a499570c65d89eb45cadda118719d64387

On-chain status:
  Risk      : PENDING
  Processed : false
  Score     : 0

Waiting for AI oracle to score this application...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 9 — AI Oracle Submits the Score
&lt;/h2&gt;

&lt;p&gt;Now the oracle wallet submits the AI-generated score. Create &lt;code&gt;scripts/submit_score.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// scripts/submit_score.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hardhat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CONTRACT_ADDRESS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR_DEPLOYED_CONTRACT_ADDRESS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;APPLICANT&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;THE_APPLICANT_WALLET_ADDRESS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AI_SCORE&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;711&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// Replace with your AI model's output (0–1000)&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Use the second signer — the oracle wallet&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[,&lt;/span&gt; &lt;span class="nx"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getSigners&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AIScoreOracle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getContractFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AIScoreOracle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;AIScoreOracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CONTRACT_ADDRESS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Oracle wallet     :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Applicant         :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;APPLICANT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AI Credit Score   :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AI_SCORE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/ 1000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Approval Threshold: 700 / 1000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Decision          :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AI_SCORE&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;700&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;APPROVE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;REJECT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Submitting AI score to blockchain...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;submitAIScore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;APPLICANT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AI_SCORE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;gasLimit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="nx"&gt;_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;gasPrice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;hre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parseUnits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;12.5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gwei&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;AI score committed on-chain!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TX Hash  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TX Link  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`https://testnet.xdcscan.com/tx/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Read final decision&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;risk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;approved&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getDecision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;APPLICANT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Final decision from contract:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  AI Score   :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/ 1000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  Risk Level :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;risk&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  Processed  :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;  Decision   :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;approved&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;APPROVED ✅&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;REJECTED ❌&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx hardhat run scripts/submit_score.js &lt;span class="nt"&gt;--network&lt;/span&gt; apothem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output from our live deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Oracle wallet     : 0xE65AbC44aa93B25320D9BB9eB6B5cEa3C0a21872
Applicant         : 0x2D9305d0c20106beDA3C19d9B8ac8f8AD061b0D5
AI Credit Score   : 711 / 1000
Approval Threshold: 700 / 1000
Decision          : APPROVE

Submitting AI score to blockchain...

AI score committed on-chain!
TX Hash  : 0xcf230923452c8d054435b685ce67f7ad138e4b37e1688e2e8a6852b8af12edf9
TX Link  : https://testnet.xdcscan.com/tx/0xcf230923452c8d054435b685ce67f7ad138e4b37e1688e2e8a6852b8af12edf9

Final decision from contract:
  AI Score   : 711 / 1000
  Risk Level : MEDIUM
  Processed  : true
  Decision   : APPROVED ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 10 — Verify Everything On-Chain
&lt;/h2&gt;

&lt;p&gt;Open the live contract on XDCScan Testnet:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://testnet.xdcscan.com/address/0xE031843227668f530DC0E59Bb093ED6763Dcd84D"&gt;https://testnet.xdcscan.com/address/0xE031843227668f530DC0E59Bb093ED6763Dcd84D&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transactions tab&lt;/strong&gt; — all 3 transactions visible:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;TX Hash&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Gas Used&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x7fa75b52...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Contract deploy&lt;/td&gt;
&lt;td&gt;907,449&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0xe95ba331...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;applyForLoan()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;161,014&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0xcf230923...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;submitAIScore(711)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;83,122&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Events tab&lt;/strong&gt; — two on-chain events emitted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LoanApplied(
  applicant = 0x2D9305d0c20106beDA3C19d9B8ac8f8AD061b0D5,
  timestamp = 1746...
)

AIScoreSubmitted(
  applicant = 0x2D9305d0c20106beDA3C19d9B8ac8f8AD061b0D5,
  score     = 711,
  risk      = "MEDIUM",
  approved  = true
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Read Contract tab&lt;/strong&gt; — call &lt;code&gt;getDecision(0x2D9305d0c20106beDA3C19d9B8ac8f8AD061b0D5)&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;score     → 711
risk      → MEDIUM
approved  → true
processed → true
appliedAt → 1746...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every decision is &lt;strong&gt;permanent, immutable, and publicly verifiable&lt;/strong&gt; — no central authority, no trust required.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 11 — Replace Demo AI with a Real Model
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;submit_score.js&lt;/code&gt; the score is hardcoded as &lt;code&gt;711&lt;/code&gt;. In production, replace that with a real ML model call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python scikit-learn example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ai_model.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;joblib&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;joblib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"credit_model.pkl"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_ai_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applicant_address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;"""
    Fetch applicant data, run the model, return a score 0–1000.
    """&lt;/span&gt;
    &lt;span class="n"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fetch_applicant_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applicant_address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;probability&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict_proba&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;])[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probability&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then expose it as an API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# oracle_api.py  (Flask)
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;ai_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;get_ai_score&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/score"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;score&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="s"&gt;"score"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;get_ai_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And call it from your Hardhat script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In submit_score.js — replace the hardcoded score:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:5000/score&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;APPLICANT&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;score&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AI_SCORE&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything else — the Solidity contract, the Hardhat scripts, the on-chain verification — stays exactly the same.&lt;/p&gt;




&lt;h2&gt;
  
  
  Important XDC Developer Notes
&lt;/h2&gt;

&lt;p&gt;These are lessons learned from our actual deployment:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;th&gt;Root Cause&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;under min gas price&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;XDC 2.0 upgrade raised Apothem minimum&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;12.5 gwei&lt;/code&gt; minimum&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;estimateGas&lt;/code&gt; returns null&lt;/td&gt;
&lt;td&gt;XDC Apothem doesn't support &lt;code&gt;eth_estimateGas&lt;/code&gt; reliably&lt;/td&gt;
&lt;td&gt;Set &lt;code&gt;gasLimit&lt;/code&gt; manually&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EIP-1559 tx rejected&lt;/td&gt;
&lt;td&gt;XDC does not support type-2 transactions&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;gasPrice&lt;/code&gt; not &lt;code&gt;maxFeePerGas&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Full Live Transaction Summary
&lt;/h2&gt;

&lt;p&gt;All transactions verified on &lt;a href="https://testnet.xdcscan.com"&gt;XDCScan Testnet&lt;/a&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;TX Hash&lt;/th&gt;
&lt;th&gt;Link&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Deploy contract&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x7fa75b52...c7843&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/tx/0x7fa75b52a379b20a1c3a4d8966a7c78f1ac29ba69eb25dded01185dcc66c7843"&gt;View ↗&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apply for loan&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0xe95ba331...4387&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/tx/0xe95ba3312aa0e710fb45cc6980c271a499570c65d89eb45cadda118719d64387"&gt;View ↗&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI score (711) submitted&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0xcf230923...edf9&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://testnet.xdcscan.com/tx/0xcf230923452c8d054435b685ce67f7ad138e4b37e1688e2e8a6852b8af12edf9"&gt;View ↗&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;XDC is fully EVM-compatible — Solidity and Hardhat work exactly as on Ethereum&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;oracle pattern&lt;/strong&gt; is the standard way to bridge AI (off-chain) and smart contracts (on-chain)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XDC Apothem gas settings:&lt;/strong&gt; minimum &lt;code&gt;12.5 gwei&lt;/code&gt;, always set &lt;code&gt;gasLimit&lt;/code&gt; manually, avoid EIP-1559&lt;/li&gt;
&lt;li&gt;XDC's near-zero fees make per-user AI-triggered actions economically viable at scale&lt;/li&gt;
&lt;li&gt;Every decision is permanent, immutable, and verifiable on XDCScan Testnet&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;📖 &lt;a href="https://docs.xdc.network"&gt;XDC Network Docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🧪 &lt;a href="https://faucet.apothem.network"&gt;Apothem Faucet&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🔍 &lt;a href="https://testnet.xdcscan.com"&gt;XDCScan Testnet Explorer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📄 &lt;a href="https://testnet.xdcscan.com/address/0xE031843227668f530DC0E59Bb093ED6763Dcd84D"&gt;Live Contract on XDCScan&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💬 &lt;a href="https://xdc.dev"&gt;XDC Developer Forum&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🛠️ &lt;a href="https://github.com/XinFinOrg"&gt;XinFin GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>How to Speed Up XDC Network Node Sync Using Snapshots</title>
      <dc:creator>Rushabh Parmar</dc:creator>
      <pubDate>Tue, 29 Jul 2025 14:01:27 +0000</pubDate>
      <link>https://www.xdc.dev/rushabh_parmar/how-to-speed-up-xdc-network-node-sync-using-snapshots-2237</link>
      <guid>https://www.xdc.dev/rushabh_parmar/how-to-speed-up-xdc-network-node-sync-using-snapshots-2237</guid>
      <description>&lt;p&gt;Running a full node on XDCNetwork is crucial for decentralization, data verification, and direct interaction with the XDC Network. However, syncing a full node from scratch can be a time-consuming and resource-intensive process, potentially taking days or even weeks for archive nodes. This is where snapshots come in as a game-changer, offering a fast and efficient way to get your XDC Network node up and running.&lt;/p&gt;

&lt;p&gt;This article will delve into what snapshots are, why they are essential for syncing, and provide a step-by-step guide on how to download and utilize them to set up a full node or archive node on the XDC Network.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Blockchain Snapshots?
&lt;/h2&gt;

&lt;p&gt;In the context of blockchain, a *&lt;em&gt;snapshot *&lt;/em&gt; is essentially a complete "photograph" of the blockchain's state at a specific block height. This snapshot captures all current account balances, smart contract states, and other relevant data, but crucially, it doesn't include the entire historical transaction data that led to that state. Think of it as having the finished painting without needing to re-watch every brushstroke.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why are Snapshots Crucial for Syncing a Full Node or Archive Node on XDC Network?
&lt;/h2&gt;

&lt;p&gt;The traditional method of syncing a full node or archive node on XDC Network  involves downloading and verifying every single block from the genesis block (the very first block) up to the current one. This process requires significant computational resources and bandwidth. Snapshots offer several key advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Faster Synchronization&lt;/strong&gt;: By downloading a recent snapshot, your node can start from a pre-verified state, drastically reducing the sync time from days or weeks to hours. This allows new participants to join the network quickly and helps existing nodes recover faster from any disruptions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced Resource Consumption&lt;/strong&gt;: Since you're not processing the entire blockchain history, snapshots minimize the CPU, memory, and bandwidth required for initial synchronization, making it more efficient to run nodes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Efficiency and Scalability&lt;/strong&gt;: Faster node participation leads to a more distributed and robust network, contributing to overall network efficiency and scalability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhanced Reliability&lt;/strong&gt;: Snapshots provide a stable and verified starting point, reducing the potential for errors that can occur during a full blockchain download.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Essentially, snapshots provide a "shortcut" for nodes to quickly acquire the latest XDC Network state, enabling them to catch up and participate in the network much faster and with fewer resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up a Full Node on XDC Network with Snapshots: A Step-by-Step Guide
&lt;/h2&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A server or cloud instance (minimum 16 GB RAM, 1.5 TB storage)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ubuntuoperating system&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Basic Linux command-line knowledge&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Setting up the Node Environment using Bootstrap&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Its the primary options for setting up your XDC Network node environment: using the bootstrap.sh script for a quick setup&lt;/p&gt;

&lt;p&gt;Using the Bootstrap Command for Quick Setup&lt;br&gt;
This command automates the installation of necessary dependencies and sets up the basic node environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su -c "bash &amp;lt;(wget -qO- https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/master/setup/bootstrap.sh)" root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be prompted to enter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;XinFin Network (mainnet/testnet/devnet)&lt;/strong&gt;: Type mainnet for the main XDC Network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;XinFin MasterNode Name&lt;/strong&gt;: Provide a name for your node (e.g.,Rushabh-Snapshot-Node).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate new private key and wallet address. If you have your own key, you can change after this and restart the node&lt;/strong&gt;: Enter y or Y and continue &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/mMRbzGPvP4DbnteFr_1RMzlyP6qRaZwsk8GVce_bHlk/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L25nOGtqNjhrampn/Ymh3d3YydzQ5LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/mMRbzGPvP4DbnteFr_1RMzlyP6qRaZwsk8GVce_bHlk/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L25nOGtqNjhrampn/Ymh3d3YydzQ5LnBu/Zw" alt="Image description" width="880" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the installation on your Ubuntu server is complete, attach to the node using the following command to verify that the blockchain synchronization has begun&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash xdc-attach.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.xdc.dev/images/ASB5XVojPG50JFw6o0fajMHsqVlOFF7CI8Ofn3U7Paw/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzE4bWNkYnZ5YTk3/ZTd2azE1aWVxLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/ASB5XVojPG50JFw6o0fajMHsqVlOFF7CI8Ofn3U7Paw/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzE4bWNkYnZ5YTk3/ZTd2azE1aWVxLnBu/Zw" alt="Image description" width="880" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can monitor the status of your node using the above command or by visiting the official stats page at &lt;a href="https://xinfin.network/#stats"&gt;https://xinfin.network/#stats&lt;/a&gt; Once you've confirmed that the node has begun syncing from the genesis block, stop the node by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash docker-down.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.xdc.dev/images/3w0S9ULc-NF0q4ysF9SCXQfBSvgNAwVdQd7NVEcF19I/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2ZxZm1uOG5zemtr/eHFkb2w1ZWZjLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/3w0S9ULc-NF0q4ysF9SCXQfBSvgNAwVdQd7NVEcF19I/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2ZxZm1uOG5zemtr/eHFkb2w1ZWZjLnBu/Zw" alt="Image description" width="880" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After stopping your node, proceed to delete the existing XDC directory to prepare for the snapshot data&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/Do4YjmY19mDUrFz4D8QJRDPruCE0uX0pEloMg09cSJ4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3hiZjIzdjBoZHBk/cnBxenI4ZjVqLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/Do4YjmY19mDUrFz4D8QJRDPruCE0uX0pEloMg09cSJ4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3hiZjIzdjBoZHBk/cnBxenI4ZjVqLnBu/Zw" alt="Image description" width="880" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After deleting the XDC folder, you can now proceed to download and apply the latest snapshot.&lt;/p&gt;

&lt;p&gt;To download the XDC Network Mainnet snapshot, use the appropriate command based on the type of node you’re setting up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For a Full Node (latest state only)&lt;/strong&gt;: &lt;a href="https://download.xinfin.network/xdcchain.tar"&gt;https://download.xinfin.network/xdcchain.tar&lt;/a&gt;   &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For an Archive Node (complete history)&lt;/strong&gt;: &lt;a href="http://downloads.xinfin.network/xdcchain_archive.tar"&gt;http://downloads.xinfin.network/xdcchain_archive.tar&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note: Snapshots are updated approximately every 20 days.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/u_5Z7KYowD-lGrVsdJgElErwygOCnA53ny4tyCupzWk/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzFxNHU2ZWd5YTNy/bjNldWFlZDBkLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/u_5Z7KYowD-lGrVsdJgElErwygOCnA53ny4tyCupzWk/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzFxNHU2ZWd5YTNy/bjNldWFlZDBkLnBu/Zw" alt="Image description" width="880" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the xdc.tar file has been downloaded, extract the snapshot by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tar -xvzf xdc.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will unpack the archive and create the XDC directory containing the necessary blockchain data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/pKgzt7SIrjhfOT6-8it5tHwKu-ATaJRhUSzaSh9nLRk/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2ozajZlZzYyZjY2/dGRyZ3owOTBpLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/pKgzt7SIrjhfOT6-8it5tHwKu-ATaJRhUSzaSh9nLRk/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2ozajZlZzYyZjY2/dGRyZ3owOTBpLnBu/Zw" alt="Image description" width="880" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the XDC folder has been extracted, navigate into it and perform the following cleanup steps:&lt;/p&gt;

&lt;p&gt;Delete the nodekey file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf nodekey
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete the transactions.rlp file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf transactions.rlp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.xdc.dev/images/Kx8tttKV--LXLAlVRYMaGw0fobbygqYFJmCNDMcOsqo/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzcxbmwzNmY5MnN0/a2tieXE2MDd0LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/Kx8tttKV--LXLAlVRYMaGw0fobbygqYFJmCNDMcOsqo/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzcxbmwzNmY5MnN0/a2tieXE2MDd0LnBu/Zw" alt="Image description" width="880" height="113"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After removing these files, return to the mainnet directory and open the .env file.&lt;br&gt;
In the configuration, locate the ENABLE_RPC variable and set it to true to enable RPC access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENABLE_RPC=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.xdc.dev/images/ueWTmM_llC2yOidOBi8z2Vjf8yV26VQUzxcgbdJN-Ro/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3V4Z2wxeWQwdzFw/NnFhMXN3Mm83LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/ueWTmM_llC2yOidOBi8z2Vjf8yV26VQUzxcgbdJN-Ro/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3V4Z2wxeWQwdzFw/NnFhMXN3Mm83LnBu/Zw" alt="Image description" width="880" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the .env file, you’ll find the ENABLE_RPC parameter set to false by default. Update it to enable RPC access by changing it to: &lt;strong&gt;ENABLE_RPC=true&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are setting up a full node, you can now start your node without any additional changes.&lt;/p&gt;

&lt;p&gt;However, if you are configuring an archive node, you must modify the start-node.sh script by adding the following flag: --&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcmode=archive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note: This flag is only required for archive nodes to retain full blockchain history.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you've made the necessary changes, start your node with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash docker-up.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.xdc.dev/images/Alv_W5XlRQT2hQNZXWpk7mLszsFAlR4TS8kGygRh6M4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3Nwd2xxcHk0Y3R4/d2ltajRkM2Z0LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/Alv_W5XlRQT2hQNZXWpk7mLszsFAlR4TS8kGygRh6M4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3Nwd2xxcHk0Y3R4/d2ltajRkM2Z0LnBu/Zw" alt="Image description" width="880" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can monitor your node’s status by attaching to the console using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash xdc-attach.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can view real-time sync progress and network activity on the official stats page:&lt;a href="https://xinfin.network/#stats"&gt;https://xinfin.network/#stats&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/BpPTWzbYbcf819CuQ0Svi01j_b8EtWaC799MyoicMe4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzdreHhkNXRjb2k4/Zmo5ODRmMDFoLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/BpPTWzbYbcf819CuQ0Svi01j_b8EtWaC799MyoicMe4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzdreHhkNXRjb2k4/Zmo5ODRmMDFoLnBu/Zw" alt="Image description" width="880" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your node is not connecting to peers or you're experiencing issues with peer discovery, run the following command to manually connect to the network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash peer.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will help your node establish connections with other active nodes on the XDC Network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/htrcXef8jGy3AGB8_rcGG_gIWrKuMOEAn572LyaW65w/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2x3cDczdjhtMG53/OTRlNDZ5cm83LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/htrcXef8jGy3AGB8_rcGG_gIWrKuMOEAn572LyaW65w/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2x3cDczdjhtMG53/OTRlNDZ5cm83LnBu/Zw" alt="Image description" width="880" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After executing the command, your node will begin establishing connections with peers on the XDC Network, allowing it to sync and participate in the network more effectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/YUFLrejMrvWu7uA9z0sl1rLCOpz3KXdJMbvFcB7RNnE/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2xxOHprZHg5aDQy/b2M0aG5mMXlsLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/YUFLrejMrvWu7uA9z0sl1rLCOpz3KXdJMbvFcB7RNnE/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2xxOHprZHg5aDQy/b2M0aG5mMXlsLnBu/Zw" alt="Image description" width="880" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessing the RPC Endpoint:&lt;/strong&gt; Once your node is fully synced, you can use its dedicated RPC endpoint.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The RPC port used is 8989&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The WebSocket port used is 8888&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've configured your server's firewall to allow external access to these ports (which is necessary for dApps to connect from outside your server), you would replace localhost with your server's public IP address or domain name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting up a dedicated RPC node on the XDC Network, especially for DApps requiring high performance and reliability, is greatly simplified by leveraging snapshots. By following this comprehensive guide, you can efficiently set up and synchronize your XDC full node, providing a robust and responsive gateway for your decentralized applications to interact with the XDC blockchain. Snapshots are an invaluable tool for maintaining a healthy and efficient decentralized ecosystem, ensuring seamless communication and robust data management for developers and network operators alike.&lt;/p&gt;

</description>
      <category>xdc</category>
      <category>snapshots</category>
      <category>rpc</category>
      <category>node</category>
    </item>
    <item>
      <title>Securely Broadcast Offline-Signed Crypto Transactions Across XDC, Ethereum, Bitcoin, Solana &amp; XRP</title>
      <dc:creator>Rushabh Parmar</dc:creator>
      <pubDate>Fri, 23 May 2025 07:37:51 +0000</pubDate>
      <link>https://www.xdc.dev/rushabh_parmar/securely-broadcast-offline-signed-crypto-transactions-across-xdc-ethereum-bitcoin-solana-xrp-27do</link>
      <guid>https://www.xdc.dev/rushabh_parmar/securely-broadcast-offline-signed-crypto-transactions-across-xdc-ethereum-bitcoin-solana-xrp-27do</guid>
      <description>&lt;p&gt;In the evolving landscape of cryptocurrency, ensuring the security of transactions is paramount. Broadcasting raw, offline-signed transactions stands out as a robust method to safeguard private keys while maintaining transaction efficiency. The XDC Network's Raw Transaction Broadcast Tool offers a streamlined, non-custodial solution to propagate these transactions across multiple blockchains, including XDC, Ethereum, Bitcoin, Solana, and XRP.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔐 Understanding Raw Offline Transactions
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;raw transaction&lt;/strong&gt; is a serialized data structure, often in hexadecimal format, encompassing all necessary transaction details—sender, recipient, amount, fees, and signatures—ready for network broadcast. When these transactions are signed in an offline environment, they become &lt;strong&gt;offline transactions&lt;/strong&gt;, ensuring that private keys remain isolated from internet-connected devices. This approach enhances security by mitigating exposure to potential online threats.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛡️ Benefits of Offline Signing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Security&lt;/strong&gt;: Private keys never touch online systems, reducing vulnerability to hacks and malware.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Privacy&lt;/strong&gt;: Offline signing keeps sensitive data away from internet exposure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hardware Wallet Compatibility&lt;/strong&gt;: Seamlessly integrates with devices like Ledger, Trezor, and D'CENT for secure transaction signing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cold Storage Integration&lt;/strong&gt;: Facilitates transactions from air-gapped systems without compromising key safety.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🌐 Introducing the XDC Raw Transaction Broadcast Tool
&lt;/h2&gt;

&lt;p&gt;Accessible at &lt;a href="https://broadcast.xinfin.network/build/raw-tx"&gt;https://broadcast.xinfin.network/build/raw-tx&lt;/a&gt;, this web-based utility empowers users to broadcast raw, signed transactions across multiple blockchain networks. Key features include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Chain Support&lt;/strong&gt;: Compatible with XDC, Ethereum, Bitcoin, Solana, and XRP networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transaction Decoding&lt;/strong&gt;: Automatically parses and displays transaction details for verification before broadcasting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;QR Code Functionality&lt;/strong&gt;: Enables scanning of transaction data from offline devices, facilitating secure and error-free broadcasting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-Custodial Design&lt;/strong&gt;: Does not require private keys or wallet access, ensuring user control over funds.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🧭 Step-by-Step Guide to Broadcasting Transactions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prepare Your Signed Transaction Offline&lt;/strong&gt;: Utilize your preferred wallet or tool to create and sign the transaction in an offline environment, generating a raw transaction hex string.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Access the Broadcast Tool&lt;/strong&gt;: Navigate to &lt;a href="https://broadcast.xinfin.network/build/raw-tx"&gt;https://broadcast.xinfin.network/build/raw-tx&lt;/a&gt; on an internet-connected device.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Select the Appropriate Network&lt;/strong&gt;: Choose the blockchain network corresponding to your transaction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Input the Raw Transaction&lt;/strong&gt;: Paste the signed transaction hex into the provided field or scan the QR code if available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verify Transaction Details&lt;/strong&gt;: Review the decoded information to ensure accuracy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Broadcast the Transaction&lt;/strong&gt;: Click the "Publish" button to send the transaction to the selected network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Confirm Submission&lt;/strong&gt;: Upon successful broadcast, the tool will display the transaction hash for tracking purposes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  📸 Leveraging QR Code Functionality
&lt;/h2&gt;

&lt;p&gt;The tool's QR code feature enhances the offline-to-online workflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scanning&lt;/strong&gt;: Easily import signed transactions from offline devices by scanning QR codes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sharing&lt;/strong&gt;: Generate QR codes for transactions to facilitate secure sharing and storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔒 Security and Non-Custodial Design Emphasis
&lt;/h2&gt;

&lt;p&gt;Security is paramount when handling cryptocurrency transactions, and the XDC broadcast tool is built with that in mind. It is a non-custodial tool, meaning it never takes control of your assets or keys at any point. You do not create accounts or input private keys; you only input signed transactions, which by design cannot be used to derive your private key or alter your balance except as intended. This ensures that you retain full custody of your cryptographic keys and coins at all times.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Conclusion &amp;amp; Call to Action
&lt;/h2&gt;

&lt;p&gt;Broadcasting raw offline transactions is a smart strategy for anyone serious about crypto security. The XDC Network's multi-chain broadcast tool makes this process accessible and convenient, whether you're sending an XDC transaction broadcast from a cold wallet, pushing an Ethereum raw transaction from a safe offline signer, or handling Bitcoin, Solana, or XRP transfers. By incorporating offline signing and this broadcast utility into your workflow, you gain peace of mind that your keys are safe while still enjoying the flexibility to transact on major blockchains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Call to Action&lt;/strong&gt;: Ready to enhance your crypto transaction security? Start using the raw transaction broadcast tool today. Head over to &lt;a href="https://broadcast.xinfin.network/build/raw-tx"&gt;https://broadcast.xinfin.network/build/raw-tx&lt;/a&gt; and give it a try with a small test transaction. Experience how straightforward it is to broadcast raw crypto transactions offline. By adopting this tool, you're taking control of your crypto in the most secure way possible. Developers and power users alike are encouraged to incorporate offline signing and broadcasting into their workflow—let's make the crypto ecosystem safer, one offline-signed transaction at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;Cryptocurrency transactions involve significant risks, including but not limited to market volatility, technological failures, and regulatory changes. Users are strongly advised to conduct their own research and consult with qualified professionals before engaging in any cryptocurrency activities.&lt;/p&gt;

</description>
      <category>xdc</category>
      <category>broadcast</category>
      <category>offline</category>
      <category>wallets</category>
    </item>
    <item>
      <title>XDC Safe Transaction Builder: Streamlining Multisig Transactions</title>
      <dc:creator>Rushabh Parmar</dc:creator>
      <pubDate>Tue, 11 Feb 2025 11:51:55 +0000</pubDate>
      <link>https://www.xdc.dev/rushabh_parmar/xdc-safe-transaction-builder-streamlining-multisig-transactions-44b8</link>
      <guid>https://www.xdc.dev/rushabh_parmar/xdc-safe-transaction-builder-streamlining-multisig-transactions-44b8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;XDC Safe is a multisig wallet built for the XDC Network, designed to enhance security and streamline transactions for teams and organizations. In our latest update, we have introduced the Transaction Builder, a powerful tool that allows users to batch multiple transactions into a single confirmation process. This makes interacting with smart contracts and performing complex operations significantly more efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the Transaction Builder?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Transaction Builder in XDC Safe enables users to create and execute multiple transactions in a single batch, reducing manual confirmations and improving efficiency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Batch Transactions:&lt;/strong&gt; Group multiple actions (such as token transfers, approvals, and contract calls) into one transaction, reducing execution steps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User-Friendly Interface:&lt;/strong&gt; A visual interface allows users to easily add, edit, and review transactions before execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart-Contract Interactions:&lt;/strong&gt; Interact with any verified smart contract directly from XDC Safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simulation Capabilities:&lt;/strong&gt; Users can simulate transactions to preview the expected outcome and gas fees before execution.&lt;/li&gt;
&lt;li&gt;**Security &amp;amp; Efficiency: **Reduces the number of on-chain interactions, enhancing security and optimizing transaction costs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why We Added the Transaction Builder to XDC Safe&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;XDC Safe was developed to provide seamless multisig functionality for XDC users, ensuring secure and efficient management of assets and contract interactions. The Transaction Builder further enhances this experience by allowing users to interact with smart contracts in a more streamlined way, eliminating the need to confirm each transaction separately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Use the XDC Safe Transaction Builder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Access the Transaction Builder&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the New Transaction section in XDC Safe and select Transaction Builder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/gBLzR1UPXWTvXAA_b-UoXjex7cm1xCzHxrkXY2AtvnU/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/Lzg0dGdncWRqNHFt/NnA3cWZ5YTB0LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/gBLzR1UPXWTvXAA_b-UoXjex7cm1xCzHxrkXY2AtvnU/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/Lzg0dGdncWRqNHFt/NnA3cWZ5YTB0LnBu/Zw" alt="Image description" width="880" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Select a Smart Contract&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enter the XDC address of the smart contract you want to interact with.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Specify the ABI&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For contracts verified on XDCScan  Explorer, the ABI will be automatically fetched.&lt;/li&gt;
&lt;li&gt;If not, manually enter the ABI in the provided input field.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Select a Method&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose the method you wish to execute from the available contract functions.&lt;/li&gt;
&lt;li&gt;XDC Safe supports both read and write functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/Bx2iICAfyNtYTZt002cJQaQvO23hQmbU_ImjQXDiU3c/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3dsOTd6MTVxMzBw/c2RvdzdrNzd4LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/Bx2iICAfyNtYTZt002cJQaQvO23hQmbU_ImjQXDiU3c/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3dsOTd6MTVxMzBw/c2RvdzdrNzd4LnBu/Zw" alt="Image description" width="592" height="769"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Define Parameters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The interface will display the parameters for the selected method.&lt;/li&gt;
&lt;li&gt;If necessary, enter values such as token amounts or recipient addresses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Add to Batch&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click Add Transaction to include it in the batch.&lt;/li&gt;
&lt;li&gt;You can continue adding multiple transactions before executing them all at once.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/E7wSPyNQxMIqzY1EGbBgsHGF51C5DrsnZrtC3ZbxwPc/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3lmOWhhbnJxbDZj/dHd3Y3BoOGY4LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/E7wSPyNQxMIqzY1EGbBgsHGF51C5DrsnZrtC3ZbxwPc/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3lmOWhhbnJxbDZj/dHd3Y3BoOGY4LnBu/Zw" alt="Image description" width="880" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Review and Execute&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before submission, review the batched transactions.&lt;/li&gt;
&lt;li&gt;You can also bookmark, download, or share the transaction batch with other signers for approval.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/kbVCtIzpav_pEiPWQg-nnFQBH-TIIH_gP7v0-ujEa68/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3EybnUwZHVscjZo/aG9zc3N6emc2LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/kbVCtIzpav_pEiPWQg-nnFQBH-TIIH_gP7v0-ujEa68/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3EybnUwZHVscjZo/aG9zc3N6emc2LnBu/Zw" alt="Image description" width="880" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Confirm and Sign&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once reviewed, confirm the transaction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/upzSmupO5yd3oKG0MSnmzOVcLnVvVpFGaCepDFstTvw/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3kwMHA5emhrbWh6/eDhyZzduc2tyLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/upzSmupO5yd3oKG0MSnmzOVcLnVvVpFGaCepDFstTvw/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3kwMHA5emhrbWh6/eDhyZzduc2tyLnBu/Zw" alt="Image description" width="880" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Depending on your multisig setup, other signers will need to approve before execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/vo_7Z1S9XiJ48WTJHekdjiLb7OwVSgNTSLp3xw2kqEw/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzgweHpsNzlxMmQx/YXNqM2FyOWVmLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/vo_7Z1S9XiJ48WTJHekdjiLb7OwVSgNTSLp3xw2kqEw/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzgweHpsNzlxMmQx/YXNqM2FyOWVmLnBu/Zw" alt="Image description" width="880" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Using the XDC Safe Transaction Builder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Efficiency:&lt;/strong&gt; Reduce the number of confirmations needed for multiple transactions.&lt;br&gt;
✅ &lt;strong&gt;Security:&lt;/strong&gt; Minimizes the number of interactions, lowering potential attack surfaces.&lt;br&gt;
✅ &lt;strong&gt;Cost-Effective:&lt;/strong&gt; Reduces overall gas fees by bundling transactions.&lt;br&gt;
✅ &lt;strong&gt;Seamless Collaboration:&lt;/strong&gt; Share and execute transaction batches easily with multiple signers.&lt;/p&gt;

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

&lt;p&gt;With the addition of the Transaction Builder, XDC Safe has become even more powerful, allowing users to interact with smart contracts efficiently and securely. This update ensures that teams and organizations managing funds and contracts on the XDC Network can streamline their processes while maintaining top-tier security.&lt;/p&gt;

&lt;p&gt;💡 For any questions regarding XDC Safe or the XDC Network, feel free to engage with the community at &lt;a href="https://xdc.dev"&gt;XDC.dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Start using the XDC Safe Transaction Builder today: &lt;a href="https://xdcsafe.xdcobserver.io/welcome"&gt;XDC Safe&lt;/a&gt; 🚀 &lt;/p&gt;

&lt;p&gt;While XDC Safe offers a robust multisig experience, users exploring multisig solutions on the XDC Network can also try other wallets like &lt;a href="https://app.oryy.io/welcome"&gt;Orry&lt;/a&gt; and &lt;a href="https://yplusvault.com/welcome"&gt;Yodaplus Vault&lt;/a&gt;. Both platforms provide secure, multi-signature wallet management tailored for teams, allowing users to safeguard assets, co-sign transactions, and maintain control in a decentralized manner. Exploring these alternatives can help users choose the best fit for their specific workflow and governance needs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The information provided in this article is for educational and informational purposes only. It does not constitute financial, investment, or legal advice. Users are encouraged to conduct their own research and exercise caution when interacting with smart contracts and multisig wallets. While we strive to keep content accurate and up to date, we do not guarantee the security, functionality, or availability of any third-party tools or platforms mentioned, including XDC Safe, Orry, and Yodaplus Vault. Use at your own risk.&lt;/p&gt;

</description>
      <category>xdc</category>
      <category>safe</category>
      <category>transaction</category>
      <category>multisignaturewallet</category>
    </item>
    <item>
      <title>Update: XDC Apothem Network Experiences Surge in Traffic: Public RPC Update</title>
      <dc:creator>Rushabh Parmar</dc:creator>
      <pubDate>Thu, 05 Sep 2024 16:12:03 +0000</pubDate>
      <link>https://www.xdc.dev/rushabh_parmar/update-xdc-apothem-network-experiences-surge-in-traffic-public-rpc-update-5cpe</link>
      <guid>https://www.xdc.dev/rushabh_parmar/update-xdc-apothem-network-experiences-surge-in-traffic-public-rpc-update-5cpe</guid>
      <description>&lt;p&gt;On 4th September, the XDC Apothem Network’s public RPC (&lt;a href="https://erpc.apothem.network"&gt;https://erpc.apothem.network&lt;/a&gt;) experienced temporary downtime due to increased traffic. Over 24 hours, the public RPC saw 17.15 million hits, which made the service unavailable for some users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.xdc.dev/images/n7Lz2yph1Rf60loo_BvYVjscAIw3akbGPhtwbOG901w/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2dmbWFpNXhud2Qy/YnN3bGV6bWx3Lmpw/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/n7Lz2yph1Rf60loo_BvYVjscAIw3akbGPhtwbOG901w/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2dmbWFpNXhud2Qy/YnN3bGV6bWx3Lmpw/Zw" alt="Image description" width="880" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In response, the DevOps team quickly addressed the issue. They started by adding a node balancer and deploying multiple additional nodes across all public RPC endpoints. This step aims to distribute traffic more evenly and avoid similar problems in the future.&lt;br&gt;
A rate limit has been applied to the public RPC to protect the network from DDoS attacks further. If users encounter a rate limit when connecting, it is recommended that they set up a dedicated RPC for a more stable and reliable connection. For details on setting up a dedicated RPC, refer to the guide here: &lt;a href="https://www.xdc.dev/ruslan_wing/setting-up-an-rpc-node-server-for-your-dapp-on-xdc-network-a-comprehensive-guide-3dm9"&gt;https://www.xdc.dev/ruslan_wing/setting-up-an-rpc-node-server-for-your-dapp-on-xdc-network-a-comprehensive-guide-3dm9&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;For Non-Technical Users:&lt;br&gt;
If you’re a non-technical user, you can also get a paid dedicated RPC (for Mainnet or Apothem Network) from third-party providers like &lt;a href="https://www.ankr.com/rpc/xdc/"&gt;Ankr&lt;/a&gt;, &lt;a href="https://www.indsoft.net/blockchain-nodes.html"&gt;Indsoft&lt;/a&gt;, &lt;a href="https://xdcrpc.com/"&gt;Blocksscan&lt;/a&gt;, &lt;a href="https://nownodes.io/nodes"&gt;NowNodes&lt;/a&gt;, &lt;a href="https://tatum.io/nodes"&gt;Tatum&lt;/a&gt;, or &lt;a href="https://www.asternodes.io/get-access"&gt;Asternodes&lt;/a&gt;. These providers offer reliable services without the need to set it up yourself.&lt;br&gt;
These steps should help prevent future downtime and improve the overall stability of the public RPC.&lt;/p&gt;

</description>
      <category>xdc</category>
      <category>rpc</category>
      <category>node</category>
      <category>apothem</category>
    </item>
  </channel>
</rss>
