<?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: JukLee0ira</title>
    <description>The latest articles on Developers Forum for XinFin XDC Network by JukLee0ira (@juklee0ira).</description>
    <link>https://www.xdc.dev/juklee0ira</link>
    <image>
      <url>https://www.xdc.dev/images/Y-C-c492jVWy2-bCAUkZEtRrj2zHpdnMzUqSn5wLL2w/rs:fill:90:90/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL3VzZXIvcHJv/ZmlsZV9pbWFnZS8z/MTAzL2JlMWEwODA1/LTIxMzItNDY1OC1i/MjhkLWVhOTc5MmI2/NWE2Yy5qcGVn</url>
      <title>Developers Forum for XinFin XDC Network: JukLee0ira</title>
      <link>https://www.xdc.dev/juklee0ira</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://www.xdc.dev/feed/juklee0ira"/>
    <language>en</language>
    <item>
      <title>How to Setup monitor tool</title>
      <dc:creator>JukLee0ira</dc:creator>
      <pubDate>Thu, 20 Mar 2025 03:50:32 +0000</pubDate>
      <link>https://www.xdc.dev/juklee0ira/how-to-setup-monitor-tool-2g2n</link>
      <guid>https://www.xdc.dev/juklee0ira/how-to-setup-monitor-tool-2g2n</guid>
      <description>&lt;p&gt;This monitoring tool provides a visual display of various performance metrics for node runtime, helping you understand node performance, debug, tune, and gain insight into actual Node runtime.&lt;br&gt;
&lt;a href="https://www.xdc.dev/images/RX3P0KnchJ82gD9xIcNjn5tRP8XFCS9sgoQd-Go8wx4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3NnMzA5OTc0NTh4/ODV6MHJwcGE2LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/RX3P0KnchJ82gD9xIcNjn5tRP8XFCS9sgoQd-Go8wx4/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L3NnMzA5OTc0NTh4/ODV6MHJwcGE2LnBu/Zw" alt="Image description" width="880" height="478"&gt;&lt;/a&gt;&lt;br&gt;
Here's how to deploy the monitoring tool:&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing InfluxDB 1.8 and Grafana on Linux System
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Update the System
&lt;/h3&gt;

&lt;p&gt;Before starting the installation, first update the package manager of the system:&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;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Download and Install InfluxDB 1.8
&lt;/h3&gt;

&lt;p&gt;Go to the InfluxData official repository and download the suitable version of InfluxDB 1.8 for your system. For Debian/Ubuntu systems, you can use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://dl.influxdata.com/influxdb/releases/influxdb_1.8.10_amd64.deb
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; influxdb_1.8.10_amd64.deb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Start InfluxDB
&lt;/h4&gt;

&lt;p&gt;Start the InfluxDB service and set it to start on boot:&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;sudo &lt;/span&gt;systemctl start influxdb
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;influxdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Check Service Status
&lt;/h4&gt;

&lt;p&gt;You can check the status of the InfluxDB service with the following command:&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;sudo &lt;/span&gt;systemctl status influxdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see &lt;code&gt;active (running)&lt;/code&gt;, it means the service is working fine.&lt;/p&gt;

&lt;p&gt;After saving, restart the service:&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;sudo &lt;/span&gt;systemctl restart influxdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and confirm that InfluxDB is listening on the port:&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;sudo &lt;/span&gt;lsof &lt;span class="nt"&gt;-i&lt;/span&gt; :8086
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create User and Database
&lt;/h4&gt;

&lt;p&gt;You can use the following commands to create a user（&lt;code&gt;user01&lt;/code&gt;，with password &lt;code&gt;12345678&lt;/code&gt;）,it will serve for high level management, creating databases and users.Then enter the influxdb command line interface to create a database（&lt;code&gt;xdc&lt;/code&gt;）and a user（&lt;code&gt;xdc&lt;/code&gt;）with password &lt;code&gt;xdc&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;curl &lt;span class="nt"&gt;-XPOST&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:8086/query"&lt;/span&gt; &lt;span class="nt"&gt;--data-urlencode&lt;/span&gt; &lt;span class="s2"&gt;"q=CREATE USER user01 WITH PASSWORD '12345678' WITH ALL PRIVILEGES"&lt;/span&gt;
influx &lt;span class="nt"&gt;-username&lt;/span&gt; &lt;span class="s1"&gt;'user01'&lt;/span&gt; &lt;span class="nt"&gt;-password&lt;/span&gt; &lt;span class="s1"&gt;'12345678'&lt;/span&gt;
create database xdc
CREATE USER xdc WITH PASSWORD &lt;span class="s1"&gt;'xdc'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the following commands to verify the created entries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;show databases
show &lt;span class="nb"&gt;users&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h3&gt;
  
  
  3. Prepare Node
