# Introducing DeeLance Blockchain

## Blockchain Built for Freelancers

In the digital age, the intersection of technology and professional collaboration is evolving at a breakneck pace. Enter DeeLance Blockchain – a pioneering force reshaping the landscape of freelancing and recruitment. Merging the principles of decentralization with Web3 innovations, DeeLance isn't merely a platform; it's an ecosystem, a paradigm shift that encapsulates the future of work.

DeeLance doesn't just harness the power of blockchain; it refines and magnifies its potential. By addressing the traditional pain points of freelancing - from transactional inefficiencies to the lack of transparent interactions - DeeLance offers a solution that is secure, transparent, and remarkably user-centric. With its integration of groundbreaking features like an NFT marketplace, an immersive Metaverse, and a next-gen recruitment platform, DeeLance stands as a beacon for professionals globally.

This blockchain initiative is not just about revolutionizing freelancing; it's about creating a realm where opportunities are boundless, transactions are seamless, and every user's potential is recognized and rewarded. Welcome to the DeeLance Blockchain – where the future of freelancing is being crafted today.<br>

***

<details>

<summary>Mission</summary>

To empower freelancers globally with a blockchain-driven ecosystem that prioritizes transparency, security, and seamless collaboration. We endeavor to reinvent the freelancing landscape by bridging decentralized technology with human talent, ensuring every professional has direct control and ownership of their work, fostering trust and genuine connections between freelancers and clients.

</details>

<details>

<summary>Vision </summary>

To establish DeeLance Blockchain as the gold standard for the future of freelancing, where every interaction is underpinned by trust, every transaction is swift and transparent, and every freelancer thrives in an environment built to recognize and reward their unique skills. We envision a world where boundaries are blurred, opportunities are boundless, and the global freelancer community stands united and strong on the bedrock of our revolutionary blockchain platform.

</details>


# What is Blockchain

> *Blockchain is a distributed ledger technology that allows data to be stored across a network of computers in a way that's transparent, secure, and without a central authority. At its core, a blockchain is a chain of blocks, with each block containing a list of records called transactions.*\
> \
> *Every computer in the network must agree upon each new block and the chain as a whole. These computers are known as "nodes". Nodes ensure everyone interacting with the blockchain has the same data. To accomplish this distributed agreement, blockchains need a consensus mechanism.*

## Ethereum Virtual Machine (EVM)

The Ethereum Virtual Machine is the global virtual computer whose state every participant on the Ethereum network stores and agrees on. Any participant can request the execution of arbitrary code on the EVM; code execution changes the state of the EVM.

## Nodes <a href="#nodes" id="nodes"></a>

The real-life machines which are storing the EVM state. Nodes communicate with each other to propagate information about the EVM state and new state changes. Any user can also request the execution of code by broadcasting a code execution request from a node. The Ethereum network itself is the aggregate of all Ethereum nodes and their communications.


# Overview

## Introduction

Deelance Chain is an innovative solution tailored for freelancer. Deelance Chain relies on a system of 55 validators with Proof of Staked Authority (PoSA) consensus that can support short block time and lower fees. The most bonded validator candidates of staking will become validators and produce blocks. The double-sign detection, malicious vote detection and other slashing logic guarantee security, stability, and chain finality. Other than the 32 active validators, Deelance will introduce more validators, e.g. another 23 inactive validators, into the validator set as backups, which will be called "Candidates".

Candidates will produce blocks and charge gas fees in Deelance Chain mainnet, but in a much less chance than the official validator set of 32 elected. The unavailable candidates will be slashed as well though in a smaller size. A decent motivation is expected to be maintained so that the candidate validators are willing to ensure the quality and help secure Deelance Chain.

The Deelance Chain also supports EVM-compatible smart contracts and protocols. Cross-chain transfer and other communication are possible due to native support of interoperability. The Deelance Chain will be:

* **A self-sovereign blockchain**: Provides security and safety with elected validators.
* **EVM-compatible**: Supports all the existing Ethereum tooling along with faster finality and cheaper transaction fees.
* **Fast Finality**: Finalizes the chain within two blocks in most cases.
* **Interoperable**: Comes with efficient native dual chain communication; Optimized for scaling high-performance dApps that require a fast and smooth user experience.
* **Distributed with on-chain governance**: Proof of Staked Authority (PoSA) brings in decentralization and community participants. As the native token, DEE will serve as both the gas of smart contract execution and tokens for staking.

### Proof of Staked Authority

Although Proof-of-Work (PoW) has been recognized as a practical mechanism to implement a decentralized network, it is not friendly to the environment and also requires a large size of participants to maintain the security.

