Skip to content

Commit 0a57b1b

Browse files
committed
import from perso account
0 parents  commit 0a57b1b

File tree

7 files changed

+481
-0
lines changed

7 files changed

+481
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# XRPL JS - Simple JS scripts
2+
3+
This repository contains JavaScript scripts to interact with the XRP Ledger (XRPL), enabling wallet generation, trustline approval, and transactions.
4+
5+
## 📁 Project Structure
6+
7+
The scripts are located inside the src folder:
8+
9+
- `generate.js` → Generates a new XRPL wallet (address & seed).
10+
11+
- `rlusd.js` → Generates a new XRPL wallet (address & seed) and approves a trustline for the RLUSD token on XRPL.
12+
13+
- `transaction.js` → Sends an XRP transaction from one wallet to another.
14+
15+
## 🔧 Installation & Setup
16+
17+
Clone this repo and run `npm i`.
18+
19+
## 📝 Usage
20+
21+
1. Run the following command to generate a new wallet:
22+
23+
`node src/generate.js`
24+
25+
2. Generate a wallet and approve Trustline for RLUSD:
26+
27+
`node src/rlusd.js`
28+
29+
3. Send an XRP Transaction:
30+
31+
Before running this script, update transaction.js with:
32+
- Source Wallet Seed (from generate.js)
33+
- Destination Wallet Address
34+
35+
`node src/transaction.js`
36+
37+
## Links
38+
39+
- [XRPL Documentation](https://xrpl.org/)
40+
- [Ripple Stablecoin](https://ripple.com/solutions/stablecoin/)

package-lock.json

Lines changed: 200 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "xrpl-simple-js-scripts",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"keywords": [],
9+
"author": "",
10+
"license": "ISC",
11+
"description": "",
12+
"dependencies": {
13+
"xrpl": "^4.1.0"
14+
}
15+
}

src/generate.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Import the xrpl library
2+
const xrpl = require("xrpl");
3+
4+
/**
5+
* Main function to interact with the XRPL.
6+
* This function connects to the XRPL Testnet, generates a wallet,
7+
* funds it with test XRP, and disconnects.
8+
*/
9+
async function main() {
10+
// Step 1: Connect to the XRPL Testnet
11+
const client = new xrpl.Client("wss://s.altnet.rippletest.net:51233");
12+
await client.connect();
13+
console.log("Connected to the XRPL Testnet");
14+
15+
// Step 2: Generate a new wallet
16+
const wallet = xrpl.Wallet.generate();
17+
console.log("Wallet generated:");
18+
console.log("Address:", wallet.address); // XRPL address
19+
console.log("Seed:", wallet.seed); // Secret seed (keep this safe!)
20+
21+
// Step 3: Fund the wallet with test XRP (only works on Testnet)
22+
const fundingResponse = await client.fundWallet(wallet);
23+
console.log("Wallet funded with test XRP:");
24+
console.log("Balance:", fundingResponse.balance); // Initial balance after funding
25+
26+
// Step 4: Disconnect from the XRPL
27+
await client.disconnect();
28+
console.log("Disconnected from the XRPL");
29+
}
30+
31+
// Execute the main function and handle errors
32+
main().catch((error) => {
33+
console.error("Error:", error);
34+
process.exit(1); // Exit with a non-zero status code to indicate failure
35+
});

0 commit comments

Comments
 (0)