&lt;/h3&gt;

&lt;p&gt;Download and configure xdpos, ensuring the folder settings are correct. Modify the startup script to add the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    --metrics \
    --metrics-influxdb \
    --metrics-influxdb.database "xdc" \
    --metrics-influxdb.username "xdc" \
    --metrics-influxdb.password "xdc" \
    --metrics-influxdb.endpoint "http://localhost:8086" \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;start the node and check if the data is being pushed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;influx &lt;span class="nt"&gt;-username&lt;/span&gt; &lt;span class="s1"&gt;'user01'&lt;/span&gt; &lt;span class="nt"&gt;-password&lt;/span&gt; &lt;span class="s1"&gt;'12345678'&lt;/span&gt;
use xdc
show measurements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Firewall Settings
&lt;/h4&gt;

&lt;p&gt;If the firewall blocks access to port 8086, run the following command to check the status:&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;sudo &lt;/span&gt;ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the firewall is on and port 8086 is not allowed, run the following commands to open the port:&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;sudo &lt;/span&gt;ufw allow 8086
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw reload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Set Up Grafana
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-tlsv1&lt;/span&gt;.3 &lt;span class="nt"&gt;--proto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;https &lt;span class="nt"&gt;-sL&lt;/span&gt; https://packages.grafana.com/gpg.key | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"deb https://packages.grafana.com/oss/deb stable main"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/apt/sources.list.d/grafana.list
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;grafana &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;grafana-server
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start grafana-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Check Grafana Status
&lt;/h4&gt;

&lt;p&gt;Confirm if the Grafana service is running properly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof &lt;span class="nt"&gt;-i&lt;/span&gt; :3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Access the Grafana interface in your browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:3000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Configure InfluxDB Data Source
&lt;/h4&gt;

&lt;p&gt;In Grafana, click on the "Data Sources" icon and select "InfluxDB". It is recommended to use the following configuration options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: InfluxDB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query Language&lt;/strong&gt;: InfluxQL&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTP&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL&lt;/strong&gt;: &lt;a href="http://localhost:8086"&gt;http://localhost:8086&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access&lt;/strong&gt;: Server (default)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Whitelisted cookies&lt;/strong&gt;: None (leave blank)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auth&lt;/strong&gt;: All options left as their default&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;InfluxDB Details&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Database&lt;/strong&gt;: &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User&lt;/strong&gt;: &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password&lt;/strong&gt;: &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTP Method&lt;/strong&gt;: GET&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Click on "Save and test" and wait for the confirmation to pop up,then you can follow the instruction to create a dashboard ,add panels and configure the dashboard.here is a often used &lt;a href="https://grafana.com/grafana/dashboards/18463-go-ethereum-by-instance/"&gt;example dashboard&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://www.xdc.dev/images/V97di54uf0bAsTV6rMKswycXmKDeZdAka390kjFnxiE/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzkycGhkbnBidTc5/aGIwbHVoaTZ1LnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/V97di54uf0bAsTV6rMKswycXmKDeZdAka390kjFnxiE/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/LzkycGhkbnBidTc5/aGIwbHVoaTZ1LnBu/Zw" alt="Image description" width="880" height="522"&gt;&lt;/a&gt;&lt;br&gt;
you can also create your own panel and dashboard to meet your needs,and adjust the parameters on &lt;code&gt;Inspect&lt;/code&gt;&amp;gt;&lt;code&gt;Penal JSON&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://www.xdc.dev/images/fj5OPOfPo1OVXKgFKxFoOl8Gifez6aEC55zWqckwHyE/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2pjMzByd2d0M21l/ZnVpMnQ2ZjhpLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/fj5OPOfPo1OVXKgFKxFoOl8Gifez6aEC55zWqckwHyE/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2pjMzByd2d0M21l/ZnVpMnQ2ZjhpLnBu/Zw" alt="Image description" width="880" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Configuring Multiple Data Sources
&lt;/h4&gt;

