|
Krishan Chand Oodles

Krishan Chand (Backend-Associate Consultant L2- Development)

Experience:Below 1 yr

Krishan, a highly skilled backend developer, excels in Node.js with a profound understanding of this technology. His expertise extends to various tools and frameworks, including MongoDB, HTML, CSS, Express, JavaScript, GIT/Github, and REST-API. Krishan's proficiency is further validated by multiple certifications, including Project Appreciation, JavaScript Programming, and HTML-5. Leveraging his extensive knowledge and development prowess, he consistently delivers outstanding results on projects within his domain.

Krishan Chand Oodles
Krishan Chand
(Associate Consultant L2- Development)

Krishan, a highly skilled backend developer, excels in Node.js with a profound understanding of this technology. His expertise extends to various tools and frameworks, including MongoDB, HTML, CSS, Express, JavaScript, GIT/Github, and REST-API. Krishan's proficiency is further validated by multiple certifications, including Project Appreciation, JavaScript Programming, and HTML-5. Leveraging his extensive knowledge and development prowess, he consistently delivers outstanding results on projects within his domain.

LanguageLanguages

DotENGLISH

Fluent

DotHindi

Fluent

Skills
Skills

DotJavascript

80%

DotMern Stack

80%

DotNode Js

80%

DotNo SQL/Mongo DB

60%

DotChatgpt

100%

DotSolana

80%
ExpWork Experience / Trainings / Internship

May 2024-Jun 2024

Full Stack developer Intern

Noida Delhi


InnoByte Services

Noida Delhi

May 2024-Jun 2024

EducationEducation

2019-2023

Dot

Chandigarh University

B.E-CSE

certificateCertifications
Dot

Fundamentals of operating System

NPTEL

Issued On

Oct 2021

Top Blog Posts
Building a Solana NFT Rarity Ranking Tool

A Solana NFT Rarity Ranking Tool is a software application or platform that analyzes and ranks NFTs (Non-Fungible Tokens) on the Solana blockchain based on their rarity. Rarity is a key factor in determining the value and desirability of an NFT, as collectors often seek out unique or rare traits within a collection. For more about Solana, visit our Solana blockchain development services

 

What Does a Solana NFT Rarity Ranking Tool Do?

 

Fetches NFT Metadata:

 

  • Retrieves metadata (e.g., traits, attributes, images) for NFTs in a specific collection
    from the Solana blockchain. 
  • Uses tools like the Metaplex SDK or third-party APIs to access this data.

 

Calculates Rarity:

 

  • Analyzes the traits of each NFT to determine how rare they are within the collection.

     

Common methods include:

 

  • Trait Rarity: How uncommon each trait is.
  • Statistical Rarity: A combined score based on the rarity of all traits.
  • Average Rarity: The average rarity of all traits in an NFT.

 

Ranks NFTs:

 

  • Assigns a rarity score to each NFT and ranks them from most rare to least rare.

 

Displays Results:

 

  • Provides a user-friendly interface (e.g., a website or app) where users can view the rarity rankings, search for specific NFTs, and explore traits.

 

Also, Read | Build a Crypto Payment Gateway Using Solana Pay and React

 

How to Build a Solana NFT Rarity Ranking Tool



1. Set Up Your Development Environment


Programming Language: Use JavaScript/TypeScript (Node.js) or Python for backend logic.

Solana Tools:

  • Solana Web3.js: For interacting with the Solana blockchain.
  • Metaplex SDK: For fetching NFT metadata.
  • Database: Use a database (e.g., PostgreSQL, MongoDB) to store NFT metadata and rarity scores.
  • Frontend Framework: Use React, Next.js, or Vue.js for the user interface.

 

2. Fetch NFT's  

 

Identify the NFT Collection:

 

Use the collection's mint address or creator address to fetch NFTs.
Example:

import { PublicKey } from '@solana/web3.js';
import { Connection } from '@solana/web3.js';
import { Metaplex } from '@metaplex-foundation/js';

const rpcUrl='https://api.mainnet-beta.solana.com';
const connection=new Connection(rpcUrl,'confirmed');