Ethereum and some other blockchain networks, such as [MATIC Bor](https://github.com/maticnetwork/bor), [TOMOChain](https://tomochain.com/), [GoChain](https://gochain.io/), [xDAI](https://xdai.io/), do use [Proof-of-Authority(PoA)](https://en.wikipedia.org/wiki/Proof_of_authority) or its variants in different scenarios, including both testnet and mainnet. PoA provides some defense to 51% attack, with improved efficiency and tolerance to certain levels of Byzantine players (malicious or hacked). It serves as an easy choice to pick as the fundamentals.

Meanwhile, the PoA protocol is most criticized for being not as decentralized as PoW, as the validators, i.e. the nodes that take turns to produce blocks, have all the authorities and are prone to corruption and security attacks. Other blockchains, such as EOS and Lisk both, introduce different types of [Delegated Proof of Stake (DPoS)](https://en.bitcoinwiki.org/wiki/DPoS) to allow the token holders to vote and elect the validator set. It increases the decentralization and favors community governance.

Deelance Chain here proposes to combine DPoS and PoA for consensus, so that:

1. Blocks are produced by a limited set of validators
2. Validators take turns to produce blocks in a PoA manner, similar to [Ethereum's Clique](https://eips.ethereum.org/EIPS/eip-225) consensus design
3. Validator set are elected in and out based on a staking based governance

Fast finalization can greatly improve user experience. The `Fast Finality` feature will be enabled upon the coming Plato upgrade. This will be a major advantage of Deelance Chain, and many dapps will benefit from it.

The consensus protocol of Deelance Chain fulfills the following goals:

1. Short Blocking time, 3 seconds on mainnet.
2. It requires quite short time to confirm the finality of transactions, around 6s for mainnet after the coming Plato upgrade.
3. There is no inflation of native token: DEE, the block reward is collected from transaction fees, and it will be paid in DEE.
4. It is 100% compatible with Ethereum system.
5. It allows modern proof-of-stake blockchain network governance.

### Security

Given there are more than ½\*N+1 validators are honest, PoA based networks usually work securely and properly. However, there are still cases where certain amount Byzantine validators may still manage to attack the network, e.g. through the [Clone Attack](https://arxiv.org/pdf/1902.10244.pdf). Deelance Chain does introduce Slashing logic to penalize Byzantine validators for double signing or inavailability. This Slashing logic will expose the malicious validators in a very short time and make the "Clone Attack" very hard or extremely non-beneficial to execute.

### Fast Finality

Finality is critical for blockchain security, once the block is finalized, it wouldn’t be reverted anymore. The fast finality feature is very useful, the users can make sure they get the accurate information from the latest finalized block, then they can decide what to do next instantly. More details of design, please to refer [BEP-126](https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP126.md)

### Reward

All the Deelance Chain validators in the current validator set will be rewarded with transaction fees in DEE. As DEE is not an inflationary token, there will be no mining rewards as what Bitcoin and Ethereum network generate, and the gas fee is the major reward for validators. After the coming Plato upgrade, part of the fees collected will be used as reward for finality voting. As DEE is also utility tokens with other use cases, delegators and validators will still enjoy other benefits of holding DEE.

The reward for validators is the fees collected from transactions in each block. Validators can decide how much to give back to the delegators who stake their DEE to them, in order to attract more staking. Every validator will take turns to produce the blocks in the same probability (if they stick to 100% liveness), thus, in the long run, all the stable validators may get a similar size of the reward. Meanwhile, the stakes on each validator may be different, so this brings a counter-intuitive situation that more users trust and delegate to one validator, they potentially get less reward. So rational delegators will tend to delegate to the one with fewer stakes as long as the validator is still trustful (insecure validator may bring slashable risk). In the end, the stakes on all the validators will have less variation. This will actually prevent the stake concentration and "winner wins forever" problem seen on some other networks.

### Staking and Governance

Proof of Staked Authority brings in decentralization and community involvement. Its core logic can be summarized as the below. You may see similar ideas from other networks, especially Cosmos and EOS.

1. Token holders, including the validators, can put their tokens "bonded" into the stake. Token holders can delegate their tokens onto any validator or validator candidate, to expect it can become an actual validator, and later they can choose a different validator or candidate to re-delegate their tokens.
2. All validator candidates will be ranked by the number of bonded tokens on them, and the top ones will become the real validators.
3. Validators can share (part of) their blocking reward with their delegators.
4. Validators can suffer from "Slashing", a punishment for their bad behaviors, such as double sign and/or instability.
5. There is an "unbonding period" for validators and delegators so that the system makes sure the tokens remain bonded when bad behaviors are caught, the responsible will get slashed during this period.


# About DeeLance

Blockchain Built for Freelancers

### **DeeLance Blockchain: Tailored for Freelancers**

In the expansive realm of digital freelancing, where traditional platforms have often grappled with issues like intermediary fees, delayed payments, and transparency, DeeLance Blockchain emerges as a breath of fresh air.

### **The Freelance Revolution**:

DeeLance Blockchain isn't just another platform; it's a revolution for freelancers. Grounded in the principles of decentralization, DeeLance aspires to realign the power dynamics of the freelancing industry. By leveraging blockchain technology, it ensures that intermediaries are eliminated, reducing unnecessary fees and ensuring faster, more secure payments for freelancers.

### **Empowering the Individual**:

At its core, DeeLance believes in the power of individual talent. The platform is designed to give freelancers a space where their skills are not just recognized but also aptly rewarded. Every freelancer, irrespective of their domain, has direct control over their projects, negotiations, and earnings. With an integrated smart contract system, agreements are clear, secure, and automated, ensuring both parties get what they've agreed upon.

### **A Global Freelance Marketplace**:

DeeLance Blockchain transcends geographical boundaries. It provides a global marketplace where freelancers from any corner of the world can collaborate with clients without the usual geographical or currency-related constraints. The platform supports instant crypto payments, ensuring that freelancers are paid promptly and securely.

### **Intuitive and User-Centric Design**:

Understanding the diverse needs of freelancers, DeeLance Blockchain is developed with an intuitive user interface. Whether it's creating a profile, showcasing a portfolio, or navigating through projects, every aspect of the platform is streamlined for ease of use.

### **The Road Ahead**:

While DeeLance Blockchain has already set the stage for a more inclusive, transparent, and efficient freelance ecosystem, its journey has just begun. With plans to integrate features like an NFT marketplace for digital artists, a metaverse for virtual collaboration, and advanced AI-driven matchmaking for projects, DeeLance aims to remain at the forefront of the freelance revolution.

In essence, DeeLance Blockchain is not just a technological platform but a movement – a commitment to reshaping the world of freelancing to ensure it's more equitable, rewarding, and attuned to the needs of modern-day professionals.


# Ecosystem

## **A Deep Dive into its Revolutionary Offerings**

***

### **DeFi (Decentralized Finance)**:&#x20;

Central to DeeLance's vision is its steadfast commitment to revolutionizing the financial landscape with Decentralized Finance (DeFi). Beyond just another feature, our DeFi solutions challenge and transform conventional financial systems. With the robust DeeLance blockchain at its core, we offer a platform where users not only regain control over their financial transactions but also enjoy a myriad of decentralized financial tools and services. These tools, tailored for the modern freelancer, prioritize security, transparency, and flexibility, truly epitomizing the essence of financial democratization.

### **Smart Contracts**:

A blend of technology and trust, DeeLance's Smart Contracts offer more than just digital agreements. These contracts, meticulously coded onto our blockchain, are representative of our commitment to redefining transactional trust in the digital realm. From automating agreements to ensuring tamper-proof validation, these contracts streamline and secure every transaction. In a domain where transparency is paramount, our Smart Contracts ensure every deal is locked in with confidence, reliability, and utmost integrity.

### **Bridge Assets**:&#x20;

In the fragmented universe of digital assets, DeeLance introduces a bridge that streamlines and secures the movement of assets across different blockchains. The Bridge Assets functionality, an integral part of the DeeLance ecosystem, acts as a conduit, ensuring smooth and hassle-free transfer and synchronization of various digital entities. With this, users can seamlessly manage, move, and magnify their digital portfolio, all while staying assured of their assets' security and integrity.

### **NFT Marketplace**:&#x20;

In the age of digital art and collectibles, DeeLance's NFT (Non-Fungible Token) Marketplace stands out as an epitome of authenticity and innovation. Beyond a platform, it's a universe where creators can mint, list, and trade their digital masterpieces. Leveraging the immutable nature of our blockchain, every NFT listed ensures provenance, reducing the risk of counterfeit assets. For collectors and creators alike, this marketplace offers a space to discover, collaborate, and capitalize on unique digital assets, all within a secure and transparent framework.

### **Metaverse**:&#x20;

The DeeLance Metaverse is a marvel of virtual innovation. Constructed atop our state-of-the-art blockchain, it represents the nexus where reality melds with virtual possibilities. This immersive space is designed for collaboration, creation, and exploration. Freelancers can interact with clients in real-time, attend virtual conferences, showcase their portfolios in 3D galleries, or even partake in virtual co-working spaces. The DeeLance Metaverse, with its vast potential, is poised to redefine how freelancers collaborate, communicate, and create.

### **Freelancing Platform**:

&#x20;DeeLance's Freelancing Platform is a holistic solution tailored for the modern freelancer. Marrying the principles of blockchain with the dynamic needs of freelancers and clients, this platform offers more than just job listings. From a transparent review system to instant, crypto-based payments, and smart contract-secured project deliveries, every interaction is elevated by the principles of transparency, security, and efficiency. In an industry often plagued by delayed payments, opaque agreements, and intermediary fees, DeeLance's platform emerges as a beacon of trust, ensuring that freelancers can focus on what they do best, leaving the intricacies of transactions, agreements, and security to us.


# ERC20 DLANCE Token

### **Usage of ERC20 dlance Token**:&#x20;

The ERC20 dlance token is compliant with the ERC20 standard on the Ethereum blockchain. This means it's compatible with Ethereum wallets, can be traded on Ethereum-based exchanges, and can be used with smart contracts specifically crafted for ERC20 tokens. Within the deelance ecosystem, the dlance token might have various applications, such as:

* Acting as a medium of exchange.
* acting as payment method in ecosystem&#x20;
* Potentially representing assets or other values unique to the deelance platform.

<mark style="color:blue;">ERC20 dlance token as a starting point on the Ethereum network.</mark> However, with the growth and specific needs of the platform, a migration to our proprietary **DeeLance blockchain** becomes essential.

### **Migration to Dlance Native Coin on the deelance blockchain**:

* The deelance team began with the ERC20 dlance token on the Ethereum platform. But given the platform's evolving demands and growth, transitioning to our exclusive deelance blockchain has become crucial.
* This transition will typically involve a token swap. Holders of the ERC20 dlance token will likely be given directives on sending their tokens to a particular address or using a specific swapping mechanism where their ERC20 tokens will be "locked". Subsequently, they will receive the native Dlance coins on the deelance blockchain.
* The conversion rate during the swap could vary and will announce at later stage&#x20;

### Benefits of the Dlance native token on the deelance blockchain:

1. **Improved Scalability**: Native tokens on dedicated blockchains can often handle more transactions per second, offering smoother and faster operations than tokens on congested networks like Ethereum.
2. **Reduced Transaction Fees**: Without having to compete for block space on Ethereum, Dlance native token transactions might have significantly lower fees.
3. **Tailored Governance**: The native token can be integrated with a governance system that allows token holders to participate in decision-making specifically tailored to the deelance ecosystem.
4. **Enhanced Security**: With a proprietary blockchain, the deelance team will implement custom security measures, making the network more resilient to attacks.
5. **Integrated Features**: The native token could support advanced features and utilities directly built into the deelance blockchain, without the limitations of the ERC20 standard.
6. **Interoperability**: The deelance blockchain could be designed to seamlessly interact with other blockchains, enhancing the utility of the Dlance native token.
7. **Economic Incentives**: There might be staking, farming, or other economic incentives tied directly to the Dlance native token, promoting user engagement and investment in the ecosystem.
8. **Green Initiatives**: Deelance blockchain employs a more energy-efficient consensus mechanism than other Blockchains , then using the native token could be more environmentally friendly.
9. **Dedicated Support**: With a token native to its platform, any issues, upgrades, or changes can be directly managed by the deelance team, ensuring faster resolutions and more responsive adjustments.
10. **Enhanced Adoption**: A unique and dedicated blockchain could attract more partnerships and integrations, increasing the utility and demand for the Dlance native token.


# Community

### Website And Socials

* [Website](https://deelance.com/)
* [Twitter](https://twitter.com/deelance_com)
* [Facebook](https://www.facebook.com/deelanceofficial/?show_switched_toast=0\&show_invite_to_follow=0\&show_switched_tooltip=0\&show_podcast_settings=0\&show_community_review_changes=0\&show_community_rollback=0\&show_follower_visibility_disclosure=0)
* [Telegram](https://t.me/deelance_com)
* [LinkedIn](https://www.linkedin.com/company/deelance)
* [Discord](https://discord.gg/vhH3Sbt9NQ)
* [Instagram](https://www.instagram.com/deelanceofficial/)
* [YouTube](https://www.youtube.com/channel/UCM7Nv8JQECFr5lF_hd8KgTA)
* [Medium](https://medium.com/@deeLance)

### **DeeLance Academy**

Welcome to the DeeLance Academy, a dedicated hub for learners at all stages of their blockchain journey. Whether you're a beginner seeking foundational knowledge or an advanced user looking to sharpen your expertise, our academy has been tailored to meet your needs.

[VISIT](https://deelance.com/academy)

### Join Our Ambassador Program

Become A DeeLance’s Ambassador

Are you an influencers, bloggers, and content creators !

Join our exclusive community as a Deelance Ambassador. Earn incredible rewards and showcase your skills while spreading a word about our brand.

[Join Now](https://ambassador.deelance.com/)

### Careers

visit [Career Page](https://deelance.com/academy/careers)


# Add DeeLance to Metamask

Effortlessly Integrate DeeLance with MetaMask using the guide below.

### Mainnet

Use this link to add directly to your metamask - <https://chainlist.org/?search=dee>

| Parameters         | Values                     |
| ------------------ | -------------------------- |
| **Currency**       | Dee                        |
| **Chain ID**       | 45510                      |
| **RCP endpoint**   | <https://rpc.deelance.com> |
| **Block Explorer** | <https://deescan.com/>     |

### Testnet

<table><thead><tr><th width="374">Parameters </th><th>Value</th></tr></thead><tbody><tr><td><strong>Currency</strong> </td><td>Dee</td></tr><tr><td><strong>Chain ID</strong> </td><td>455214</td></tr><tr><td><strong>Http RCP endpoint</strong> </td><td><a href="http://testnet-rpc.deelance.com/">http://testnet-rpc.deelance.com/</a></td></tr><tr><td><strong>Faucet</strong> </td><td><a href="http://faucet.deelance.com/">http://faucet.deelance.com/</a></td></tr><tr><td><strong>Block Explorer</strong></td><td><a href="http://testnet.deelance.com/">http://testnet.deelance.com/</a></td></tr></tbody></table>

###

## How to Add DeeLance to MetaMask: A Step-by-Step Guide&#x20;

<mark style="color:blue;">Download Metamask Extension</mark>&#x20;

<figure><img src="/files/XTV5GrBtWhSsafxKwfIe" alt=""><figcaption><p>To begin your journey in the crypto world, you need to install a decentralized wallet that only you have control over. One of the most widely used wallets is MetaMask. To install MetaMask, visit the official website and select the browser you want to use, such as Chrome or Firefox. / Download the metamask extension</p></figcaption></figure>

<figure><img src="/files/PD2hQ0H8dXsa8vUHknoQ" alt=""><figcaption><p><mark style="color:blue;"><strong>Click this icon on your browser</strong></mark> </p></figcaption></figure>

<figure><img src="/files/JEInrX3Do70Y1LgMpvG6" alt=""><figcaption><p>Once installed, click on the "Create a Wallet" button to create your MetaMask wallet. Your wallet's public key is a unique identifier on the blockchain and is generated randomly.</p></figcaption></figure>

<figure><img src="/files/AuONpnLaK3IQPu6N1dKZ" alt=""><figcaption><p>MetaMask will prompt you to set a password for your wallet. It is essential to choose a strong password that cannot be easily guessed.</p></figcaption></figure>

<figure><img src="/files/4Up5XiYHF72xMpAEPG8X" alt=""><figcaption><p>It is crucial to write down your 12-word recovery phrase on a piece of paper and keep it safe. Please do not store it on your PC as it may be vulnerable to cyber-attacks. This recovery phrase is necessary, without this you could lose access to your wallet.</p></figcaption></figure>

<figure><img src="/files/EhuR5NaZbzxoVLPkoNEr" alt=""><figcaption><p>By default, MetaMask is set to transact with the Ethereum network, to add DeeLance Network Open MetaMask Extension, Access Settings then click on Click  "Add Network."</p></figcaption></figure>

<figure><img src="/files/SjK7EKQdLcVfpz5gph3s" alt=""><figcaption><p>Provide DeeLance Network Name, RPC URL, Chain ID, and optionally Symbol and Block Explorer of DeeLance testnet parameter. Click "Save" or "Add" to finish</p></figcaption></figure>

<figure><img src="/files/DbYPLQO13NZIXbQcVfGJ" alt=""><figcaption><p>You can now see the DeeLance network listed among the available networks in your MetaMask account.</p></figcaption></figure>


# Get Testnet Funds

{% hint style="info" %}
To obtain Testnet funds, visit our DeeLance testnet faucet [<mark style="color:blue;">here</mark>](https://faucet.deelance.com/).
{% endhint %}

### How does the DeeLance faucet work?

To stop harmful users from using up all the available $Dee, we've linked requests to Twitter accounts. If you have a Twitter account, you can ask for funds up to the allowed limit.

## Faucet instructions:

1\. In the FAQs section of [<mark style="color:blue;">faucet.deelance.com</mark>](https://faucet.deelance.com/), in the first point, click on the 'tweet' button.

2\. Twitter will automatically open with a pre-populated tweet. Replace the blank address: <mark style="color:blue;">0x0000000000000000000000000000000000000000</mark>, with your account address and post the tweet.

3\. Click on the tweet to visit its particular tweet URL.

4\. Copy the tweet URL.

5\. Paste the copied URL into the Deelance faucet page and request $Dee.

6\. A pop-up message will appear if the request is successful and some $Dee will arrive in your wallet shortly.


# Core Concepts


# Genesis File

The genesis file is a JSON-formatted document that establishes the primary state of a blockchain. It serves as the foundational block, positioned at height 0, of the blockchain structure. The subsequent block, at height 1, recognizes the genesis file as its predecessor.

The genesis file encapsulates various critical data points such as the initial token distribution, genesis timestamp, default configurations, and more. Here's a detailed breakdown:

### **Key Components:**

1. **chainId:**
   * For test-net: 455214 To ensure compatibility with third-party services familiar with Ethereum, it's advisable not to employ a network ID previously utilized in the Ethereum ecosystem.&#x20;
2. **period:**
   * Represents the minimum time interval between the timestamps of two consecutive blocks. Recommended setting is 3 seconds for testnet.
3. **epoch:**
   * Denotes the block count after which there's a checkpoint, followed by a reset of pending votes. Suggested value is 100 for the testnet.
4. **nonce:**
   * In the DeeLance Blockchain, the nonce represents a secure proof-of-work for mining, ensuring the computational effort made to ascertain this token value. Consistently set to 0x0 in the DeeLance chain.
5. **timestamp:**
   * Should always surpass the parent timestamp by at least one BLOCK\_PERIOD.
6. **extraData:**
   * EXTRA\_VANITY: Preserves a fixed count of prefix bytes in extra-data for signer vanity. Typically, 32 bytes are suggested.
   * Signer Info: Denotes the validator address.
   * EXTRA\_SEAL bytes: Fixed in number; this is the signature of the signer that seals the header.
7. **gasLimit:**
   * Represents the collective Gas limit for every block. Set high to prevent limitations during testing, although Gas consumption by Contracts remains a consideration. For the testnet, the GasCeil is set to 80000000.
8. **difficulty:**
   * Reflects the challenge encountered during nonce discovery for this block. Testnet recommendation is 0x1.
9. **mixHash:**
   * Reserved for potential fork safeguards, akin to the DAO's extra-data. During standard operations, this should be populated with zeros.
10. **coinbase:**

* A system-managed address designated for accumulating block rewards.

11. **number:**

* Indicates the block's height in the chain, with the genesis positioned at block 0.

12. **parentHash:**

* A 256-bit Keccak hash of the complete header of the preceding block (inclusive of its nonce and mixhash). This acts as a link to the parent block, facilitating the creation of the block chain. Exclusively for the Genesis block, it is set to 0.

13. **Account and Address:**

* The DeeLance Blockchain employs a methodology akin to Ethereum for key generation. It utilizes 256 bits of entropy to generate a 24-word mnemonic based on BIP39. This mnemonic, combined with an empty passphrase, produces a seed. This seed subsequently produces a master key, from which the private key is derived using BIP32/BIP44. The HD prefix "44'/60'/" remains consistent with Ethereum's derivation path.

***

By understanding the structure and purpose of each component within the genesis file, participants can gain insight into the foundational principles governing the DeeLance Blockchain.


# Consensus

Consensus algorithms play a fundamental role in distributed computing systems, ensuring that a group of nodes or participants can agree on a single, consistent state of the system despite network delays, node failures, and malicious actors. These algorithms are crucial in various applications, including blockchain technology, distributed databases, and many peer-to-peer networks. Below is a detailed description of consensus algorithms, including their types, key components, and applications.

1. **Definition of Consensus:**

Consensus is the process by which a group of participants in a distributed system agree on a common value or state. In the context of distributed computing, consensus algorithms ensure that all nodes in the system reach agreement on the same data, order of events, or state, even when some nodes are unreliable or adversarial.

2. **Key Components of Consensus Algorithms:**

To achieve consensus, consensus algorithms typically involve the following key components:

**Nodes (Participants):** These are individual entities in the distributed network responsible for participating in the consensus process. Nodes can be computers, servers, or devices connected over a network.

**Proposal:** A node initiates the consensus process by proposing a value or a set of values to be agreed upon. This proposal is broadcast to the network.

**Agreement:** Nodes communicate and collaborate to agree on a specific value or outcome. The agreement can take the form of a majority vote, validation by a specific node, or other mechanisms, depending on the consensus algorithm used.

**Termination:** The consensus process should eventually terminate, indicating that all participants have agreed on a common value.

3. **Types of Consensus Algorithms:**

There are several consensus algorithms, each designed to address different requirements and trade-offs. Some common types include:

**Proof of Work (PoW):** PoW, used in Bitcoin, requires participants (miners) to solve a computationally intensive puzzle to propose and validate blocks. It relies on the concept that the node that solves the puzzle first has the right to propose a block and add it to the blockchain.

**Proof of Stake (PoS):** PoS, used in Ethereum 2.0 and other blockchains, assigns block validation rights based on the amount of cryptocurrency (stake) held by a node. Nodes are chosen to propose and validate blocks in proportion to their stake.

**Delegated Proof of Stake (DPoS):** DPoS, used in networks like EOS and Tezos, introduces a small number of elected delegates who take turns validating blocks. This approach enhances scalability and efficiency.

Practical Byzantine Fault Tolerance (pBFT): pBFT, employed in systems like Hyperledger Fabric, is designed for permissioned networks. It ensures consensus through a series of communication rounds, with nodes voting on proposed transactions.

**Raft:** Raft is a consensus algorithm designed for simplicity and understandability. It's used in various distributed systems to elect a leader node and ensure data consistency.

**HoneyBadgerBFT:** A more recent consensus algorithm designed for asynchronous networks, HoneyBadgerBFT offers robust security and tolerates adversarial behavior.

4. **Applications of Consensus Algorithms:**

Consensus algorithms have a wide range of applications, including:

Blockchain Technology: Consensus algorithms form the backbone of blockchain networks, ensuring the agreement on the order and validity of transactions among nodes in a decentralized and trustless environment.

**Distributed Databases:** Distributed databases use consensus algorithms to maintain data consistency and replication across multiple nodes in a distributed data store.

**Cloud Computing:** Consensus algorithms are used in cloud computing environments to manage resource allocation, task scheduling, and load balancing.

**IoT Networks:** In Internet of Things (IoT) networks, consensus algorithms help devices make collective decisions and agree on shared data.

Finance and Cryptocurrencies: Consensus algorithms are vital in financial applications, such as stock exchanges and cryptocurrency platforms, to maintain transaction order and ensure fairness.

In conclusion, consensus algorithms are a critical component of distributed systems, ensuring that multiple nodes can agree on a single, consistent state despite the challenges posed by network issues and malicious actors. The choice of a consensus algorithm depends on the specific requirements and characteristics of the distributed system in question, with various algorithms offering different trade-offs in terms of security, scalability, and efficiency.


# Proof of Stake (Pos)

#### Proof of Stake (PoS) is a consensus algorithm used in blockchain networks. It relies on the concept of staking, where validators are chosen to create new blocks and validate transactions based on the amount of cryptocurrency they hold and are willing to "stake" as collateral.

Below are some mathematical formulations and notations related to Proof of Stake (PoS) in a blockchain: The probability of a validator being chosen to create a new block can be denoted as `P(Validator_i) = (Stake_i) / (∑ from (j=1) to (n) Stake_j)`

2. **Validator Set:**

The set of validators in the network can be represented as

```
-   \(V = \{Validator_1, Validator_2, \ldots, Validator_n\}\).
```

4. **Block Creation Probability:** The probability of a validator being chosen to create a new block within a specific time period

   ```
     P(CreateBlock_i) = (Stake_i) / (∑ from (j=1) to (n) Stake_j)
   ```
5. **Validation of Transactions:** The process of validating transactions by a selected validator can be represented as a function

   ```
     V(Validator_i, Transaction_j) = VerifySignature(Transaction_j)
   ```
6. **Consensus Rule:** The consensus rule for validating a new block and adding it to the blockchain can be described as a function

   ```
     C(Block_k) = ValidateBlock(Block_k)
   ```
7. **Blockchain State:** The overall state of the blockchain, including account balances and data stored, can be denoted as

   ```
   S = {Account_1: Balance_1, Account_2: Balance_2, ...}
   ```
8. **Epoch Length:** The duration of an epoch, a fixed time period during which validators take turns creating blocks and validating transactions, can be represented as

   ```
    Epoch Length: T_epoch
   ```
9. **Staking Parameters:** Parameters related to staking, such as the minimum stake required to become a validator

   ```
    Minimum Stake: S_min
    Staking Duration: T_stake
   ```

These mathematical formulations provide a basis for understanding and analyzing the Proof of Stake (PoS) consensus algorithm in blockchain networks. They help in formalizing the probabilistic nature of validator selection, block creation, and transaction validation within the PoS framework.


# Understanding pBFT

### Understanding the Practical Byzantine Fault Tolerance (pBFT) algorithm requires a grasp of the fundamental concepts and mechanisms that underlie this consensus protocol. pBFT is a Byzantine fault-tolerant algorithm designed for use in distributed systems, particularly in the context of blockchain technology. Here's a comprehensive explanation of the pBFT algorithm:

1. **Byzantine Fault Tolerance (BFT):**

pBFT falls under the broader category of Byzantine fault-tolerant algorithms, which aim to achieve consensus in distributed systems even in the presence of malicious nodes or Byzantine failures. Byzantine failures refer to nodes that may behave arbitrarily, including sending incorrect or conflicting information to disrupt the system. 2. Key Principles of pBFT:

Replica Nodes: In a pBFT network, there are typically multiple replica nodes responsible for validating and ordering transactions. Client-Server Model: The consensus process in pBFT follows a client-server model, where client nodes send transaction proposals to a set of replica nodes. 3. Phases of the pBFT Algorithm:

### **pBFT operates in several phases to reach consensus:**<br>

<figure><img src="/files/wYDMDTs8FfTbXKsEJNrj" alt=""><figcaption><p>PBFT consensus reaching process</p></figcaption></figure>

a. **Request:** A client initiates the consensus process by sending a transaction proposal to the network.<br>

{% hint style="info" %}
The Primary node (such as R0 in Fig.1) sends pre-prepare messages <\<PRE\_PREPARE，v，n，d>, m> to other Replica nodes (such as R1, R2, R3 shown in Fig. 1). V represents the view number, n is the serial number, d represents the message summary, and m represents the original message data.
{% endhint %}

Replica nodes receive pre-prepare messages and verify the following:

&#x20;      a. the legitimacy of the signature of m and whether d is compatible with m: d=hash(m)

&#x20;      b. if the node is currently in v

&#x20;      c. The node does not have other pre-prepare messages on the same page (view v ，sequence n). Namely, there isn’t another m’ and d’, where d’=hash(m’)

&#x20;     d. h<=n<=H, H and h represent the high and low thresholds of n.

After the verification is successfully done, Replica nodes send out the corresponding prepare messages\<PREPARE，v，n，d，i>. The i represents the identity of the Replica node.

b. **Pre-Prepare:** In this phase, the primary replica node receives the client's request and assigns it a unique sequence number. The primary then broadcasts this request, along with its sequence number, to the other replicas.

c. **Prepare:** Upon receiving the Pre-Prepare message, the non-primary replicas verify the request, check the primary's sequence number, and if everything is correct, they send Prepare messages to the rest of the network.

d. **Commit:** Once a replica has received a sufficient number of Prepare messages (usually a two-thirds majority), it sends a Commit message to indicate its agreement on the transaction's validity.

e. **Response:** After receiving Commit messages from a two-thirds majority of replicas, the client knows that the transaction is confirmed and sends a Response message to the network.

f. **Execute:** Finally, each replica executes the accepted transaction and updates its local state.

4. Fault Tolerance and Security:

pBFT is designed to tolerate up to (n-1)/3 Byzantine faulty nodes, where 'n' is the total number of nodes. It achieves security through redundancy, as a malicious node would need to compromise a significant portion of the network to subvert consensus. 5. Performance Considerations:

pBFT is known for its low latency and high throughput compared to traditional consensus algorithms like Proof of Work (PoW). However, it is typically used in permissioned or consortium blockchains due to its reliance on a fixed set of validating nodes. 6. Limitations:

pBFT's primary limitation is its scalability, as the number of validating nodes can be limited compared to more open consensus algorithms like PoW and PoS. It assumes that the majority of nodes are honest and that network conditions are reasonably reliable. 7. Use Cases:

pBFT is well-suited for private and permissioned blockchain networks where the validating nodes are known and trusted, such as in enterprise settings. In conclusion, the pBFT algorithm is a robust Byzantine fault-tolerant consensus protocol that ensures agreement among distributed nodes in a network, even in the presence of malicious actors. Its key principles, phases, and fault tolerance mechanisms make it a valuable choice for blockchain networks that prioritize low latency, security, and a known set of validating nodes. Understanding pBFT is essential for those interested in designing or working with blockchain systems that require strong consensus guarantees.


# Research&#x20;

### &#x20;Previous research on Practical Byzantine Fault Tolerance (pBFT) in blockchain has contributed significantly to the understanding of this consensus algorithm's strengths, weaknesses, and real-world applications. Below, I'll provide an overview of some key findings and research topics related to pBFT in blockchain:

1. **Performance Evaluation:** Various research studies have focused on benchmarking pBFT in terms of its throughput, latency, and scalability. These evaluations often compare pBFT to other consensus algorithms like PoW and PoS. Researchers have investigated the impact of network latency, node distribution, and the number of validating nodes on pBFT's performance.
2. **Fault Tolerance and Security:** Studies have examined pBFT's ability to withstand various types of faults, including Byzantine faults, node failures, and network partitions. Researchers have analyzed the security properties of pBFT, including its resistance to malicious nodes and its fault tolerance guarantees.
3. **Practical Implementations:** Research has explored the practical implementation of pBFT in different blockchain platforms, including Hyperledger Fabric, Tendermint, and Quorum. Studies have investigated the ease of deployment and configuration of pBFT in permissioned and consortium blockchains.
4. **Scalability Challenges:** Scalability is a critical concern in blockchain networks. Research has delved into pBFT's limitations regarding the number of validating nodes and transaction throughput. Solutions and enhancements to improve pBFT's scalability while maintaining its security guarantees have been proposed.
5. **Hybrid Consensus Models:** Some research has explored hybrid consensus models that combine pBFT with other consensus algorithms like PoW or PoS to leverage the strengths of each for different aspects of blockchain operation. These studies aim to balance security, decentralization, and scalability.
6. **Attack Vectors and Mitigations:** Research has identified potential attack vectors and vulnerabilities specific to pBFT-based blockchains, such as Sybil attacks and denial-of-service attacks. Countermeasures and mitigation strategies to protect pBFT-based systems from such attacks have been proposed and analyzed.
7. **Use Cases and Applications:** Studies have examined real-world use cases and applications of pBFT-based blockchains, particularly in enterprise and consortium settings. Research has explored the suitability of pBFT for applications beyond cryptocurrencies, such as supply chain management and healthcare.
8. **Privacy and Confidentiality:** Privacy and confidentiality in pBFT-based blockchains have been a research focus. Researchers have investigated techniques for protecting sensitive data while maintaining transparency and integrity.
9. **Governance and Decision-Making:** Some research has looked into the governance mechanisms of pBFT-based networks, exploring how consensus decisions are made, node incentives, and protocol upgrades.
10. **Future Directions:** - Many research papers conclude with recommendations for future research directions, highlighting areas where further investigation is needed to enhance the understanding and practicality of pBFT in blockchain systems. In summary, previous research on pBFT in blockchain has contributed to a deeper understanding of this consensus algorithm's capabilities and limitations. It has explored various aspects, from performance and security to real-world applications, scalability challenges, and hybrid models. This body of research has played a crucial role in advancing the field of blockchain consensus mechanisms.\
    \
    References

    [http://pmg.csail.mit.edu/papers/osdi99.pdf](https://links.jianshu.com/go?to=http%3A%2F%2Fpmg.csail.mit.edu%2Fpapers%2Fosdi99.pdf)\
    [https://www.comp.nus.edu.sg/\~rahul/allfiles/cs6234-16-pbft.pdf](https://links.jianshu.com/go?to=https%3A%2F%2Fwww.comp.nus.edu.sg%2F%7Erahul%2Fallfiles%2Fcs6234-16-pbft.pdf)


# Scalability&#x20;

#### Scalability and throughput are critical aspects of any blockchain network, including those using Proof of Stake (PoS) and Practical Byzantine Fault Tolerance (pBFT) consensus algorithms. Let's explore how these two consensus mechanisms handle scalability and throughput:

Scalability in PoS and pBFT Blockchains:

1. **Proof of Stake (PoS):**

PoS blockchains aim to improve scalability by reducing the resource-intensive nature of Proof of Work (PoW) consensus. In PoS, validators are chosen to create new blocks and validate transactions based on the amount of cryptocurrency they hold and are willing to "stake" as collateral. Scalability benefits in PoS arise from the fact that there is no need for computationally expensive mining, as seen in PoW. This means that PoS networks can process transactions more efficiently and with less energy consumption. However, PoS scalability still faces some challenges. The number of validators may be limited, and as the network grows, consensus may require the coordination of a larger number of nodes. This can lead to centralization concerns as more significant stakeholders have a higher chance of becoming validators. 2. Practical Byzantine Fault Tolerance (pBFT):

pBFT is designed for permissioned or consortium blockchains where the number of validating nodes is known and typically smaller than in open, public blockchains. pBFT provides high scalability due to its fixed set of validators. The consensus process in pBFT involves a series of communication rounds, typically three or four, which allows for quick agreement on transactions. pBFT's scalability is particularly useful in enterprise and consortium settings, where transaction throughput and low confirmation times are crucial. It is well-suited for private networks with a limited number of known, trusted participants. Throughput in PoS and pBFT Blockchains:

Proof of Stake (PoS):

PoS blockchains often exhibit higher throughput compared to PoW networks due to their efficient consensus mechanism. The absence of mining and the selection of validators based on stake can result in faster transaction processing. Faster block confirmation times contribute to higher throughput in PoS blockchains. This makes PoS suitable for applications that require quick settlement of transactions, such as financial services. 2. Practical Byzantine Fault Tolerance (pBFT):

pBFT blockchains are known for their excellent throughput. Since consensus is achieved through a series of communication rounds with a fixed set of validators, the network can process transactions quickly. In pBFT, a block is confirmed once a two-thirds majority of validators reach consensus. This results in low latency and high transaction throughput. The high throughput and low confirmation times in pBFT make it suitable for applications like supply chain management, where real-time data processing is essential. In summary, both PoS and pBFT consensus algorithms offer scalability benefits compared to traditional PoW-based blockchains. PoS achieves scalability through its resource-efficient validation process, while pBFT achieves scalability by utilizing a fixed set of validators and fast consensus rounds. These characteristics make both consensus algorithms suitable for various blockchain applications with different scalability and throughput requirements. The choice between PoS and pBFT depends on the specific use case and network design considerations.


# Developer Guide


# RPC

### RPC Endpoints

DeeLance RPC Endpoints (ChainID 455214):

* <https://testnet-rpc.deelance.com/>


# DeeLance Testnet

### What is the purpose of a Testnet?

A testnet (short for "test network") is an environment in which developers can test and experiment with new features and software without affecting the main network (mainnet). Testnets are parallel systems with their own native cryptocurrencies, which hold no real-world value, allowing for risk-free experimentation.

The validators on the testnet are mainly from the development team.

### What are the benefits of using the Deelance Testnet?

* **Setting Up and Exploring:**\
  Create your own test address and procure DeeLance testnet funds.
* **Safe Development and Testing:**\
  Build apps and walk through tutorials on DeeLance without risking real assets.
* **Stay Updated:**\
  Evaluate your applications against the latest DeeLance versions.
* **Data Analysis:**\
  Assess blockchain data on a concise, yet meaningful dataset distinct from the main network.

### How to get Testnet Funds? <a href="#how-to-get-testnet-fund" id="how-to-get-testnet-fund"></a>

The faucet dedicated to the DeeLance Testnet can be found [here](https://faucet.deelance.com/).

### DeeLance Testnet Explorers

* Deelance Explorer - <https://testnet.deelance.com/>

### RPC Endpoints

DeeLance RPC Endpoints (ChainID 455214):

* <https://testnet-rpc.deelance.com/>


# Deelance Explorers

The DeeLance explorer provides a visual interface for users to explore the blockchain, showcasing blocks, transactions, wallet balances, and DeeLance token details.

**DeeLance currently offers an explorer for its testnet, with the mainnet explorer set to be available soon.**

### Explorers for Mainnet <a href="#explorers-for-mainnet" id="explorers-for-mainnet"></a>

coming soon...

### Explorers for Testnet <a href="#explorers-for-mainnet" id="explorers-for-mainnet"></a>

* Deelance Explorer - <https://testnet.deelance.com/>


# Deploy Smart Contract

Launch the DEE20 token on the Deelance Testnet utilizing cutting-edge technologies.

{% hint style="info" %}
Read our tutorial on deploying the DEE20 Token to the Deelance Testnet.
{% endhint %}

[Using Remix IDE](/getting-started/developer-guide/deploy-smart-contract/using-remix-ide)

[Using Truffle](/getting-started/developer-guide/deploy-smart-contract/using-truffle)

[Using Hardhat](/getting-started/developer-guide/deploy-smart-contract/using-hardhat)


# Using Remix IDE

Setting up and launching a DRC20 Token Smart Contract on the Deelance Testnet using Remix IDE.

### What is Remix IDE ?

Remix IDE is an open-source web and desktop application that aids in smart contract development, written in Solidity language for the Ethereum blockchain. It provides a range of tools that help developers write, test, debug, and deploy smart contracts with ease. Some notable features of Remix IDE include.

### Prerequisites

1. Add Deelance Testnet in your MetaMask, to add refer to our guide [Add DeeLance to Metamask](/getting-started/add-deelance-to-metamask)
2. Get Deelance Testnet coins from the [Deelance Faucet](https://faucet.deelance.com/).

### Creating and Deploying DRC20 Token on Remix IDE

* Visit <https://remix.ethereum.org/>&#x20;

you'll be greeted with the following screen.

<figure><img src="/files/KAjE3LWm1tsLmjDiFk5M" alt=""><figcaption></figcaption></figure>

* Click on the icon mentioned below to generate a new file called `PepeDeelance.sol`.

<figure><img src="/files/ZQhwrkTo13yHVYVs7DuZ" alt=""><figcaption></figcaption></figure>

An empty file will appear as shown below.

<figure><img src="/files/2FrRDTAT9iQbdrUpCUNa" alt=""><figcaption></figcaption></figure>

* Copy the following code and insert it into `PepeDeelance.sol`.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract PepeDeelance is ERC20, Ownable {
    constructor() ERC20("PepeDeelance", "PEPEDLANCE") {
        _mint(msg.sender, 1000000000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}
```

* Now, click on the specified icon to compile your contract.

<figure><img src="/files/qOVU27OjCh564R3Lpjya" alt=""><figcaption></figcaption></figure>

* Next, press the "Compile" button to compile your contract, ensuring you select the checkbox highlighted within the blue circle.

<figure><img src="/files/i5BdKPQig7C3k8GoTkik" alt=""><figcaption></figcaption></figure>

* To deploy your contract, click on the indicated button below.

<figure><img src="/files/2lwRSKLLwngbeZS2pnGA" alt=""><figcaption></figcaption></figure>

* Now, select the "Remix VM...." dropdown, and then choose the "Injected Provider" highlighted in orange.

<figure><img src="/files/etOOEiAttqAfALGD6g7n" alt=""><figcaption></figcaption></figure>

After making that selection, MetaMask will prompt you to unlock your wallet. If you're already logged into MetaMask, you'll see a display similar to the one below.&#x20;

<figure><img src="/files/6gIsQJXiiEF3D3mpRiOb" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Ensure that you're connected to the DLANCE TESTNET, which carries a chain ID of 455214.
{% endhint %}

* To finalize the deployment of your DRC20 Smart Contract on the Deelance Testnet, press the "Deploy" button highlighted in orange, as shown below.

<figure><img src="/files/Q9qsAxNwp28icsQJ2HyS" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Ensure you have enough Deelance Testnet Tokens to cover the gas fees for the transaction. If you need Testnet Deelance tokens, visit the [Deelance Faucet](https://faucet.deelance.com/).
{% endhint %}

{% hint style="info" %}
If you haven't added the Deelance Testnet in your MetaMask, refer to our guide [Add DeeLance to Metamask](/getting-started/add-deelance-to-metamask)
{% endhint %}

After clicking the "Deploy" button, MetaMask will pop up prompting you to approve the transaction. Once you confirm, your contract will deploy within a few seconds, and you'll be able to view your deployed contract here.&#x20;

<figure><img src="/files/29ScOtceKhN4l7H4ksxt" alt=""><figcaption></figcaption></figure>

**Well done!** You've successfully created and launched the DRC20 token on the Deelance Testnet.


# Using Truffle

Setting up and launching anDRC20 Token Smart Contract on the Deelance Testnet using Truffle.

## Using Truffle

### What is Truffle ?

Truffle is a development framework and suite of tools primarily used for building, deploying, and managing smart contracts and decentralized applications (DApps) on blockchain platforms. It provides developers with a set of utilities and commands to streamline the development process and make it easier to work with blockchain technologies.

### Configuring the Development Workspace

Before we dive in, ensure you have the following essentials installed: Requirements:

* Windows, Linux or Mac OS X
* [Node.js v8.9.4 LTS or later](https://nodejs.org/en/)

### Installing Truffle

After we've set up those tools, we just need a single command to get Truffle:

```
npm install -g truffle
```

Let's ensure Truffle is correctly installed. Open your terminal and type `truffle version`. If some error shows up, make sure your computer knows where to find the npm modules.

### Create a Project <a href="#create-a-project" id="create-a-project"></a>

Our first task is to set up a Truffle project. We'll use `TokenDeelance.sol` as our guide, demonstrating how to create a token that can be shared between accounts:

* Create a new directory for your Truffle project

```
mkdir PepeDeelance
cd PepeDeelance
```

* Initialize your project:

```
truffle init
```

After completing this step, you'll have a project organized with these folders:

* contracts/: Directory for Solidity contracts
* migrations/: Directory for scriptable deployment files
* test/: Directory for test files for testing your application and contracts
* truffle-config.js: Truffle configuration file

### Create Contract <a href="#create-contract" id="create-contract"></a>

* Create a `PepeDeelance.sol` file within the `contracts/:` directory.
* Copy the below code and place it into the `PepeDeelance.sol` file:

{% code title="PepeDeelance.sol" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract PepeDeelance is ERC20, Ownable {
    constructor() ERC20("PepeDeelance", "PEPEDLANCE") {
        _mint(msg.sender, 1000000000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}
```

{% endcode %}

{% hint style="info" %}
Ensure you have the [`@openzeppelin/contracts`](https://www.npmjs.com/package/@openzeppelin/contracts) package since our Solidity code relies on it. To get it, execute: `npm i @openzeppelin/contracts` in terminal.
{% endhint %}

&#x20;

* Create a `1_deploy_contracts.js` file within the `migrations/:` directory and insert the following code:

{% code title="1\_deploy\_contracts.js" %}

```javascript
const PepeDeelance = artifacts.require("PepeDeelance");

module.exports = function (deployer) {
  deployer.deploy(PepeDeelance);
};

```

{% endcode %}

* Next, paste the following code into your `truffle-config.js` file:

{% code title="truffle-config.js" %}

```javascript
const HDWalletProvider = require("@truffle/hdwallet-provider");

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 9545,
      network_id: "*",
    },
    testnet: {
      provider: () =>
        new HDWalletProvider(
          "<YOUR_WALLET_PRIVATE_KEY>",
          `https://testnet-rpc.deelance.com`
        ),
      network_id: 455214,
      confirmations: 10,
      timeoutBlocks: 200,
      skipDryRun: true,
    },
  },

  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      version: "0.8.0", // A version or constraint - Ex. "^0.5.0"
    },
  },
};

```

{% endcode %}

{% hint style="info" %}
Ensure you replace `<YOUR_WALLET_PRIVATE_KEY>` with the actual private key of your wallet.
{% endhint %}

{% hint style="info" %}
Ensure you've set up [@truffle/hdwallet-provider](https://www.npmjs.com/package/@truffle/hdwallet-provider), as mentioned in the file. To get this package, type `npm i @truffle/hdwallet-provider` in your terminal.
{% endhint %}

* #### Compile Contract <a href="#compile-contract" id="compile-contract"></a>

To compile your Truffle project, execute the following command:

```
truffle compile
```

### Deploying DRC20 Contract on Deelance Network <a href="#compile-contract" id="compile-contract"></a>

Execute the given command at the base of the project folder:

```
truffle migrate --network testnet
```

The contract will deploy on the Deelance Testnet and will appear in your terminal as follows:

```bash
1_deploy_contracts.js
=====================

   Deploying 'PepeDeelance'
   ------------------------
   > transaction hash:    0x42a4fe45d66cdc7648d9a8607f4f8c0044946074c1bf07963cf501bf14a8f493
   > Blocks: 2            Seconds: 8
   > contract address:    0xE6D82514Fe6A796D947b5580Fc26090Dd818412e
   > block number:        37296
   > block timestamp:     1692550864
   > account:             0x2bd250B5e8eEeB4e0E9fC6023f525Ac62b72c0ae
   > balance:             9.984142327455598517
   > gas used:            1491671 (0x16c2d7)
   > gas price:           2.500000007 gwei
   > value sent:          0 ETH
   > total cost:          0.003729177510441697 ETH

   Pausing for 10 confirmations...

   --------------------------------
   > confirmation number: 1 (block: 37297)
   > confirmation number: 2 (block: 37298)
   > confirmation number: 3 (block: 37299)
   > confirmation number: 4 (block: 37300)
   > confirmation number: 5 (block: 37301)
   > confirmation number: 6 (block: 37302)
   > confirmation number: 7 (block: 37303)
   > confirmation number: 8 (block: 37304)
   > confirmation number: 9 (block: 37305)
   > confirmation number: 10 (block: 37306)
   > Saving artifacts
   -------------------------------------
   > Total cost:     0.003729177510441697 ETH

Summary
=======
> Total deployments:   1
> Final cost:          0.003729177510441697 ETH
```

> Keep in mind that your address, transaction\_hash, and other details will vary. The information above is simply to give you a sense of the format.

Well done! You've successfully launched the DRC20 Smart Contract on Deelance Network. You can now engage with the Smart Contract.


# Using Hardhat

Setting up and launching an DRC20 Token Smart Contract on the Deelance Testnet using Hardhat.

## Using Hardhat

### What is Hardhat ?

Hardhat is a popular development framework and tool suite designed for building, testing, and deploying smart contracts and decentralized applications (DApps) on blockchain platforms. Like Truffle, Hardhat streamlines the development process and provides a range of features to aid developers in working with blockchain technologies.

### Configuring the Development Workspace

Before we dive in, ensure you have the following essentials installed: Requirements:

* Windows, Linux or Mac OS X
* [Node.js v8.9.4 LTS or later](https://nodejs.org/en/)

### Initialize Project <a href="#create-a-project" id="create-a-project"></a>

Our first task is to set up a Hardhat project.

* Create a new directory for your Hardhat project

```bash
mkdir PepeDeelance
cd PepeDeelance
```

* Next, execute `npm init -y` to generate a package.json file.
* Afterward, install Hardhat with the following command:

```bash
npm install --save-dev hardhat
```

Now, If you run `npx hardhat`, you will be shown some options to facilitate project creation:

```
$ npx hardhat
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

Welcome to Hardhat v2.17.1

? What do you want to do? …
▸ Create a JavaScript project
  Create a TypeScript project
  Create an empty hardhat.config.js
  Quit
```

We recommend selecting the option "Create a JavaScript project."

After selecting the `"Create a JavaScript project"` option, you will be prompted to install the following dependencies.

```
npm install --save-dev "hardhat@^2.17.1" "@nomicfoundation/hardhat-toolbox@^3.0.0"
```

Finally, the Hardhat project is initialized.

To initially familiarize yourself with the available features and the current status, execute `npx hardhat` within your project directory. This will produce the following output in the terminal:

```
$ npx hardhat
Hardhat version 2.17.1

Usage: hardhat [GLOBAL OPTIONS] <TASK> [TASK OPTIONS]

GLOBAL OPTIONS:

  --config              A Hardhat config file.
  --emoji               Use emoji in messages.
  --flamegraph          Generate a flamegraph of your Hardhat tasks
  --help                Shows this message, or a task's help if its name is provided
  --max-memory          The maximum amount of memory that Hardhat can use.
  --network             The network to connect to.
  --show-stack-traces   Show stack traces (always enabled on CI servers).
  --tsconfig            A TypeScript config file.
  --typecheck           Enable TypeScript type-checking of your scripts/tests
  --verbose             Enables Hardhat verbose logging
  --version             Shows hardhat's version.


AVAILABLE TASKS:

  check                 Check whatever you need
  clean                 Clears the cache and deletes all artifacts
  compile               Compiles the entire project, building all artifacts
  console               Opens a hardhat console
  coverage              Generates a code coverage report for tests
  flatten               Flattens and prints contracts and their dependencies. If no file is passed, all the contracts in the project will be flattened.
  gas-reporter:merge
  help                  Prints this message
  node                  Starts a JSON-RPC server on top of Hardhat Network
  run                   Runs a user-defined script after compiling the project
  test                  Runs mocha tests
  typechain             Generate Typechain typings for compiled contracts
  verify                Verifies a contract on Etherscan

To get help for a specific task run: npx hardhat help [task]
```

The things you can do are shown in a list. Some are already there, and some come when you add extra tools/packages. [Learn More](https://hardhat.org/hardhat-runner/docs/getting-started#quick-start).

After initialization, your Hardhat project's folder structure will look like this.

```
project-root/
├── hardhat.config.js
├── contracts/
│   └── YourContract.sol
├── scripts/
│   └── yourScript.js
├── test/
│   └── yourTest.js
├── node_modules/
├── package.json
├── package-lock.json
└── .gitignore
```

### Create an DRC20 Token Contract on Deelance Testnet using Hardhat.&#x20;

* Make a file named "PepeDeelance.sol" in the "contracts/" folder of your project.
* Copy and paste the code provided below.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract PepeDeelance is ERC20, Ownable {
    constructor() ERC20("PepeDeelance", "PEPEDLANCE") {
        _mint(msg.sender, 1000000000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}
```

{% hint style="info" %}
Ensure you have the [`@openzeppelin/contracts`](https://www.npmjs.com/package/@openzeppelin/contracts) package since our Solidity code relies on it. To get it, execute: `npm i @openzeppelin/contracts` in terminal.
{% endhint %}

* Now, in your terminal, run the command `npx hardhat compile` , This will compile the contracts located in the "contracts/" folder.
* Once the contract compiles without errors, generate a `deploy.js` file within the `scripts/` directory and insert the following code:

```javascript
const hre = require("hardhat");

async function main() {
  console.log("Deploying Contract....");

  const PepeDeelanceFactory = await hre.ethers.getContractFactory(
    "PepeDeelance"
  );
  const PepeDeelance = await PepeDeelanceFactory.deploy();

  console.log("waiting for Transaction Confirmations");
  const res = await PepeDeelance.deploymentTransaction().wait(2);

  console.log(`==============================`);
  console.log(`Contract Deployed : ${res.contractAddress}`);
  console.log(`Transaction Hash : ${res.hash}`);
  console.log(`Gas Used : ${res.gasUsed}`);
  console.log(`Gas Price : ${res.gasPrice}`);
  console.log(`==============================`);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

```

* Next, copy the following code into the `hardhat.config.js` file.

```javascript
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.19",
  networks: {
    deelanceTestnet: {
      url: "https://testnet-rpc.deelance.com/",
      chainId: 455214,
      accounts: ["<PRIVATE_KEY>"],
    },
  },
};
```

{% hint style="info" %}
Ensure you replace `<`PRIVATE\_KEY`>` with the actual private key of your Wallet, essential for executing transactions.
{% endhint %}

### Deploying on Deelance Testnet

* We're now set to deploy our Smart Contract on the Deelance Testnet. To proceed with the deployment, execute the following command in your terminal:

```
npx hardhat run --network deelanceTestnet scripts/deploy.js
```

Executing this will produce an output in the terminal similar to the following:

```bash
$ npx hardhat run --network deelanceTestnet scripts/deploy.js
Deploying Contract....
waiting for Transaction Confirmations
==============================
Contract Deployed : 0xFe52162DCe322Ba797FB0329b2a9409CCe29Eb32
Transaction Hash : 0xffc881d291732891006fbda071cdeF124d1a6E139bc30550daf36453411eb9bd
Gas Used : 1518972
Gas Price : 7
==============================
```

> Keep in mind that your address, transaction\_hash, and other details might vary. The above is merely an illustration of the expected structure.

**Well done!** You've successfully deployed the PepeDeelance DRC20 Token Smart Contract. You can now engage with the Smart Contract.


# Dive Into DeeLance Move!

Explore DeeLance blockchain and get involved in enhancing and fostering its growth.

## **Contribute to DeeLance**

1. **Submit improve Documentation:**\
   If you spot any mistakes or see potential improvements, kindly submit a pull request (PR) [here](https://github.com/Deelance/Deelance-Testnet).
2. **Share Improvement Proposal to DeeLance:** \
   The primary aim is to gather technical insights.
3. **Contribute in the form of an Article:** \
   Help in onboarding new developers by crafting tutorials or comprehensive guides.
4. **Become a Representative of DeeLance:** \
   Host Ask Me Anything (AMA) sessions, and enlighten developers and the community through educational initiatives.

<br>


# Overview

Deelance  Chain operates on a Proof-of-Staked-Authority (PoSA) blockchain, with the staking mechanism proposed in [BEP-294](https://github.com/bnb-chain/BEPs/pull/294). This enables DEE holders to stake their tokens with specified validators to secure the network and earn staking rewards. Here's an overview covering the core staking concepts and operations on Deelance chain.

### Basic Concepts

#### Consensus Engine

Deelance Chain uses a consensus mechanism which combines DPoS and PoA for consensus, in this system:

* Blocks are produced by a limited set of validators.
* Validators take turns to produce blocks in a PoA manner.
* Validator set are elected in and out based on a staking based governance.

The staking mechanism is essential for determining the eligibility of validators to produce blocks.

#### Validator Set

The validator set is the group of nodes that are responsible for validating transactions and producing blocks on the Deelance Chain. The validator set is determined by the amount of staking each validator has, which reflects the amount of DEE staked by the validator and its delegators. The top validators with the most staking are selected as the active validator set, and they take turns to propose and vote on blocks. The rest of the validators are in the standby validator set, and they can join the active validator set if their staking increases or if some active validators drop out.

Any organization or individual can become part of the validator set by creating their validator on-chain and securing sufficient delegations. Similarly, they can opt-out by simply withdrawing all their DEE delegations.

Validators can also be removed from the validator set by slashing, which is a penalty for misbehaving or being offline.

#### Validator Election

There are different roles for validators:

* Cabinet: the top K (which is 21 currently) validators who get the most chance of producing blocks.
* Candidate: the top (K, K+NumOfCandidates] (which is (21,45] currently) validators who get a small chance of producing blocks.
* Inactive: the reset validators who get no chance of producing blocks.

<figure><img src="/files/NKs2BiaDKWXjGLBdam2Z" alt=""><figcaption></figcaption></figure>

The validator set roles are determined every 24 hours based on the latest staking information.

After UTC 00:00, the consensus engine sorts validators and updates the Deelance Chain validator set with the ranking information.

### System Contracts

There are several built-in contracts (i.e., system contracts) to facilitate the Deelance Chain staking.

* Validator Set Contract. The contract periodically elects a validator set. The contract also serves as a vault for temporarily storing validator rewards.
* System Reward Contract. This contract acts as a vault to collect part of transaction fees. The funds are used for various public purposes, like distributing fast finality rewards.
* Slash Contract. This contract is used to keep track of the number of times a validator becomes unavailable and triggers penalties once a certain threshold is reached. Additionally, this contract also handles other types of slash events, such as double signing and malicious voting in fast finality.
* Stake Hub Contract. This contract serves as the entrypoint for managing validators and delegations, while also implementing the logic for slashing specific validators. For delegation/undelegation/redelegation operations, it will call different validators' implementation contracts to manage a user's stake.

### Credit Contract

Each validator has its own validator contract that manages staking credit and facilitates the exchange between credit and DEE. The token name of a staking credit is "stake {{validator moniker}} credit", and the symbol is "st{{validator moniker}}". The contract will be created by the Stake Hub Contract when a validator is created.

Whenever a user delegates DEE, an equivalent quantity of credit tokens are created. On the other hand, when a user withdraws their delegation, a corresponding amount of credit tokens are destroyed, thereby releasing the DEE.

### Reward Distribution

The staking reward comes from transaction fee - when a block is produced, the majority of the block fee will be collected as reward for the validator who proposed the block.

Every day, a portion of the rewards collected will be directly sent to the operator account of the validator as commission, while the remaining portion will be sent to the corresponding validator credit contract. And when a user undelegates and claims his/her stakes, the accumulated reward and the original stake will be sent back to him/her.

### Validator Operations

Validators are nodes running DEE Smart Chain software, participating in the consensus process. They require a minimum DEE stake at their validator address and can receive delegations from other DEE holders. Validators earn rewards from transaction fees and share most of these rewards with their delegators.

### Create Validator

To ensure the security of the network, becoming a validator on the Deelance Chain requires a minimum self-delegation of 2000 DEE. DEE holders can initiate a `CreateValidator` transaction with the `StakeHub` contract to become a validator. For more information, refer to Create Deelance Chain Validator.

### Edit Validator

Validators can update their information using transactions like `EditConsensusAddress`, `EditCommissionRate`, `EditDescription`, and `EditVoteAddress`.

### Delegator Operations

Delegators are DEE holders who stake their DEE with a validator, sharing rewards. They can select any active or standby validator, switch between them, undelegate their DEE, and claim rewards anytime. Users can refer to the user guide for instructions on these actions.


# User Guide

Coming soon...


# Overview

## Deelance Blockchain: The Freelance Revolution

In the expansive realm of digital freelancing, where traditional platforms have often grappled with issues like intermediary fees, delayed payments, and transparency, DeeLance Blockchain emerges as a breath of fresh air.

DeeLance Blockchain isn't just another platform; it's a revolution for freelancers. Grounded in the principles of decentralization, DeeLance aspires to realign the power dynamics of the freelancing industry. By leveraging blockchain technology, it ensures that intermediaries are eliminated, reducing unnecessary fees and ensuring faster, more secure payments for freelancers.

#### Key Features and Advantages

1. **Ethereum Virtual Machine (EVM) Compatibility:** Deelance chain is fully compatible with the Ethereum Virtual Machine (EVM), enabling developers to port their Ethereum-based DApps and DeFi projects to Deelance chain with minimal modifications. This compatibility extends to the use of popular Ethereum tools and applications, such as MetaMask, Truffle, and Remix.
2. **Low Transaction Fees and Fast Block Times:** One of  primary advantages is its low transaction fees. Deelance Chain block time of approximately is 3 seconds, ensuring rapid transaction confirmations and an overall smoother user experience.
3. **Robust Ecosystem and Growing Adoption**

### Role Of Dee

DEE is the native utility token of Deelance Chain. Within the Deelance ecosystem, DEE is used for various purposes:

* **Transaction Fees:** DEE is used to pay for transaction fees on Deelance Chain, offering users a cost-effective way to interact with the network.
* **Staking:** Users can stake DEE to become validators or delegate their DEE to validators to earn rewards, contributing to the network's security and decentralization.
* **Governance:** DEE holders can participate in on-chain governance, voting on proposals that influence the future development and upgrades of the network.


# Run validator

## Run Deelance Validator

### Validator Hardware Requirements

#### Mainnet

* Instance Spec: Suggest r7a.4xlarge instance type on AWS.
* Memory: 64 GB
* Disk: **IMPORTANT** 4T GB, solid-state drive(SSD), gp3, 8k IOPS, 500 MB/S throughput, read latency <1ms (if start with snap sync, it will need NVMe SSD).
* Network Bandwidth: > 10 Gbps

#### Testnet

* CPU: "AMD Gen 3 or newer" or "Intel Ice Lake or newer"
* Memory: 16 GB
* Disk: 1.5 TB, solid-state drive(SSD), gp3, 8k IOPS, 250 MB/S throughput.
* Network Bandwidth: > 2.5 Gbps

### Setup Validator Node

#### 1. Install Deelance Fullnode

Follow the instructions here to set up a full node.

#### 2. Prepare Accounts

Two accounts require preparation before running a validator: the Consensus account and the BLS Vote account. Ensure these accounts match the corresponding ones when creating a new validator.

**Generate Consensus Address**

To create a new mining consensus account, run this command and set a password for the account:

```shell
geth account new --datadir ${DATA_DIR}
```

* `DATA_DIR`: Where your key store files are saved.

If you already have a consensus account, skip this step. Save the password in a file named password.txt:

```shell
echo {your-password for the consensus account} > password.txt
```

**Generate BLS Vote Address**

To set up a new BLS account, use this command:

```shell
geth bls account new --datadir ${DATA_DIR}
```

* `DATA_DIR`: The directory to store your key store files.

If you already have a BLS vote key, you can create a BLS wallet and recover it with the keyfile using:

```shell
geth bls account import ${KEY_FILE} --datadir ${DATA_DIR}
```

To retrieve your bls address, run:

```shell
geth bls account list --datadir ${DATA_DIR}
```

Save the password in a file named blspassword.txt:

```shell
echo {your-password for the BLS wallet} > blspassword.txt
```

#### 3. Start Validator Node

> Warning: Please do not expose your RPC endpoints to public network!

Start your validator using the command line below:

```bash
geth --config ./config.toml --datadir ./node --syncmode snap -unlock {accounts to sign txs, including your mining account at least} --miner.etherbase {the address of your mining account} --password password.txt --blspassword blspassword.txt --mine --vote --allow-insecure-unlock --cache 18000
```

### Post Running

#### 1. Update validator profile

You can submit a PullRequest to this repository to update your information: <https://github.com/bnb-chain/validator-directory>

#### 2. Publish Validator Information

Please submit a Pull Request to this repo <https://github.com/Deelance-Organization/dee-validator-directory>

This repository is a place for validator candidates to give potential delegators a brief introduction about your team and infrastructure, and present your ecosystem contributions.

#### 3. Stop Validating

You can stop mining new blocks by sending commands in **geth console**

Connect to your validator node with **geth attach ipc:path/to/geth.ipc**

```bash
miner.stop()
```

To resume validating,

```bash
miner.start()
```


# Create Validator

## Create Deelance Validator

This guide outlines the process for creating a new validator on the Deelance Chain. The DEE staking dApp is the official tool for creating and managing validators on the Deelance Chain.

* **Mainnet**: <https://staking.deelance.org/en/>

### Terminology

* **Operator Address**: The address for creating and modifying validator information on the Deelance Chain. You should use this address when connecting to the staking dApp. The corresponding account should have more than 2001 BNB for creating validtors and paying transaction fees.
* **Consensus Address**: A unique address for your validator's node. It is used for consensus engine when mining new blocks. It should be different from the operator address.
* **BLS Vote Address**: A BLS address used for fast finality voting.
* **BLS Proof**: A BLS signature verifying ownership of the vote address.
* **Identity**: For associating a new validator with an existing one. This is optional unless you're migrating an old validator.

### Steps

#### 1. Connecting to the dApp

Please connect to the staking dApp using your **Operator Address**. `Trust Wallet`, `MetaMask`, and `WalletConnect` options are available for the step. Make sure that the account has more than 2001 BNB before moving on to the next step.

<figure><img src="/files/jD399HH3tfj9F51mIAvH" alt=""><figcaption><p>Connecting wallet</p></figcaption></figure>

#### 2. Filling out the form

Navigate to the dApp and select the `Become a Validator` button in the right middle of the page to initiate the creation process.

The following information is required to create a validator.

**2.1 Basic Information**

<figure><img src="/files/XhOCdK4o2mb9VNh0Cqb3" alt=""><figcaption><p>Basic information </p></figcaption></figure>

\
You'll need to provide the following details on the `Create Validator` page:

* **Validator Name**: Choose a name consisting of 3-9 alphanumeric characters, excluding special characters.
* **Website**: Provide a URL to a website with additional information about your validator.
* **Description**: A brief description of your validator.

To enhance your validator's visibility, consider uploading additional information to the [Deelance Chain validator directory](https://github.com/https://github.com/Deelance-Organization/dee-validator-directory). Your avatar, once uploaded, will be displayed in the staking dApp.

**2.2 Addresses**

<figure><img src="/files/gYS6Su2NRp67iqcqV35y" alt=""><figcaption><p>Addresses fields</p></figcaption></figure>

The following addresses are required:

* **Consensus Address**: A unique address for your validator's node.
* **Vote Address**: An address used for fast finality voting.
* **BLS Proof**: A BLS signature verifying ownership of the vote address.
* **Identity**: For associating a new validator with an existing one. This is optional unless you're migrating an old validator.

**Generate Consensus Address**

Download the Deelance Chain geth binary from [the official release page](https://github.com/https://github.com/Deelance-Organization/dee-chain/releases/).

Note: Make sure you are downloading the correct binary based on your machine's platform, e.g., if you are using MacOS, you should download the `geth_mac` file. In the following, we will refer the binary as `geth` for simplicity.

To create a new account for mining, please use the following command and set a password for the account.

```shell
geth account new --datadir ${DATA_DIR}
```

* `DATA_DIR`: The directory where you want to store your key store files.

This command will provide the public address (consensus address) and the path to your private key. Remember to back up the key file safely! A sample consensus address is `0x4b3FFeDb3470D441448BF18310cAd868Cf0F44B5`.

If you already have an account for mining, you can use the seed phrase to recover the account.

```shell
geth account import --datadir ${DATA_DIR}
```

**Generate BLS Vote Address and Proof**

To create a new bls account please use the following command.

```shell
 geth bls account new --datadir ${DATA_DIR}
```

* `DATA_DIR`: The directory where you want to store your key store files.

If you already have a voting key, create a bls wallet and use the keyfile to recover it, using the following command.

```shell
 geth bls account import ${KEY_FILE} --datadir ${DATA_DIR}
```

* `DATA_DIR`: The backup file for restoring the BLS account.

Then you can get your vote address by running the following command.

```shell
geth bls account list --datadir ${DATA_DIR}
```

A sample bls address is `b5fe571aa1b39e33c2735a184885f737a59ba689177f297cba67da94bea5c23dc71fd4deefe2c0d2d21851eb11081f69`.

Then you can get your bls proof by running the following command.

```shell
geth bls account generate-proof --chain-id ${BSC_CHAIN_ID} ${OPEATOR_ADDRESS} ${VOTE_ADDRESS}
```

* `BSC_CHAIN_ID`: `45510` for Deelance Chain mainnet, and `12345` for Deelance Chain testnet.
* `OPEATOR_ADDRESS`: The address of your account, which will be recognized as the operator of the new validator.
* `VOTE_ADDRESS`: The vote address created in the last step.

A sample bls proof is `0xaf762123d031984f5a7ae5d46b98208ca31293919570f51ae2f0a03069c5e8d6d47b775faba94d88dbbe591c51c537d718a743b9069e63b698ba1ae15d9f6bf7018684b0a860a46c812716117a59c364e841596c3f0a484ae40a1178130b76a5`.

**Create Identity**

Identity is used to associate the new validator with the old validator created on the BNB Beacon Chain. It should be left empty after the Beacon Chain fusion.

**2.3 Commissions**

<figure><img src="/files/kyIEkneXgC24QbUvq7Ex" alt=""><figcaption></figcaption></figure>

* **Rate**: The commission rate of the validator.
* **Max Rate**: The maximum commission rate that the validator can set.
* **Max Change Rate**: The maximum rate change the validator can set to every epoch (1 day).

**2.4 Self-delegation**

<figure><img src="/files/z3iAIYmUIcrEB9whIwR0" alt=""><figcaption></figcaption></figure>

* **Self Delegate Amount**: The amnout to delegate when creating the validator. The minimal number to input is `2001` - for the minimal self delegation amount is 2000 BNB and extra 1 BNB for locking to a dead address.

#### 3. Submitting the form

Once you have filled out all the required information, click the `Submit` button to submit the transaction.

Note: Upon completing these steps, your node is not guaranteed to become an active validator. Selection is based on a ranking that reflects the total BNB staked, with only the top N nodes being chosen as active validators. The number N is determined by the "maxElectedValidators" parameter within the StakeHubContract (0x0000000000000000000000000000000000002002). As of November 4th, 2024, this number stands at 8 for the testnet and 45 for the mainnet.


# Secure Validator

## Secure Deelance Validator

Each Deelance Chain validator is encouraged to run its operations independently, as diverse setups increase the resilience of the network. Due to the high amount invested by validators it is highly essential to protect them against different DoS and DDoS attacks. In this section, we discuss the security mechanism adopted by Deelance Chain for its validators.

### Sentry Nodes (DDOS Protection)

Validators should ensure network resilience against denial of service attacks. One effective approach to reduce these risks is by organizing their network in a sentry node architecture. Sentry nodes, easily deployed and capable of IP address changes, operate in private IP space, shielding them from direct internet attacks. This setup guarantees that validator block proposals and votes reliably reach the network.

To setup your sentry node architecture you can follow the instructions below:

#### 1. Setup Nodes

Construct a private network and establish trusted connections between the validator node and its sentry nodes. Refer to the fullnode guide for setting up your validator and sentry nodes. Avoid exposing your validator's RPC endpoints to the public network.

#### 2. Add Peers

Connect individual sentry nodes' console, execute `admin.nodeInfo.enode` command. This will provide you with the enode information for each node, as illustrated below.

```
enode://f2da64f49c30a0038bba3391f40805d531510c473ec2bcc7c201631ba003c6f16fa09e03308e48f87d21c0fed1e4e0bc53428047f6dcf34da344d3f5bb69373b@[::]:30306?discport=0
```

> !!! Note: **\[::]** will be interpreted as the localhost (127.0.0.1) address. If your nodes are within a local network, ensure to inspect each host machine to determine its IP using the ifconfig command. However, if your peers are outside the local network, you must be aware of your external IP address to form the enode URL correctly.

Replace **\[::]** with the correct node URL, copy the enode details, and add them to the `config.toml` file of the validator node like this:

```
# make node hidden
NoDiscovery = true
# connect exclusively to sentry
StaticNodes = ["enode://f2da64f49c30a0038bba3391f40805d531510c473ec2bcc7c201631ba003c6f16fa09e03308e48f87d21c0fed1e4e0bc53428047f6dcf34da344d3f5bb69373b@[10.1.1.1]:30306"]
```

#### 3. Confirm Connections

Connect to the validator's console, run `admin.peers`, and you will see the details of the sentry nodes you added.

### Firewall Configuration

`Geth` utilizes different ports for various functions.

It utilizes a listener (TCP) port and a discovery (UDP) port for P2P connections, typically configured to 30303. Ensure this port is open.

The default JSON-RPC service port is TCP port 8545. To prevent unauthorized admin operations, refrain from exposing the JSON-RPC port externally.


# Node Operators


# Node Best Practices


# Node Types


# Bootnodes


# Full Node


# Archive Nodes


