Move.

Post

Share your knowledge.

Bolke .
Jan 05, 2025
Expert Q&A

How to switch from testnetConnection to custom RPC in Sui.js?

I'm working on a project using Sui.js and I need to connect to a custom RPC URL instead of using the default testnetConnection. How can I achieve this? I've seen a lot about connecting via testnetConnection, but I need guidance on using a custom setup for my RPC endpoint.

  • Move CLI
0
1
Share
Comments
.

Answers

1
tomek.
Jan 6 2025, 21:05

To switch from using testnetConnection to a custom RPC URL in @mysten/sui.js, you should initialize the JsonRpcProvider with a Connection object that specifies your custom URL instead. Here's an example of how you can achieve this in your project:

import { Connection, JsonRpcProvider } from '@mysten/sui.js';

const connection = new Connection({
  fullnode: 'YOUR_CUSTOM_RPC_URL',
});
const provider = new JsonRpcProvider(connection);

This code snippet sets up a connection to your custom RPC endpoint instead of the default testnet connection. Make sure to replace 'YOUR_CUSTOM_RPC_URL' with your actual RPC URL.

0
Best Answer
Comments
.

Do you know the answer?

Please log in and share it.

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148Posts231Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignMay
We use cookies to ensure you get the best experience on our website.
More info