Skip to content

Toolkit of crossing chain from Stream chain to SWTC chain

License

Notifications You must be signed in to change notification settings

JCCDex/jcc-stream-utils

Repository files navigation

jcc-stream-utils

Toolkit of crossing chain from Stream chain to SWTC chain

npm Build Status Coverage Status Dependencies npm downloads PRs Welcome

Description

Transfer token automatically from Stream chain to SWTC chain. Support STM token.

e.g. you transfer 1 STM to Stream Fingate from your stream address if success, the contract will automatically transfer 1 JSTM to your swtc address from Jingtum Fingate in a few minutes.

Installtion

npm install jcc-stream-utils

CDN

jcc_stream_utils as a global variable.

<script src="https://unpkg.com/jcc-stream-utils/dist/jcc-stream-utils.min.js"></script>

Usage

// demo
import StreamFingate from "jcc-stream-utils";

// This is a test websocket server. Don't use it in production environment.
const testServer = "sa.labs.stream";

const instance = new StreamFingate({
    host: testServer,
    port: 443,
    secure: true
});

const testSecret = "vaFtuK2skLZUCcqHvsFk2BMKpzQmJbQsXa";

// Don't change it. The fingate address is it for now.
const destination = "vn4K541zh3vNHHJJaos2Poc4z3RiMHLHcK";

const testMemo = {
    jtaddress: "jpgWGpfHz8GxqUjz5nb6ej8eZJQtiF6KhH"
}

const amount = "1";

try {
    instance.init()
        .connect()
    const hash = await instance.transfer(testSecret, destination, amount, testMemo);
    console.log(hash);
} catch (error) {
    console.log(error);
} finally {
    instance.disconnect();
}

API

see API.md