&lt;p&gt;If you want to monitor the performance of multiple nodes at the same time, you can use the same steps to push data to the monitoring system. This means different nodes or services can send their performance metrics independently, allowing for centralized monitoring and data analysis. See the image below:&lt;br&gt;
&lt;a href="https://www.xdc.dev/images/5-2vouyEAEAxnLnWwP1rW-zEpsDN7JAXacBbd8Ve8RU/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2JtemR4bHRvZWRz/aGFlNHJxYWluLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/5-2vouyEAEAxnLnWwP1rW-zEpsDN7JAXacBbd8Ve8RU/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2JtemR4bHRvZWRz/aGFlNHJxYWluLnBu/Zw" alt="Image description" width="880" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you need to set up multiple data sources to view in the same dashboard, you can create a new variable in the dashboard to query the corresponding data.&lt;br&gt;
&lt;a href="https://www.xdc.dev/images/2KKW7X0DtcAaDGFTQWY98-LpCl3SrnEQKTyT197-O2g/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2h5cDFkZjFkdzkz/NWNveXZyb2lhLnBu/Zw" class="article-body-image-wrapper"&gt;&lt;img src="https://www.xdc.dev/images/2KKW7X0DtcAaDGFTQWY98-LpCl3SrnEQKTyT197-O2g/w:880/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL2FydGljbGVz/L2h5cDFkZjFkdzkz/NWNveXZyb2lhLnBu/Zw" alt="Image description" width="880" height="367"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;To learn more about how dashboards work, refer to &lt;a href="https://grafana.com/docs/grafana/latest/dashboards/"&gt;Grafana's documentation&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using a Tracer to Locate Contracts </title>
      <dc:creator>JukLee0ira</dc:creator>
      <pubDate>Tue, 17 Dec 2024 09:41:27 +0000</pubDate>
      <link>https://www.xdc.dev/juklee0ira/using-a-tracer-to-locate-contracts-j3a</link>
      <guid>https://www.xdc.dev/juklee0ira/using-a-tracer-to-locate-contracts-j3a</guid>
      <description>&lt;h3&gt;
  
  
  Abstract
&lt;/h3&gt;

&lt;h3&gt;
  
  
  The journey of the tool
&lt;/h3&gt;

&lt;p&gt;The journey of creating the tracer tool began with a requirement: we needed to identify contract addresses that contained certain opcodes for better analysis and security auditing. Initially, we built a JavaScript version of the tool. This early iteration allowed us to interact with the blockchain and search for specific opcodes in blocks, providing a foundation for the solution.&lt;/p&gt;

&lt;p&gt;We iterated on a few approaches, including using JS scripts for parsing and developing a native tracer, eventually coming up with a solution that provides excellent coverage of analysis in terms of the code executions being considered. This solution also delivers good performance, making it feasible to efficiently search a long stretch of historical data.&lt;/p&gt;

&lt;p&gt;This solution includes a tracer to identify contract addresses within blocks and locate contracts containing specific opcodes. The specific implementation can be found &lt;a href="https://github.com/XinFinOrg/XDPoSChain/pull/683"&gt;here&lt;/a&gt;, and below is an example request:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Request Example:&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="nv"&gt;RPC&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://172.16.3.16:8547"&lt;/span&gt;
&lt;span class="nv"&gt;NUMBER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"0x399e"&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; POST &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;RPC&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
  "jsonrpc": "2.0",
  "id": 1002,
  "method": "debug_traceBlockByNumber",
  "params": [
    "'&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NUMBER&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'", {
        "tracer":"contractTracer"
    }
  ]
}'&lt;/span&gt; | jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Response Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"jsonrpc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1002&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"result"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"result"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"0xf63f8ba05d790b93db0005de3e65d90cd0b68bf6"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this request, &lt;code&gt;contractTracer&lt;/code&gt; is used to trace contract code in a specified block. By matching a specific opcode, it filters contract addresses. The result is an array of contract addresses that contain the specified opcode.&lt;/p&gt;