const metaplex = new Metaplex(connection);

const getnfts = async () => {
   const collectionCreatorAddress=new PublicKey('2RtGg6fsFiiF1EQzHqbd66AhW7R5bWeQGpTbv2UMkCdW');
    const nfts = await metaplex.nfts().findAllByCreator({ creator: collectionCreatorAddress });
    console.log("The nfts",nfts);
}

getnfts();

 

Also, Explore | How to Create a Multi-Signature Wallet on Solana using Rust


3. Fetch Metadata:

 

Use the Metaplex SDK or a third-party API (e.g., Hyperspace, Solscan) to retrieve NFT metadata, including traits and attributes.

 

Example:

 

javascript
code:
const data = await metaplex.nfts().findByMint({ mintAddress: tokenAddress });

 

Save the metadata (e.g., traits, image URLs) in your database for faster access.


4. Calculate Rarity
 

Parse Traits:

 

Extract traits from the metadata and count the frequency of each trait.

 

Calculate Rarity Scores:

 

For each NFT, calculate a rarity score based on the rarity of its traits.

 

Example formula:

 

Copy
Rarity Score = 1 / (Trait 1 Rarity) + 1 / (Trait 2 Rarity) + ... + 1 / (Trait N Rarity)

 

Normalize Scores:

 

Normalize scores to a consistent range (e.g., 0 to 100) for easier comparison.

 

Also, Discover | Creating a Token Vesting Contract on Solana Blockchain


5. Rank NFTs

 

  • Sort NFTs by their rarity scores in descending order.
  • Assign ranks (e.g., 1st, 2nd, 3rd) based on the sorted list.

 

6. Build the Frontend


Display Rankings:

 

  • Show a list of NFTs ranked by rarity, including their traits and rarity scores.

 

Search and Filter:

 

  • Allow users to search for specific NFTs or filter by traits.

 

Visuals:

 

  • Display NFT images and highlight rare traits.

 

7. Deploy the Tool
 

Backend: Host your backend on a cloud service (e.g., AWS, Vercel, Heroku).

Frontend: Deploy the frontend using platforms like Vercel or Netlify.

Database: Use a managed database service (e.g., AWS RDS, MongoDB Atlas).

 

8. Optional Features

 

  • Real-Time Updates: Use WebSocket or polling to update rarity rankings as new NFTs are minted.
  • Leaderboard: Show the top 10 rarest NFTs.
  • Export Data: Allow users to export rarity data as a CSV file.
  • Integration with Marketplaces: Link to marketplaces like Magic Eden or Tensor for users to purchase NFTs.

 

Example Workflow
 

  • Fetch NFT metadata from Solana using Metaplex.
  • Calculate rarity scores for each NFT.
  • Store the data in a database.
  • Build a frontend to display the ranked NFTs.
  • Deploy the tool and make it accessible to users.

 

Tools and Libraries

 

  • Solana Web3.js: @solana/web3.js
  • Metaplex SDK: @metaplex-foundation/js
  • Frontend: React, Next.js, or Vue.js
  • Database: PostgreSQL, MongoDB, or Firebase
  • APIs: Hyperspace, Solscan, or HowRare.is (for inspiration)

 

Also, Explore | Integrate Raydium Swap Functionality on a Solana Program

 

Challenges

 

  • Data Volume: Large collections may require efficient data handling and caching.
  • Trait Standardization: Ensure traits are consistently named and formatted.
  • Real-Time Updates: Keeping the rarity rankings up-to-date can be resource-intensive.

 

By following these steps, you can build a Solana NFT rarity ranking tool that helps users identify the rarest NFTs in a collection.
 
 

If you planning to build and launch your NFT project, connect with our blockchain developers to get started. 

Category: Blockchain
How to Scale Smart Contracts with State Channels

In this blog, we will explore how to implement state channels within a smart contract and examine their use cases. For more insights into smart contracts, visit our Smart Contract Development Services.

 

What are State Channels?

 

