abstract

阅读文档前, 可先行了解rpc接口, 这里大部分调用rpc接口的数据为直接暴露

安装

npm install @vitelabs/vitejs
yarn add @vitelabs/vitejs

快速开始

node/without webpack


import provider from '@vite/vitejs/dist/es5/provider/WS';
import { client, constant } from '@vite/vitejs';

const { method } = constant;
let WS_RPC = new provider("https://example.com");

let myClient = new client(WS_RPC, (_myClient) => {
    _myClient.ledger.getSnapshotChainHeight().then((result) => {
        console.log(result);
    }).catch((err) => {
        console.warn(err);
    });
});

webpack

webpack.config

// ...
    resolve: {
        alias: {
            WSprovider: '@vite/vitejs/dist/es5/provider/WS'
        }
    }
// ...

use


import provider from "WSprovider";
import { client } from '@vite/vitejs';

let WS_RPC = new provider("https://example.com");
let myClient = new client(WS_RPC);