&lt;h4&gt;
  
  
  JavaScript Version
&lt;/h4&gt;

&lt;p&gt;The first version of the tool was built in JavaScript, leveraging Node.js to interact with blockchain nodes. It worked by iterating over blocks and using the RPC endpoint to analyze contract code. The JavaScript version was functional but had limitations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Retrieving Transactions from Blocks&lt;/strong&gt;: By querying blocks (e.g., using &lt;code&gt;eth_getBlockByNumber&lt;/code&gt;), all transactions within that block were obtained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Checking Each Transaction's Receipt&lt;/strong&gt;: Using &lt;code&gt;eth_getTransactionReceipt&lt;/code&gt;, the receipt of each transaction was queried. In the receipt, the &lt;code&gt;contractAddress&lt;/code&gt; field would display the address of any newly created contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Confirming If the Address Is a Contract&lt;/strong&gt;: For each &lt;code&gt;contractAddress&lt;/code&gt;, &lt;code&gt;eth_getCode&lt;/code&gt; was used to query the code at that address. If the returned code was non-zero, it indicated that the address was a smart contract. If a contract was created, &lt;code&gt;eth_getCode&lt;/code&gt; was used to query the opcodes of that contract, matching them against the specified opcode. If a match was found, the contract address was written to a file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach has a limitation: it cannot detect contracts created by the &lt;code&gt;CREATE&lt;/code&gt; or &lt;code&gt;CREATE2&lt;/code&gt; opcodes. The reason is that it only checks the &lt;code&gt;To&lt;/code&gt; field of a transaction, which shows the transaction's target address. However, contracts created with &lt;code&gt;CREATE&lt;/code&gt; or &lt;code&gt;CREATE2&lt;/code&gt; are usually generated by internal calls within a contract, not by transactions directly sent from an externally owned account (EOA). As a result, these contracts don’t appear in the &lt;code&gt;tx.To()&lt;/code&gt; field because they are created during the transaction execution, not as part of the transaction's target address.&lt;/p&gt;

&lt;p&gt;Although &lt;code&gt;callTracer&lt;/code&gt; can be used to check for opcodes used in a transaction, this method requires decoding a large amount of data, which can lead to frequent timeouts and significantly affect performance. This is especially true when scanning a large range of blocks. Therefore, we decided to explore a solution that requires fewer RPC calls and is much faster.&lt;/p&gt;

&lt;h4&gt;
  
  
  Golang version
&lt;/h4&gt;

&lt;p&gt;Golang is usually faster than JS. By implementing a native tracer directly in the Golang client, we could reduce encoding/decoding and networking overhead. This led us to focus on developing a native tracer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CaptureEnter Iteration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To address the limitations of the JavaScript version, we introduced the &lt;code&gt;CaptureEnter&lt;/code&gt; iteration. In this version, we created a tracer within the node to track opcodes during contract execution. We added the possibility for users to customize all the tracers within XDC Golang client. This feature is utilized in our tool to specify the opcode of interest. This tracer accepted an opcode and returned the contract addresses containing the specified opcode.&lt;/p&gt;

&lt;p&gt;This version focused on enhancing the tool's performance and scalability. It achieved a significant reduction in processing time (approximately 45-fold). The first approach took 1 day to process 22k blocks, while the improved version processed 1 million blocks in the same amount of time. This makes the tool far more practical for handling larger block ranges&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CaptureState Version&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The latest iteration, known as CaptureState, implemented its main logic in CaptureState, allowing for precise tracking of contract deployment and execution. Instead of analyzing static code, this version focused on actual execution threads of contracts, enabling us to track the code that was actively used rather than dormant.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Logic Explanation
&lt;/h3&gt;

&lt;p&gt;When implementing the tracer, it follows these main steps to locate and filter contracts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initialization and Setup&lt;/strong&gt;: In the Go code, the tracer's structure and initialization function are defined. Parameters in the structure control which opcode to search for.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Opcode Matching&lt;/strong&gt;: While going through blocks and executing code, the tracer compares each instruction’s opcode with the user-specified opcode.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If a contract contains an opcode but it is not called, the tracer will not detect this opcode.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Matching contract addresses are added to the result array.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limitations 
&lt;/h3&gt;

