Skip to content

Conversation

97woo
Copy link

@97woo 97woo commented Jul 21, 2025

Summary

Added a new resolve command to the RSK CLI that enables users to
resolve RNS (RIF Name Service) domain names.

UPDATE: Following feedback, also integrated RNS support into
transfer, batch-transfer, and balance commands.

Features

RNS Resolve Command

  • Forward resolution: Convert .rsk domain names to addresses
  • Reverse resolution: Convert addresses back to domain names
  • Support for both mainnet and testnet networks
  • Auto-append .rsk extension if omitted
  • User-friendly error messages

RNS Integration in Core Commands

  • Transfer command: Added --rns parameter for recipient
    domains
  • Batch-transfer command: Added --rns flag for domain
    resolution
  • Balance command: Added --rns parameter for domain holder
    balance checks

Usage

Resolve Command

# Forward resolution
rsk-cli resolve testing.rsk
rsk-cli resolve testing.rsk --testnet

# Reverse resolution
rsk-cli resolve 0x443Cdb69... --reverse
rsk-cli resolve 0x443Cdb69... --reverse --testnet

Transfer with RNS

# RBTC transfer to RNS domain
rsk-cli transfer --rns testing.rsk --value 0.001

# ERC20 token transfer to RNS domain
rsk-cli transfer --token 0xTokenAddress --rns testing.rsk --value
0.1

Batch Transfer with RNS

# Enable RNS resolution in batch transfers
rsk-cli batch-transfer --rns --file batch.json
rsk-cli batch-transfer --rns --interactive

Balance Check with RNS

# Check balance of RNS domain holder
rsk-cli balance --rns testing.rsk
rsk-cli balance --testnet --rns testing.rsk

Implementation Notes

- Created reusable RNS helper module (src/utils/rnsHelper.ts)
- Maintains backward compatibility with all existing commands
- Fully integrated with recent upstream refactoring
- All examples use verified domains (testing.rsk, rifos.rsk)

97woo added 3 commits July 21, 2025 21:56
- Add resolve command to lookup .rsk domain names
- Support forward resolution (name to address)
- Support reverse resolution (address to name)
- Add mainnet and testnet support
- Handle edge cases with user-friendly messages
@ezequiel-rodriguez
Copy link
Collaborator

Hi @97woo ,
I was reviewing your PR and the initiative to integrate RNS into the CLI — actually, this was one of our goals for this quarter. Having the command separately is fine, but to really make an impact we should also integrate RNS into the transfer, transfer-batch, and balance commands.
Ideally, we could add a -rns parameter to those commands and then pass the .rsk domain so it gets resolved.

If you have any questions, just post them on the PR or send me an email and I’ll get back to you asap.

Thanks

97woo added 5 commits August 12, 2025 00:53
- Create reusable RNS utility functions
- Add isRNSDomain to detect RNS domains
- Add resolveRNSToAddress for forward resolution
- Add resolveAddressToRNS for reverse resolution
- Add resolveToAddress to handle both addresses and domains
- Add --rns option to specify recipient as RNS domain
- Integrate RNS resolution before transfer execution
- Support both RBTC and ERC20 token transfers with RNS
- Add --rns flag to enable RNS domain resolution
- Update FileTx type to accept both addresses and domains
- Support RNS domains in interactive mode
- Support RNS domains in file-based batch transfers
- Automatically resolve domains during execution
- Add RNS usage examples for transfer command
- Add RNS usage examples for batch-transfer command
- Add RNS usage examples for balance command
- Update command descriptions to mention RNS support
- Provide JSON examples with RNS domains for batch transfers
- Replace placeholder domains with actually registered ones
- Use testing.rsk and rifos.rsk which exist on both mainnet/testnet
- Add testnet examples for balance command
- Clarify that --rns flag is needed for batch transfers with domains
@97woo 97woo changed the title feat: add RNS resolve command feat: integrate RNS support across transfer, batch-transfer, and balance commands Aug 11, 2025
- Adapt RNS integration to new object parameter style
- Keep upstream refactoring with BatchTransferCommandOptions
- Integrate RNS resolution with new logging system
- Maintain compatibility with isExternal mode
@97woo
Copy link
Author

97woo commented Aug 11, 2025

@ezequiel-rodriguez Thank you for the great feedback! I've
successfully integrated RNS support into all the commands you
mentioned:

transfer - Added --rns <domain> parameter
batch-transfer - Added --rns flag for domain resolution
balance - Added --rns <domain> parameter

Quick Examples:

# Transfer to RNS domain
rsk-cli transfer --rns testing.rsk --value 0.001

# Batch transfer with RNS domains
rsk-cli batch-transfer --rns --file batch.json

# Check balance of RNS domain
rsk-cli balance --rns testing.rsk

Key Points:

- Created reusable RNS helper module to avoid code duplication
- Works on both mainnet and testnet
- Backward compatible - no breaking changes
- Updated documentation with examples

All changes have been pushed and tested. The integration works
seamlessly with the existing codebase and the recent refactoring.

Please review and let me know if you need any adjustments!

@97woo
Copy link
Author

97woo commented Aug 26, 2025 via email

Copy link
Collaborator

@scguaquetam scguaquetam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response, we were working on the CLI for improving it and for make it usable with external interactions as MCP servers, Please take as reference other modules like wallet or transfer and follow the same style, and please avoid the comments along all the code.

97woo added 3 commits August 27, 2025 12:37
- Move RNS contract addresses to constants.ts
- Add isExternal parameter support for MCP compatibility
- Remove all code comments
- Add address validation for reverse lookup
- Use consistent parameter patterns with other commands
- Use helper functions (logMessage, logError, etc.) consistently
- Apply spinner helper functions throughout
- Maintain emoji usage consistent with original codebase
- Ensure MCP compatibility with isExternal parameter
- Refactor rnsHelper.ts to use object parameters like other modules
- Update all RNS function calls in bin/index.ts and batchTransfer.ts
- Remove unnecessary type casting and unused functions
- Ensure consistency with wallet/transfer module patterns
@scguaquetam
Copy link
Collaborator

Hello @97woo , as you are interacting with RNS, please make sure you use the package rns-resolver in order to keep standard use of the tool (instead of create if from scratch).
See this project for reference

- Fixed dynamic import issue with @rsksmart/rns-resolver.js package
- Removed all code comments as per PR review requirements
- Updated isExternal parameter propagation in resolve command
- Maintained consistency with wallet/transfer module patterns
- Remove top-level await, use lazy loading instead
- Add proper address validation with isAddress()
- Improve type safety by removing unnecessary 'any' types
- Fix potential runtime errors with proper validation
@97woo
Copy link
Author

97woo commented Sep 7, 2025

Hi @scguaquetam,

Thank you for the thorough review! I've addressed all the
requested changes:

✅ Completed Changes:

  1. Using @rsksmart/rns-resolver.js package

    • Now properly using the official RNS resolver package as
      requested
    • Implemented lazy loading to avoid top-level await issues
  2. Removed all code comments

    • Cleaned up all comments throughout the codebase to
      maintain consistency
  3. Following wallet/transfer module patterns

    • Object parameter pattern with proper typing
    • Conditional spinner/log management using isExternal
      parameter for MCP compatibility
    • Consistent error handling and logging patterns
  4. Code quality improvements

    • Added proper address validation using isAddress() from
      viem
    • Improved type safety and removed unnecessary type
      assertions where possible
    • Fixed potential runtime errors with proper validation
  5. ZERO_ADDRESS constant

    • Using the constant from constants.js as requested

📝 Technical Notes:

The @rsksmart/rns-resolver.js package has a complex dual
CommonJS/ESM export structure that required a workaround:

async function getResolver() {
  const RNSResolverModule = await 
import("@rsksmart/rns-resolver.js");
  return (RNSResolverModule as any).default.default || 
(RNSResolverModule as any).default;
}

This is a known issue with the package's module structure and
the minimal as any usage here is unavoidable until the package
is updated.

