Quick start
Introduction of JSLib

JSLib is a nodejs library for light wallet developers, with JSLib, developers can easily interact with quras blockchain platform, currently JSLib support the following functions in general:

  • Transfer XQC/XQG;
  • Deploy/Issue/Transfer tokens;
  • Multisig address support;
  • Staking;

Install JSLib:

npm install quras-js

JSLib document: https://docs.quras.io/en/docs-overview.html

How to implement xqc/xqg transactions by JSLib

Before start a transaction, need to confirm 2 things:

  • Has XQC/XQG to transfer;
  • Own XQG as fee(every day one address can make three free transactions);

Just a few steps can transfer XQC/XQG by JSLib.

  • Get your address’s balance data;
  • Get script hash of destination address;
  • Config transaction output;
  • Build and sign the transaction;
  • Broadcast the transaction;

Here is a sample code:

import * as Quras from 'quras-js'

  Quras.api.qurasDB.getBalance(Quras.CONST.QURAS_NETWORK.MAIN, 'DknmAbcap8RnUpkLQvbXTwTXqFJMjN4QPz') // Get the balance of from address.
  .then((data) => {
    const balance = new Quras.wallet.Balance(data)
    var scriptHash = Quras.wallet.getScriptHashFromAddress('Dqf3UKe1f5FBWduGxHp8RMqP29dL6DgGS1'); // To address.
    const outputs = [{
      assetId: Quras.CONST.ASSET_ID['XQC'], // The type of asset that you want to send.
      value: 2, // amount to send.
      fee: 0.2, // fee
      scriptHash: scriptHash // The scripthash of "To address".
    }]
    const testTx = Quras.tx.Transaction.createContractTx(balance, outputs) // create a transaction.
    testTx.sign('20164b85226c67cb6d8fe114f3b91af3f2dfc52dcf05d708e9eca80c8d739481'); // Sign the transaction using private key
    const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
    rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server.
      .then((data) => {
        console.log(data);
      })
      .catch ((error) => {
        console.log("error");
      });
  })
  .catch((error) => {
    console.log(error)
  });
How to claim XQG as reward

When an address holds XQC, it can get XQG as a reward(depending on how much XQC it holds), and can make a transaction to receive the reward XQG to the address.

To achieve this, need 2 steps:

  • Check the amount that you can claim;
  • Build a claim transaction then broadcast it;
import * as Quras from 'quras-js'
Quras.api.qurasDB.getClaimInfo(Quras.CONST.QURAS_NETWORK.MAIN, 'DknmAbcap8RnUpkLQvbXTwTXqFJMjN4QPz')
  .then((data) => {
    var testTx = Quras.tx.Transaction.createClaimTxWithQurasDB('DknmAbcap8RnUpkLQvbXTwTXqFJMjN4QPz', data['available']);

    testTx.sign('20164b85226c67cb6d8fe114f3b91af3f2dfc52dcf05d708e9eca80c8d739481'); // Sign the transaction using private key
    const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
    rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server.
      .then((data) => {
        console.log(data);
      })
      .catch ((error) => {
        console.log("error");
      });
  })
  .catch((error) => {
    console.log(error);
  });
                  
Deploy your tokens in 20 mins

Quras support custom tokens, any user can issue their own tokens on quras platform;

Deploy a token on quras platform need 5000 XQG as fee;

1.Deploy a token:

import * as Quras from 'quras-js'
var assetData = new Array();
assetData['priKey'] = '02bf9e9964a3c0421ad5a8dde06f848977c514fd5cc638434d567a05b87ade39';
assetData['tokenName'] = 'DYKTest5';
assetData['totalSupply'] = 1000;
assetData['precision'] = 2;
assetData['afee'] = 0;
assetData['tfeeMin'] = 0;
assetData['tfeeMax'] = 10;

Quras.api.qurasDB.deployAsset(Quras.CONST.QURAS_NETWORK.MAIN, assetData)
  .then((data) => {
    console.log(data)
  })
  .catch((error) => {
    console.log(error)
  })
                  

2.Issue your token:

Before using this token, you must issue it to an address.

  • Get the balance data;
  • Get script hash of target address;
  • Create issue token transaction and sign it;
  • Broadcast the transaction;
import * as Quras from 'quras-js'
Quras.api.qurasDB.getBalance(Quras.CONST.QURAS_NETWORK.MAIN, 'Do27ycn5urnJnWnNboiDh5i5PkAEFmvehd') // Get the balance of from address.
  .then((data) => {
    const balance = new Quras.wallet.Balance(data)
    var scriptHash = Quras.wallet.getScriptHashFromAddress('DrnEEnU1RtNKkP6TBAx8FaUQN1t1ghYPJV'); // To address.
    const outputs = [{
      assetId: '7a1a8c541de4fb7753d077a17870943b6a622817d922f46017d239f8db5b5bec', // The type of coins that you want to send.
      value: 1, // Coin amount to send.
      scriptHash: scriptHash // The scripthash of "To address".
    }]

    const testTx = Quras.tx.Transaction.createIssueTx(balance, outputs, null, 1) // create a transaction.

    testTx.sign('02bf9e9964a3c0421ad5a8dde06f848977c514fd5cc638434d567a05b87ade39'); // Sign the transaction using private key
    const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
    rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server.
      .then((data) => {
        console.log(data);
      })
      .catch ((error) => {
        console.log("error");
      });
  })
  .catch((error) => {
    console.log(error)
  });
                  

3.Transfer this token:

Transfer token is the same as transfer XQC/XQG, just the "assetID" is different;

import * as Quras from 'quras-js'
Quras.api.qurasDB.getBalance(Quras.CONST.QURAS_NETWORK.MAIN, 'DknmAbcap8RnUpkLQvbXTwTXqFJMjN4QPz') // Get the balance of from address.
  .then((data) => {
    const balance = new Quras.wallet.Balance(data)
    var scriptHash = Quras.wallet.getScriptHashFromAddress('Dqf3UKe1f5FBWduGxHp8RMqP29dL6DgGS1'); // To address.
    const outputs = [{
      assetId: '7a1a8c541de4fb7753d077a17870943b6a622817d922f46017d239f8db5b5bec', // The type of asset that you want to send.
      value: 2, // amount to send.
      fee: 0.2, // fee
      scriptHash: scriptHash // The scripthash of "To address".
    }]
    const testTx = Quras.tx.Transaction.createContractTx(balance, outputs) // create a transaction.
    testTx.sign('20164b85226c67cb6d8fe114f3b91af3f2dfc52dcf05d708e9eca80c8d739481'); // Sign the transaction using private key
    const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
    rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server.
      .then((data) => {
        console.log(data);
      })
      .catch ((error) => {
        console.log("error");
      });
  })
  .catch((error) => {
    console.log(error)
  });
                  
How to integrate quras payment system

Will add this feature in the future

About quras Quras smart contract