State channels are an off-chain scaling solution that enables participants to execute transactions or interact with smart contracts off-chain, while only submitting the final state to the blockchain. This approach reduces on-chain transaction costs, increases throughput, and enhances scalability.

 

How to Implement State Channels in Smart Contracts

 

Core Components of State Channels

 

Smart Contract (On-Chain):

 

  • Acts as an adjudicator.
  • Locks initial funds or resources required for the interaction.
  • Enforces the final state of the off-chain interaction.

 

Off-Chain Communication:

 

  • Participants interact and exchange cryptographically signed messages off-chain to update the state of the channel.
  • Messages must include:
  • New state.
  • A sequence number or nonce for ordering.
  • Digital signatures from all participants.

 

Dispute Resolution:

 

  • If disputes arise, participants can submit the latest signed state to the on-chain smart contract.
  • The contract resolves disputes by validating signatures and applying predefined rules.

 

Final Settlement:

 

Once participants agree to close the channel, the final state is submitted on-chain for settlement.

 

Also, Read | Build a Secure Smart Contract Using zk-SNARKs in Solidity

 

Setting Up the Development Environment

 

  1. Install Node.js.
  2. Set Up Hardhat:
    • Install Hardhat using the command:
      npm install --save-dev hardhat
  3. Create a Hardhat Project:
    • Initialize a new Hardhat project by running:
      npx hardhatIf disputes arise, participants can submit the latest signed state to the on-chain smart contract.
      The contract resolves disputes by validating signatures and applying predefined rules.

       

      You may also like | Multi-Level Staking Smart Contract on Ethereum with Solidity
       

Smart Contract Example

 

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract StateChannel {
    address public partyA;
    address public partyB;

    uint256 public depositA;
    uint256 public depositB;

    uint256 public latestStateNonce; // To track the latest state
    bytes public latestSignedState; // Encoded off-chain state

    uint256 public disputeTimeout; // Timeout for dispute resolution
    uint256 public disputeStartedAt; // Timestamp when a dispute was initiated

    event ChannelFunded(address indexed party, uint256 amount);
    event StateUpdated(bytes state, uint256 nonce);
    event ChannelClosed(bytes finalState);

    constructor(address _partyA, address _partyB) {
        partyA = _partyA;
        partyB = _partyB;
    }

    function fundChannel() external payable {
        require(msg.sender == partyA || msg.sender == partyB, "Unauthorized sender");

        if (msg.sender == partyA) {
            depositA += msg.value;
        } else {
            depositB += msg.value;
        }

        emit ChannelFunded(msg.sender, msg.value);
    }

    // Additional functions omitted for brevity
}

 

Use Cases of State Channels

 

Micropayments

 

  • Example: Streaming services or pay-per-use applications.
  • How It Works:
    • Users open a state channel with the service provider.
    • Incremental payments are sent off-chain as the service is consumed.
    • The final payment state is settled on-chain after the session ends.

       

Gaming

 

  • Example: Player-versus-player games with monetary stakes.
  • How It Works:
    • Players interact off-chain for faster gameplay.
    • The final game state (e.g., winner and stakes) is settled on-chain.

 

Decentralized Exchanges (DEXs)If disputes arise, participants can submit the latest signed state to the on-chain smart contract.
The contract resolves disputes by validating signatures and applying predefined rules.
 

  • Example: Off-chain order matching with on-chain settlement.
  • How It Works:
    • Orders and trades are executed off-chain.
    • Final trade balances are settled on-chain.

 

Collaborative Applications

 

  • Example: Shared document editing or collaborative decision-making tools.
  • How It Works:
    • Updates are executed off-chain until final submission on-chain.

 

IoT and Machine-to-Machine Payments

 

  • Example: Autonomous cars paying tolls or energy grids charging for usage.
  • How It Works:
    • Devices interact via state channels for high-frequency micropayments.

 

Supply Chain

 

  • Example: Real-time tracking and payments between supply chain participants.
  • How It Works:
    • State channels track asset movements and condition checks off-chain.

 

Also, Explore | Smart Contract Upgradability | Proxy Patterns in Solidity

 

Benefits of State Channels

 

  1. Scalability:
    Reduces on-chain transactions, enhancing throughput.
  2. Cost Efficiency:
    Minimizes gas fees by only interacting with the blockchain for opening and closing the channel.

 

Conclusion

 

By implementing state channels within your smart contract, you can significantly improve scalability, reduce costs, and explore innovative use cases. Whether it's micropayments, gaming, or IoT applications, state channels offer a powerful solution for efficient blockchain interactions.

For expert assistance, connect with our solidity developers.

Category: Blockchain
How to Build Automated Market Maker (AMM) Logic in Solidity

Automated Market Maker (AMM) model sits at the heart of crypto exchange transformation, a fundamental innovation powering many centralized crypto exchange platforms and decentralized exchanges (DEXs). It is a protocol, integrated using crypto exchange development, that allows cryptocurrency trading without using traditional order books. Instead of matching buy and sell orders, AMMs rely on liquidity pools that use mathematical formulas to determine prices. Users can trade directly with the pool, and prices are adjusted based on supply and demand within the pool.

 

Explore | An Exhaustive Introduction to Automated Market Makers (AMM)

 

Steps to Implement AMM Logic in Solidity

 

1. Setting up the Development Environment

 

  • Install Node.js: Node.js is required for running the necessary scripts and tools.
  • Install Hardhat: Hardhat is a development framework for building and testing smart contracts. Install it by running the following command:
  • Create a Hardhat Project: Initialize a new Hardhat project by running:

     

  npx hardhat init


2. Create the Contract

 

Inside the contracts directory, create a new file named Amm.sol. This Solidity file will hold our Amm logic.

 

3. Implement the Contract

 

Program :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

contract TokenV2SwapAmm{

address private constant UNISWAPV2ROUTER =

0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;

address private constant WETH_TOKEN = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

address private constant DAI_TOKEN = 0x6B175474E89094C44Da98b954EedeAC495271d0F;

address constant USDC_TOKEN = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

IUniswapV2Router private myrouter = IUniswapV2Router(UNISWAPV2ROUTER);

IERC20 private weth_token = IERC20(WETH_TOKEN);

IERC20 private dai_token = IERC20(DAI_TOKEN);

// Swap WETH_TOKEN to DAI_TOKEN

function swapSingleHopExactAmountIn(uint256 amount_In, uint256 amount_OutMin)

external

returns (uint256 amountOut)

{

weth_token.transferFrom(msg.sender, address(this), amount_In);

weth_token.approve(address(myrouter), amount_In);

address[] memory route;

route = new address[](2);

route[0] = WETH_TOKEN;

route[1] = DAI_TOKEN;

uint256[] memory amounts = myrouter.swapExactTokensForTokens(

amount_In, amount_OutMin, route, msg.sender, block.timestamp

);

// amounts[0] = WETH_TOKEN amount, amounts[1] = DAI_TOKEN amount

return amounts[1];

}

// Swap DAI_TOKEN -> WETH_TOKEN -> USDC_TOKEN

function swapMultiHopExactAmountIn(uint256 amount_In, uint256 amount_OutMin)

external

returns (uint256 amountOut)

{

dai_token.transferFrom(msg.sender, address(this), amount_In);

dai_token.approve(address(myrouter), amount_In);

address[] memory route;

route = new address[](3);

route[0] = DAI_TOKEN;

route[1] = WETH_TOKEN;

route[2] = USDC_TOKEN;

uint256[] memory amounts = myrouter.swapExactTokensForTokens(

amount_In, amount_OutMin, route, msg.sender, block.timestamp

);

// amounts[0] = DAI_TOKEN amount

// amounts[1] = WETH_TOKEN amount

// amounts[2] = USDC_TOKEN amount

return amounts[2];

}

// Swap WETH_TOKEN to DAI_TOKEN

function swapSingleHopExactAmountOut(

uint256 amountOutRequired,

uint256 amounttInMaxreq

) external returns (uint256 amountOut) {

weth_token.transferFrom(msg.sender, address(this), amounttInMaxreq);

weth_token.approve(address(myrouter), amounttInMaxreq);

address[] memory route;

route = new address[](2);

route[0] = WETH_TOKEN;

route[1] = DAI_TOKEN;

uint256[] memory amounts = myrouter.swapTokensForExactTokens(

amountOutRequired, amounttInMaxreq, route, msg.sender, block.timestamp

);

// Refund WETH_TOKEN to msg.sender

if (amounts[0] < amounttInMaxreq) {

weth_token.transfer(msg.sender, amounttInMaxreq - amounts[0]);

}

return amounts[1];

}

// Swap DAI_TOKEN -> WETH_TOKEN -> USDC_TOKEN

function swapMultiHopExactAmountOut(

uint256 amountOutRequired,

uint256 amounttInMaxreq

) external returns (uint256 amountOut) {

dai_token.transferFrom(msg.sender, address(this), amounttInMaxreq);

dai_token.approve(address(myrouter), amounttInMaxreq);

address[] memory route;

route = new address[](3);

route[0] = DAI_TOKEN;

route[1] = WETH_TOKEN;

route[2] = USDC_TOKEN;

uint256[] memory amounts = myrouter.swapTokensForExactTokens(

amountOutRequired, amounttInMaxreq, route, msg.sender, block.timestamp

);

// Refund DAI_TOKEN to msg.sender

if (amounts[0] < amounttInMaxreq) {

dai_token.transfer(msg.sender, amounttInMaxreq - amounts[0]);

}

return amounts[2];

}

}


