<aside> ๐Ÿ“œ TABLE OF CONTENTS

1. ๐Ÿ“˜ Introduction to XRP Ledger

2. ๐Ÿ”‘ XRP Ledger Basics

3. ๐Ÿ’ป Interacting with XRP Ledger

4. ๐Ÿ—๏ธ Building dApps on XRPL with React

5. ๐Ÿ”— EVM Sidechain Integration for XRPL

6. ๐Ÿ› ๏ธ Non-EVM Development

7. ๐Ÿ“š Resources and References

</aside>

http://quiz.xrplsea.org

๐Ÿš€ Rapid XRPL EVM Sidechain Development Guide for Hackathons

๐ŸŒ‰ Introduction to XRPL EVM Sidechain

The XRPL EVM sidechain brings Ethereum compatibility to the XRP ecosystem, offering:

๐Ÿƒโ€โ™‚๏ธ Quick Start with XRPL EVM Template

Clone and Setup

git clone <https://github.com/maximedgr/xrpl-evm-quickstart-hardhat>
cd xrpl-evm-quickstart-hardhat
npm install

This template provides:

๐Ÿ—๏ธ Template Structure

xrpl-evm-quickstart-hardhat/
โ”œโ”€โ”€ contracts/           # Your Solidity smart contracts
โ”œโ”€โ”€ scripts/            # Deployment and interaction scripts
โ”œโ”€โ”€ test/               # Test files
โ”œโ”€โ”€ hardhat.config.js   # Hardhat configuration
โ””โ”€โ”€ README.md           # Documentation

๐Ÿ› ๏ธ Development Guide

  1. Configure Environment

    cp .env.example .env
    # Edit .env with your private key and API keys
    
    
  2. Compile Contracts

    npx hardhat compile
    
    
  3. Run Tests

    npx hardhat test
    
    
  4. Deploy to XRPL EVM Testnet

    npx hardhat run scripts/deploy.js --network xrplEvmTestnet
    
    

๐Ÿ’ป Sample Contract

// contracts/Lock.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

contract Lock {
    uint public unlockTime;
    address payable public owner;

    event Withdrawal(uint amount, uint when);

    constructor(uint _unlockTime) payable {
        require(
            block.timestamp < _unlockTime,
            "Unlock time should be in the future"
        );

        unlockTime = _unlockTime;
        owner = payable(msg.sender);
    }

    function withdraw() public {

        require(block.timestamp >= unlockTime, "You can't withdraw yet");
        require(msg.sender == owner, "You aren't the owner");

        emit Withdrawal(address(this).balance, block.timestamp);

        owner.transfer(address(this).balance);
    }
}

๐Ÿ”ง Hardhat Configuration

// hardhat.config.js
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-verify";
import * as dotenv from "dotenv";

dotenv.config();

const config: HardhatUserConfig = {
  solidity: {
    version: "0.8.24",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  networks: {
    XRPL_EVM_Sidechain_Devnet: {
      url: "<https://rpc-evm-sidechain.xrpl.org>",
      accounts: [process.env.DEV_PRIVATE_KEY || ''],
    },
  },
  etherscan: {
    apiKey: {
      'XRPL_EVM_Sidechain_Devnet': "void"
    },
    customChains: [
      {
        network: "XRPL_EVM_Sidechain_Devnet",
        chainId: 1440002,
        urls: {
          apiURL: "<https://explorer.xrplevm.org/api>",
          browserURL: "<https://explorer.xrplevm.org/>",
        }
      }
    ]
  }
};

export default config;

๐Ÿƒโ€โ™‚๏ธ Hackathon Success Tips

  1. Start with Examples
  2. Leverage EVM Compatibility
  3. Optimization Focus

๐Ÿ”’ Security Considerations

๐Ÿš€ Next Steps

  1. Interaction Scripts

    // scripts/withdraw.js
    import { ethers } from "hardhat";
    
    async function main() {
      // Address of the deployed Lock contract
      const lockContractAddress = "0xYourLockContractAddressHere";
    
      // Get the Lock contract
      const Lock = await ethers.getContractFactory("Lock");
      const lock = Lock.attach(lockContractAddress);
    
      // Get the signer (your deploying account or the one with the necessary rights)
      const [deployer] = await ethers.getSigners();
    
      // Execute the withdraw function of the contract
      console.log("Attempting to withdraw funds...");
    
      try {
        const tx = await lock.connect(deployer).withdraw();
        console.log("Transaction sent:", tx.hash);
    
        // Wait for the transaction to be mined
        await tx.wait();
        console.log("Withdrawal successful!");
      } catch (error) {
        console.error("Error during withdrawal:", error);
      }
    }
    
    main().catch((error) => {
      console.error(error);
      process.exitCode = 1;
    });
    

๐Ÿ“š Resources

๐ŸŽ“ Conclusion

The XRPL EVM sidechain opens up new possibilities for Ethereum developers to leverage XRPL's benefits. This template accelerates your hackathon development process, allowing you to focus on building innovative features.

๐Ÿค Contributing

Found ways to improve the template? Submit a PR to the template repository!