&lt;p&gt;Currently, the tracer directly compares opcodes without differentiating between &lt;code&gt;PREVRANDAO&lt;/code&gt; and &lt;code&gt;DIFFICULTY&lt;/code&gt;. Both share the same opcode value (0x44).The &lt;code&gt;PREVRANDAO&lt;/code&gt; opcode was enabled after block 76321000. Therefore, when using this tool, if you search for this opcode in blocks before 76321000, the matching results will correspond to the &lt;code&gt;DIFFICULTY&lt;/code&gt; opcode. Understanding this limitation is crucial for accurately interpreting the results.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Use (Script) 
&lt;/h3&gt;

&lt;p&gt;For easier batch processing and data storage, a Node.js script &lt;code&gt;opCodeFinder.js&lt;/code&gt; is provided and the implementation can be found &lt;a href="https://github.com/XinFinOrg/Scripts/pull/1"&gt;here&lt;/a&gt;.This script searches for contracts with specific opcodes in a given block range and stores the results in a .txt file. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Script Example:&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;node src\opCodeFinder.js 72290000 latest PREVRANDAO https://rpc.ankr.com/xdc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Parameters 
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[START_BLOCK]&lt;/strong&gt;: The starting block number for the search, e.g., &lt;code&gt;72290000&lt;/code&gt;  .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[END_BLOCK]&lt;/strong&gt;: The ending block number or &lt;code&gt;latest&lt;/code&gt; for the most recent block. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[OPCODE]&lt;/strong&gt;: The opcode to search for, e.g., &lt;code&gt;PREVRANDAO&lt;/code&gt; (case-sensitive). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[RPC_ENDPOINT]&lt;/strong&gt;: The URL of the RPC node, e.g., &lt;code&gt;https://rpc.ankr.com/xdc&lt;/code&gt;  .&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running this script, all matching contract addresses are stored in a specified txt file for further analysis and use. &lt;/p&gt;

&lt;h3&gt;
  
  
  Results and Analysis 
&lt;/h3&gt;

&lt;p&gt;After developing the &lt;code&gt;CaptureState&lt;/code&gt; version, we ran extensive analysis to identify contracts that might be vulnerable due to the presence of specific opcodes. For instance, contracts containing the &lt;code&gt;PREVRANDAO&lt;/code&gt; opcode were of particular interest because of their potential impact on randomness generation and security. &lt;/p&gt;

&lt;p&gt;Through our analysis, we identified several contracts that could be vulnerable based on their use of certain opcodes. This information is crucial for developers and auditors to assess the security of smart contracts and take appropriate measures to mitigate risks. &lt;/p&gt;

&lt;p&gt;By using this method, developers can efficiently locate contracts with specific opcodes on the blockchain, providing valuable support for security audits and code analysis.&lt;/p&gt;

</description>
      <category>xdc</category>
      <category>tracer</category>
    </item>
    <item>
      <title>XDCValidator.sol：managing KYC and validators</title>
      <dc:creator>JukLee0ira</dc:creator>
      <pubDate>Tue, 27 Aug 2024 06:21:41 +0000</pubDate>
      <link>https://www.xdc.dev/juklee0ira/draft-xdcvalidatorsolmanaging-kyc-and-validators-43oc</link>
      <guid>https://www.xdc.dev/juklee0ira/draft-xdcvalidatorsolmanaging-kyc-and-validators-43oc</guid>
      <description>&lt;p&gt;The &lt;code&gt;XDCValidator.sol&lt;/code&gt; contract helps with decentralized identity checks (called KYC) and managing validators. It does these tasks: handles user identity verification, lets users suggest and choose validators, and allows the community to vote on whether to accept identity checks that might not pass the standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Become a masternode
&lt;/h2&gt;

&lt;p&gt;The process of becoming a masternode is shown in the diagram below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         User 
          O   
         /|\  
         / \  

          |
          | Upload KYC information to participate
          | in the candidate process.
          v
