3.2.0 • Published 3 years ago

jcc_exchange v3.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

jcc_exchange

npm Build Status Coverage Status npm downloads

preface

jcc_exchange 可以提交订单和转账两种交易,而且都是在本地签名后发送到井通节点。自动管理 sequence 以提高交易频率。 如果 sequence 失效,支持重试机制(默认 3 次)。

jcc_exchange is toolkit to submit order/payment transaction to Jingtum node after local signature. Automatically manage sequence to increase transaction frequency. If sequence is ineffective, retry again (default thrice).

  • 支持浏览器 Support running in browsers

井畅应用交流群: 557524730

JCCDex Tech support QQ group ID: 557524730

Installtion

npm install jcc_exchange

Usage

Since v3.0.0, the transaction is submitted to chain node, see v3.0.0.

Breaking changes since v2.0.0, if you used v1.0.9 see v1.0.9.

(async () => {
    const JCCExchange = require('jcc_exchange').JCCExchange;
    // set chain config

    // default support jingtum chain
    // JCCExchange.setDefaultChain("jingtum");

    // support bizain chain
    // JCCExchange.setDefaultChain("bizain");

    // support seaaps chain
    // JCCExchange.setDefaultChain("seaaps");

    // example urls
    const urls = ["http://localhost"];

    const retry = 3; // default value

    // init value of urls & retry
    JCCExchange.init(urls, retry);

    // create an order
    // buy 1 jcc with 1 swt
    const address = "";
    const secret = "";
    const amount = "1";
    const base = "jjcc";
    const counter = "swt";
    const sum = "1";
    const type = "buy"; // if sell 1 jjcc with 1 swt, the value of type is "sell"
    const platform = ""; // swtc address for service charge
    const issuer = "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or"; // the default value is "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or"
    try {
        const hash = await JCCExchange.createOrder(address, secret, amount, base, counter, sum, type, platform, issuer);
        console.log(hash);
    } catch (error) {
        console.log(error);
    }

    // cancel an order
    const address = "";
    const secret = "";
    const orderSequence = 0;
    try {
        const hash = await JCCExchange.cancelOrder(address, secret, orderSequence);
        console.log(hash);
    } catch (error) {
        console.log(error);
    }

    // transfer token
    // transfer 1 jjcc to "jKTtq57iqHoHg3cP7Rryzug9Q2puLX1kHh" from "jpgWGpfHz8GxqUjz5nb6ej8eZJQtiF6KhH"
    const address = "jpgWGpfHz8GxqUjz5nb6ej8eZJQtiF6KhH";
    const secret = "";
    const amount = "1";
    const memo = "test";
    const to = "jKTtq57iqHoHg3cP7Rryzug9Q2puLX1kHh";
    const token = "jjcc";
    const issuer; // the default value is "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or"
    try {
        const hash = await JCCExchange.transfer(address, secret, amount, memo, to, token, issuer);
        console.log(hash);
    } catch (error) {
        console.log(error);
    }
})();
3.2.0

3 years ago

3.1.18

3 years ago

3.1.17

3 years ago

3.1.16

4 years ago

3.1.15

4 years ago

3.1.14

4 years ago

3.1.13

4 years ago

3.1.12

4 years ago

3.1.11

4 years ago

3.1.10

4 years ago

3.1.9

4 years ago

3.1.8

4 years ago

3.1.7

4 years ago

3.1.6

4 years ago

3.1.5

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.4

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.5

4 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago