Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,21 @@ The `tx` command allows you to check the status of a specific transaction on the
#### Mainnet

```bash
# Check transaction status
rsk-cli tx --txid 0x86deb77e1d666ae6848630496d672da8b5f48292681bda33f8f04245c55dde26

# Monitor transaction until confirmation
rsk-cli tx --txid 0x86deb77e1d666ae6848630496d672da8b5f48292681bda33f8f04245c55dde26 --monitor
```

#### Testnet

```bash
# Check transaction status
rsk-cli tx --testnet --txid 0x86deb77e1d666ae6848630496d672da8b5f48292681bda33f8f04245c55dde26

# Monitor transaction until confirmation
rsk-cli tx --testnet --txid 0x86deb77e1d666ae6848630496d672da8b5f48292681bda33f8f04245c55dde26 --monitor
```

Output example:
Expand All @@ -310,8 +318,16 @@ Output example:
🌐 Network: Rootstock Testnet
💰 Current Balance: 0.5015859620415593 RBTC
🔗 Ensure that transactions are being conducted on the correct network.

# When using --monitor flag:
📊 Monitoring transaction: 0x86deb77e1d666ae6848630496d672da8b5f48292681bda33f8f04245c55dde26
⏳ Current status: pending, confirmations: 0
⏳ Current status: pending, confirmations: 2
✅ Transaction confirmed with 12 confirmations!
```

The `--monitor` flag keeps listening to the transaction status until it reaches the required number of confirmations (default: 12) or fails. The monitoring will automatically stop once the transaction is confirmed or fails.

### 5. Deploy Smart Contract

The deploy command allows you to deploy a smart contract on the Rootstock blockchain. This command supports deployment on both the mainnet and testnet.
Expand Down
62 changes: 61 additions & 1 deletion bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { bridgeCommand } from "../src/commands/bridge.js";
import { batchTransferCommand } from "../src/commands/batchTransfer.js";
import { historyCommand } from "../src/commands/history.js";
import { selectAddress } from "../src/commands/selectAddress.js";
import { transactionCommand } from "../src/commands/transaction.js";
import { monitorCommand, listMonitoringSessions, stopMonitoringSession } from "../src/commands/monitor.js";
import { parseEther } from "viem";

interface CommandOptions {
Expand All @@ -35,6 +35,13 @@ interface CommandOptions {
file?: string;
interactive?: boolean;
token?: Address;
tx?: string;
confirmations?: number;
balance?: boolean;
transactions?: boolean;
list?: boolean;
stop?: string;
monitor?: boolean;
gasLimit?: string;
gasPrice?: string;
data?: string;
Expand Down Expand Up @@ -144,6 +151,8 @@ program
.description("Check the status of a transaction")
.option("-t, --testnet", "Check the transaction status on the testnet")
.requiredOption("-i, --txid <txid>", "Transaction ID")
.option("--monitor", "Keep monitoring the transaction until confirmation")
.option("--confirmations <number>", "Required confirmations for monitoring (default: 12)")
.action(async (options: CommandOptions) => {
const formattedTxId = options.txid!.startsWith("0x")
? options.txid
Expand All @@ -152,6 +161,9 @@ program
await txCommand({
testnet: !!options.testnet,
txid: formattedTxId as `0x${string}`,
isExternal: false,
monitor: !!options.monitor,
confirmations: options.confirmations ? parseInt(options.confirmations.toString()) : undefined,
});
});

Expand Down Expand Up @@ -272,4 +284,52 @@ program
}
});

program
.command("monitor")
.description("Monitor addresses or transactions with real-time updates")
.option("-t, --testnet", "Monitor on the testnet")
.option("-a, --address <address>", "Address to monitor")
.option("--tx <txid>", "Transaction ID to monitor")
.option("--confirmations <number>", "Required confirmations for transaction monitoring (default: 12)")
.option("--balance", "Monitor address balance changes")
.option("--transactions", "Monitor address transaction history")
.option("--list", "List active monitoring sessions")
.option("--stop <sessionId>", "Stop a specific monitoring session")
.action(async (options: CommandOptions) => {
try {
if (options.list) {
await listMonitoringSessions(!!options.testnet);
return;
}

if (options.stop) {
await stopMonitoringSession(options.stop, !!options.testnet);
return;
}

const address = options.address
? (`0x${options.address.replace(/^0x/, "")}` as `0x${string}`)
: undefined;

const tx = options.tx
? (options.tx.startsWith("0x") ? options.tx : `0x${options.tx}`) as `0x${string}`
: undefined;

await monitorCommand({
testnet: !!options.testnet,
address: address as Address | undefined,
monitorBalance: options.balance !== false,
monitorTransactions: !!options.transactions,
tx,
confirmations: options.confirmations ? parseInt(options.confirmations.toString()) : undefined,
isExternal: false
});
} catch (error: any) {
console.error(
chalk.red("Error during monitoring:"),
error.message || error
);
}
});

program.parse(process.argv);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"devDependencies": {
"@types/bun": "latest",
"@types/figlet": "^1.5.8",
"@types/uuid": "^10.0.0",
"solc": "0.8.28",
"typescript": "^5.0.0"
},
Expand All @@ -55,6 +56,7 @@
"fs-extra": "^11.2.0",
"inquirer": "^12.1.0",
"ora": "^8.0.1",
"uuid": "^9.0.1",
"viem": "^2.19.4",
"zxcvbn": "^4.4.2"
}
Expand Down
Loading
Loading