<aside> ๐ TABLE OF CONTENTS
1. ๐ Introduction to XRP Ledger
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>
The XRPL EVM sidechain brings Ethereum compatibility to the XRP ecosystem, offering:
git clone <https://github.com/maximedgr/xrpl-evm-quickstart-hardhat>
cd xrpl-evm-quickstart-hardhat
npm install
This template provides:
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
Configure Environment
cp .env.example .env
# Edit .env with your private key and API keys
Compile Contracts
npx hardhat compile
Run Tests
npx hardhat test
Deploy to XRPL EVM Testnet
npx hardhat run scripts/deploy.js --network xrplEvmTestnet
// 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.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;
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;
});
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.
Found ways to improve the template? Submit a PR to the template repository!