+-----------------+
|   uploadKYC()   | 
+-----------------+
          |
          | Become an owner by depositing XDC
          | (minCandidateCap) and proposing
          | a candidate address.
          v
+-----------------+
|    propose()    | Propose an address as a candidate
+-----------------+
          | 
          |
          v
Now you are a candidate node owner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Kick out the masternodes
&lt;/h2&gt;

&lt;p&gt;An invalid KYC will cause a owner to lose all of his candidate node. The process is shown in the diagram below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+-----------------+
|   Candidates    |
|     (Node)      |
+-----------------+
          | 
          | 
          |
          v
+-----------------+
| voteInvalidKYC()| Report invalid KYC for other candidates
+-----------------+
          |
          | Check the invalid vote percentage
          | using `invalidPercent()` 
          |
          v
+---------+---------+
|                   |
v                   v
75% against         (else)
invalid KYC         valid KYC
the owner of KYC    Candidate remains valid.
Lost his candidates      
and funds           
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Resign
&lt;/h2&gt;

&lt;p&gt;If you want to resign from candidacy. The process is shown in the diagram below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        Owner
          O   
         /|\  
         / \  
          |
          |
          v
    +----------+
    | resign() |
    +----------+
          | Withdraws candidacy
          |
          |              
          | Locking Period
          | 30 days lock-up
          |
          |
          v
    +------------+
    | withdraw() |
    +------------+
     Withdraw funds from contract 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;Implementing KYC management and Validator management through several functions, with specific roles as follows:&lt;/p&gt;

&lt;h3&gt;
  
  
  uploadKYC
&lt;/h3&gt;

&lt;p&gt;Uploads user KYC. This operation only stores the user's verification details and does not confer owner status.&lt;br&gt;
Function Signature:&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;function&lt;/span&gt; &lt;span class="n"&gt;uploadKYC&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;kychash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Anyone(msg.sender)&lt;/p&gt;

&lt;p&gt;Modifers: none&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;kychash&lt;/code&gt; : The hash of the user's KYC information.
### propose
Owner proposes &lt;code&gt;_candidate&lt;/code&gt; to become a masternode.
Function Signature:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;propose&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;_candidate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Anyone who has uploaded KYC (or is the owner) and has paid enough deposit.&lt;/p&gt;

&lt;p&gt;Modifers: &lt;code&gt;onlyKYCWhitelisted&lt;/code&gt;, &lt;code&gt;onlyValidCandidateCap&lt;/code&gt;,&lt;code&gt;onlyNotCandidate&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_candidate&lt;/code&gt; : The address of the nominee.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  vote
&lt;/h3&gt;

&lt;p&gt;Deposits an amount not less than minVoterCap into the contract to cast a vote for the candidate.During voting, the candidate's total cap value will be updated.If it's the first time voting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The voter will be added to the candidate's voter list.&lt;/li&gt;
&lt;li&gt;The voter's stake for that candidate will be updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Function Signature:&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;function&lt;/span&gt; &lt;span class="n"&gt;vote&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;_candidate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Anyone (msg.sender) who has paid enough voting amount&lt;/p&gt;

&lt;p&gt;Modifers: &lt;code&gt;onlyValidVoterCap&lt;/code&gt;,&lt;code&gt;onlyValidCandidate&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_candidate&lt;/code&gt; : The address of the candidate receiving the vote.
### unvote
Revokes a vote for a candidate, with the corresponding funds refunded after X blocks.
Function Signature:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;unvote&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;_candidate&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;_cap&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Anyone (msg.sender) who has a valid vote for a specific candidate node&lt;/p&gt;

&lt;p&gt;Modifers: &lt;code&gt;onlyValidVote&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_candidate&lt;/code&gt; : The address of the candidate for whom the vote is to be revoked.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_cap&lt;/code&gt; : The amount to be refunded.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  voteInvalidKYC
&lt;/h3&gt;

&lt;p&gt;Allows the masternode, through a vote among masternode owner , to decide if another owner's KYC information meets the requirements. If over 75% of the owners deem it invalid, the KYC is considered Unqualified, leading to the forfeiture of funds from that owner and all their candidates.&lt;/p&gt;

