Developers Forum for XinFin XDC Network

Cover image for [Solved] How Do I Get an RPC URL for My Subnet?
π”€π”žπ”° 𝔩𝔦π”ͺ𝔦𝔱
π”€π”žπ”° 𝔩𝔦π”ͺ𝔦𝔱

Posted on • Updated on

[Solved] How Do I Get an RPC URL for My Subnet?

I want to enable gasless transactions for my users of platform. I have set up my Subnet, but I don't know how to connect it to ethers. I have found my subnet local device's RPC URL from localhost:3000, but I do not know if it is safe, nor feasible to use it as an endpoint. Can someone please advise me on how I can use ethers to let users on my platform transact with my subchain without paying gas? thanks.
Image description

Discussion (8)

Collapse
mitali_blocksscan profile image
Mitali_BlocksScan

Hello @gaslimit
We hope that the above issue is resolved, if the issue still persists then please let us know about it so that the team can resolve it on priority. It will be grateful to get an update within 72 hours or else it will be considered resolved.
Thank You.

Collapse
gaslimit profile image
π”€π”žπ”° 𝔩𝔦π”ͺ𝔦𝔱 Author • Edited on

Hello, apologies for the late reply. I have successfully sent tokens from the master account to another address on the local machine where the subnet is being hosted, however I have failed when running the same script on a separate machine. How do I make it so that I can access the chain from anywhere? Please refer to the screenshots below

xdc.dev/uploads/articles/5q68w8c5z...

Collapse
wanwiset25 profile image
Wanwiset Peerapatanapokin

Hi @gaslimit

This is a network issue. It depends on your connectivity on the remote machine to the subnet machine.

Are they on the same network (ie. "ping 10.0.2.15" works)?
Does port 8545 allow external connection on the subnet machine?

You might have to look at NAT, and Port forwarding if you want to call the subnet over the internet.

Thread Thread
gaslimit profile image
π”€π”žπ”° 𝔩𝔦π”ͺ𝔦𝔱 Author

Thank you! that was the issue.

Collapse
wanwiset25 profile image
Wanwiset Peerapatanapokin

Hi @gaslimit

For your query on Subnet RPC URL, it is by default port '8545' for subnet1 then '8546' for subnet2 and so on. You can change the config in subnetX.env files (then restart the docker image to apply). The 'localhost:3000' is the endpoint for the web UI backend server.

For your query on 'Can someone please advise me on how I can use ethers to let users on my platform transact with my subchain without paying gas?' let me revert back with the recommendation.

Collapse
wanwiset25 profile image
Wanwiset Peerapatanapokin

Hi @gaslimit

Apologies for the delay. To allow users to push TXs on your subnet they would require a wallet with Subnet coins. As a Subnet owner you have the Grandmaster key (check keys.json) which owns all the subnet funds. Once you transfer some coins to your users they will be able to interact with your Subnet.

We have a script which uses web3.js instead of ethers for the coin transfer. Please note the script location is not finalized.
github.com/XinFinOrg/XinFin-Node/t...

Collapse
wanwiset25 profile image
Wanwiset Peerapatanapokin

Also, docs are updated on details of Subnet ports.
xinfinorg.github.io/xdc-subnet-doc...

Collapse
vinn_9686 profile image
Vinn

Hello @gaslimit

Noted your query! I am forwarding this query to respective team and share the revert ASAP.