@arkiv-network/sdk
Version:
TypeScript client library for Arkiv's blockchains interactions
71 lines (68 loc) • 2.13 kB
JavaScript
import { t as ACCESS_KEYS_URL } from "../consts-Lp55G1Qc.js";
import { r as MissingAccessKeyError } from "../errors-CmOg0Na9.js";
import { defineChain } from "viem";
//#region src/chains/localhost.ts
/**
* A node running on the local machine
*/
const localhost = defineChain({
id: 1337,
name: "Localhost",
nativeCurrency: {
decimals: 18,
name: "Ether",
symbol: "ETH"
},
rpcUrls: { default: { http: ["http://127.0.0.1:8545"] } }
});
//#endregion
//#region src/chains/rabdi.ts
const RPC_HOST = "rpc.rabdi.db-chain.testnet.arkiv.network";
let warnedPublicEndpoint = false;
/**
* Rabdi is Arkiv's testnet. The chain carries the access key in its RPC URLs, so every transport
* that defaults to the chain's URL (`http()`, `webSocket()`, wagmi's transports) and every wallet
* the chain is added to sends it.
*
* @throws {MissingAccessKeyError} When the key is missing. Pass `""` to go without one
*
* @example
* import { createPublicClient } from "@arkiv-network/sdk"
* import { rabdi } from "@arkiv-network/sdk/chains"
* import { http } from "viem"
*
* const client = createPublicClient({
* chain: rabdi({ accessKey: "..." }),
* transport: http(),
* })
*/
function rabdi(options) {
if (typeof options?.accessKey !== "string") throw new MissingAccessKeyError("Rabdi");
if (options.accessKey === "" && !warnedPublicEndpoint) {
warnedPublicEndpoint = true;
console.warn(`Rabdi: no access key, so requests go to the public endpoint, which is heavily rate limited. Get a free key at ${ACCESS_KEYS_URL} and pass it as rabdi({ accessKey }).`);
}
const path = options.accessKey === "" ? "" : `/${encodeURIComponent(options.accessKey)}`;
return defineChain({
id: 7794095,
name: "Rabdi",
network: "rabdi",
nativeCurrency: {
name: "Golem",
symbol: "tGLM",
decimals: 18
},
rpcUrls: { default: {
http: [`https://${RPC_HOST}${path}`],
webSocket: [`wss://${RPC_HOST}${path}`]
} },
blockExplorers: { default: {
name: "Rabdi Explorer",
url: "https://rabdi.explorer.arkiv.network"
} },
testnet: true
});
}
//#endregion
export { localhost, rabdi };
//# sourceMappingURL=index.js.map