&lt;p&gt;Function Signature:&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;function&lt;/span&gt; &lt;span class="n"&gt;voteInvalidKYC&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;_invalidCandidate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Candidate&lt;/p&gt;

&lt;p&gt;Modifers: &lt;code&gt;onlyValidCandidate&lt;/code&gt;,&lt;code&gt;onlyValidCandidate&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_invalidCandidate&lt;/code&gt; : The address of the candidate whose owner's KYC validity is under judgment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  invalidPercent
&lt;/h3&gt;

&lt;p&gt;Checks the percentage of "Invalid KYC" votes for a particular owner, indicating the level of community approval regarding that owner's KYC information.&lt;br&gt;
Function Signature:&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;function&lt;/span&gt; &lt;span class="n"&gt;invalidPercent&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;_invalidCandidate&lt;/span&gt;&lt;span class="p"&gt;)&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;uint&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Anyone(msg.sender)&lt;/p&gt;

&lt;p&gt;Modifers:  &lt;code&gt;onlyValidCandidate&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_invalidCandidate&lt;/code&gt; : The address of the candidate whose owner's KYC recognition level needs to be queried.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user can withdraw from candidacy and reclaim their funds upon meeting certain conditions. &lt;/p&gt;

&lt;h3&gt;
  
  
  resign
&lt;/h3&gt;

&lt;p&gt;Withdraws candidacy, with the corresponding deposit refunded after X blocks. This function can only be called by the owner.&lt;br&gt;
Function Signature:&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;function&lt;/span&gt; &lt;span class="n"&gt;resign&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;_candidate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Owner&lt;/p&gt;

&lt;p&gt;Modifers: &lt;code&gt;onlyOwner&lt;/code&gt;,&lt;code&gt;onlyCandidate&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_candidate&lt;/code&gt; : The address of the candidate wishing to withdraw their candidacy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  withdraw
&lt;/h3&gt;

&lt;p&gt;This function allows for the withdrawal of funds from the contract, exclusively available to approved candidates.&lt;br&gt;
Function Signature:&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;function&lt;/span&gt; &lt;span class="n"&gt;withdraw&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;_blockNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint&lt;/span&gt; &lt;span class="n"&gt;_index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who can use: Addresses that have previously staked (as owner or voter) and have unlocked funds&lt;/p&gt;

&lt;p&gt;Modifers: &lt;code&gt;onlyValidWithdraw&lt;/code&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_blockNumber&lt;/code&gt; : The block height associated with the withdrawal request. This is used to link the withdrawal action to a specific point in the blockchain's history.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_index&lt;/code&gt; : An index pointing to the user's current withdrawal request in the record. This helps in locating and processing the correct withdrawal operation for the candidate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Modifers
&lt;/h2&gt;

&lt;p&gt;The contract incorporates several Modifiers to govern the execution conditions of functions, serving specific purposes as outlined below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;onlyValidCandidateCap&lt;/strong&gt;: The deposited amount (&lt;code&gt;msg.value&lt;/code&gt;) must exceed &lt;code&gt;minCandidateCap&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyValidVoterCap&lt;/strong&gt;: The amount deposited into the contract (&lt;code&gt;msg.value&lt;/code&gt;) must be greater than &lt;code&gt;minVoteCap&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyKYCWhitelisted&lt;/strong&gt;: A KYC record is required, or the address must have proposed or owns another candidate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyOwner(address _candidate)&lt;/strong&gt;: restricts calls to the owner associated with the specified candidate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyCandidate(address _candidate)&lt;/strong&gt;: allows calls only from the candidate specified.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyValidCandidate(address _candidate)&lt;/strong&gt;: permits calls exclusively from a legitimate candidate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyNotCandidate(address _candidate)&lt;/strong&gt;: permits calls only from addresses that are not candidates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyValidVote(address _candidate, uint256 _cap)&lt;/strong&gt;: requires the vote to be legitimate with respect to the candidate and the cap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onlyValidWithdraw(uint256 _blockNumber, uint _index)&lt;/strong&gt;: demands that the block number is reasonable and valid for the withdrawal operation.&lt;/li&gt;
&lt;/ul&gt;

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