Move.

帖子

分享您的知识。

Bolke .
Jan 05, 2025
专家问答

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
分享
评论
.

答案

1
tomek.
Jan 6 2025, 21:05

testnetConnection在中从使用切换到自定义 RPC URL@mysten/sui.js,应JsonRpcProvider``Connection改为使用指定自定义 URL 的对象来初始化. 以下是如何在项目中实现这一目标的示例:

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

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

此代码片段设置了与您的自定义 RPC 端点的连接,而不是默认的测试网连接. 请务必'YOUR_CUSTOM_RPC_URL'使用实际的 RPC 网址替换.

0
最佳答案
评论
.

你知道答案吗?

请登录并分享。

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

148帖子231答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。

奖励活动五月
我们使用 cookie 确保您在我们的网站上获得最佳体验。
更多信息