✅ Testing:

  • Mainnet: alice.rsk →
    0x2824B21E348D520a50cDDFA77ba158822160Dd94 ✅
  • Testnet: testing.rsk →
    0x0000000000000000000000000000000001000006 ✅
  • Reverse resolution: Working where configured ✅
  • Build: Clean compilation with TypeScript ✅
  • Runtime: All commands functioning correctly ✅

The implementation is now consistent with the rest of the
codebase and ready for MCP server integration.

Happy to iterate quickly on any remaining feedback.

Thank you!

@97woo
Copy link
Author

97woo commented Sep 10, 2025 via email

});

program
.command("resolve <name>")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shoould call it just resolve?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's just resolve

@scguaquetam
Copy link
Collaborator

Hello @97woo, thanks so much for your work, please take in account the comments I put recently and work on them, I think there are the last details to polish.

- Add minimum 5 character validation based on RNS contract requirements
- Prevent non-RNS domains (like .com, .txt) from being recognized
- Based on FIFSRegistrarBase.sol: uint public minLength = 5
@97woo
Copy link
Author

97woo commented Sep 11, 2025

Hi @scguaquetam, I've addressed all your
review comments:

  • Moved dynamic imports to top-level
  • Replaced console.error with throw Error
  • Removed unnecessary comments
  • Deleted unused readStdin function

The code is ready for another review. Thank
you for your thorough feedback!

@scguaquetam
Copy link
Collaborator

Hello @97woo I was running some tests, and on the transfer command, I found an error, which cannot find the reason, but when trying to sent a transfer on testnet , using this:
node dist/bin/index.js transfer -t --wallet sebas --rns jormel.rsk --value 0.000001
I receive an error
image
but when I tried the common command , it works
image

can you take a look on this error?

@scguaquetam
Copy link
Collaborator

When testing reverse resolution, I found this, just get the address from a .rsk domain, that works good, but when using the same address to get it in reverse, there is a format error (checksum error) it would be nice if can implement a checksum function to avoid this error.
image
But, when I checksum it using for example https://ethsum.netlify.app/ , I have this error:
image

@scguaquetam
Copy link
Collaborator

The code requests I made before are okay @97woo , so the code is well formatted okay now. Just take a look on these comments I make about the RNS resolution and we would be done.

@97woo
Copy link
Author

97woo commented Sep 28, 2025

Hi @scguaquetam — I’ve addressed your latest feedback:

  • Implemented chain‑aware (EIP‑1191) validation with EIP‑55 fallback; normalize to lowercase internally, display EIP‑1191 when helpful.

  • Applied to resolve (forward/reverse), transfer, and batch‑transfer input paths.
    Balance now uses provided --rns/--address directly (no wallet required); defaults to rBTC if token prompt isn’t available.

  • No breaking changes; non‑RNS flows remain unchanged.

  • Reverse resolution note: Reverse resolution requires a reverse record set by the address owner. If it’s missing, “Address has no reverse record” is expected and not a checksum error.

Ready for another review.

@scguaquetam
Copy link
Collaborator

Hello @97woo , the first issue (transfer -t --wallet sebas --rns jormel.rsk --value 0.000001) is working correct, thank you!!

When I tested the reverse one, I have this behavior (looks like it is not capable to solve reverse mode), does it work for you? is this a library issue ? can you take a look on it? sorry for the inconvenience!
image

@97woo
Copy link
Author

97woo commented Sep 30, 2025

Hi @scguaquetam — thanks for confirming transfer now works.

On reverse resolution: it’s data‑dependent. Reverse resolution requires a reverse record set by the address owner. If it’s missing, “Address has no reverse record” is expected and not a checksum or library error.

What I checked:

  • Chain‑aware checksum (EIP‑1191, 30/31) validation is correct.
    For 0x782A… on testnet, the resolver reports no reverse record (expected).
  • With a reverse record set, the CLI returns the name.

How to verify:

  • Testnet: rsk-cli resolve -r -t
  • If no name: set “Reverse/Primary Name” for that address in the RNS manager dApp (testnet), wait a few blocks, then retry.

If you can share an address that already has a reverse record, I’ll verify it end‑to‑end. I can also add a small hint in the CLI output explaining this if you’d like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants