npm.io
1.0.9 • Published 3 years ago

partisia-rpc

Licence
ISC
Version
1.0.9
Deps
1
Size
81 kB
Vulns
23
Weekly
0
DeprecatedThis package is deprecated

Install

npm i partisia-rpc

Query Across All Shards

import { PartisiaAccount } from "partisia-rpc"

// Set the Config for each shard
const rpc = PartisiaAccount({
    urlBaseGlobal: { url: 'https://reader.partisiablockchain.com', shard_id: 99 },
    urlBaseShards: [
        { url: 'https://reader.partisiablockchain.com/shards/Shard0', shard_id: 0 },
        { url: 'https://reader.partisiablockchain.com/shards/Shard1', shard_id: 1 },
        { url: 'https://reader.partisiablockchain.com/shards/Shard2', shard_id: 2 },
    ]
})

// get account info
const account = await rpc.getAccount('<address>')
// get nonce for adderss
const nonce = await rpc.getNonce('<address>', account.shard_id)
// get contract info
const contract = await rpc.getContract('<contract address>',1)

// get url being used for a specific shard
const url = rpc.getShardUrl(account.shard_id)