Skip to content

Commit

Permalink
Merge a926057 into 86932ab
Browse files Browse the repository at this point in the history
  • Loading branch information
xdjiang committed Dec 16, 2019
2 parents 86932ab + a926057 commit 0c12da5
Showing 1 changed file with 56 additions and 52 deletions.
108 changes: 56 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,64 @@ npm install jcc_exchange
Breaking changes since v2.0.0, if you used v1.0.9 see [v1.0.9](https://github.com/JCCDex/jcc_exchange/blob/master/docs/v1.0.9.md).

```javascript
import JCCExchange from "jcc_exchange";

// example
const hosts = ["localhost"];
const port = 80;
const https = false;
const retry = 3; // default value

// init value of hosts、port、https & retry
JCCExchange.init(hosts, port, https, 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; // 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);
var JCCExchange = require('jcc_exchange').JCCExchange;
async function main() {
// example
const hosts = ["localhost"];
const port = 80;
const https = false;
const retry = 3; // default value

// init value of hosts、port、https & retry
JCCExchange.init(hosts, port, https, 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);
}
}

// 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);
}
main();

```

0 comments on commit 0c12da5

Please sign in to comment.