您现在的位置:kastop>> Kas信息 Kaspa网络>>正文内容

kaspa连接rpc用例错误分析

If I run a local node like:

./kaspad --testnet \
--utxoindex \
--ram-scale=0.8 \
--appdir "./tn10" \
--rpclisten="0.0.0.0:16210" \
--listen="0.0.0.0:16211" \
--rpclisten-borsh="0.0.0.0:17210" \
--maxinpeers=20  &

Can I just connect it locally with WASM like the following?

const RPC = new RpcClient({  
  resolver: new Resolver({ urls: ["ws://127.0.0.1:16210"]}),  
  encoding: Encoding.Borsh,  
  networkId: network
});

For some reason it's not working


错误分析:
1、The RpcClient argument is “url” not “resolver”. Resolver is a different protocol. So when connecting to a local node, specify url : “ws://127.0.0.1:17210” and omit the resolver argument.

2、why are you targeting your Rpcclient borsch on 16210 while you activated the borsh listening on 17210 (on the node)?

3、Wasm is approaching the borsh rpc endpoint, so you need the 17210 port

4、参考代码:

  1. const { RpcClient } = kaspa;
    
    const rpc = new RpcClient({
      url: "127.0.0.1",
      networkId:"testnet-10",
    })
    
    await rpc.connect()




感动 同情 无聊 愤怒 搞笑 难过 高兴 路过
【字体: 】【收藏】【打印文章】 【 打赏 】 【查看评论

相关文章

    没有相关内容