interface IUniswapV2Router {

function swapExactTokensForTokens(

uint256 amount_In,

uint256 amount_OutMin,

address[] calldata route,

address to,

uint256 deadline

) external returns (uint256[] memory amounts);


function swapTokensForExactTokens(

uint256 amountOut,

uint256 amounttInMaxreq,

address[] calldata route,

address to,

uint256 deadline

) external returns (uint256[] memory amounts);

}

interface IERC20 {

function totalSupply() external view returns (uint256);

function balanceOf(address account) external view returns (uint256);

function transfer(address recipient, uint256 amount)

external

returns (bool);

function allowance(address owner, address spender)

external

view

returns (uint256);

function approve(address spender, uint256 amount) external returns (bool);

function transferFrom(address sender, address recipient, uint256 amount)

external

returns (bool);

}

interface IWETH_TOKEN is IERC20 {

function deposit() external payable;

function withdraw(uint256 amount) external;

}

 

Create the Contract

 

Inside the contracts directory, create a new file named Amm.sol. This Solidity file will contain the AMM logic for token swaps.

 

Implement the AMM Logic in Solidity

 

The following code snippet implements the AMM logic for token swaps using Uniswap's V2 router.
 


async function main() {
  const Ammswap = await ethers.getContractFactory('TokenV2SwapAmm');
  const swap = await Ammswap.deploy();
  await swap.deployed();
  console.log('Amm logic deployed to:', swap.address);
}
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});


Testing the Contract 

 

1. Write Tests:


  - In the test directory, create a new file for the tests.
 - Use Hardhat's testing framework to write tests for your contract.

 

2. Run Tests:

 


 npx hardhat test

 

Also, Explore | Identifying Smart Contract Orchestration Patterns in Solidity

 

Conclusion

 

Congratulations on implementing Automated Market Maker (AMM) Logic in Solidity and deploying your contract on Ethereum.

Ready to take your decentralized Amm swap system to the next level? Contact our expert blockchain developers at Oodles to transform your vision into a robust, feature-rich solution tailored to your specific needs. Let's innovate together and redefine the future of Amm swap.

 

 
Category: Blockchain
Banner

Don't just hire talent,
But build your dream team

Our experience in providing the best talents in accordance with diverse industry demands sets us apart from the rest. Hire a dedicated team of experts to build & scale your project, achieve delivery excellence, and maximize your returns. Rest assured, we will help you start and launch your project, your way – with full trust and transparency!