INT JavaScript API

create

intjs.create();

Create an account with public key and private key

Parameters

Returns

Object - The private key and address.

Example

let result = intjs.create();
console.log(result); // { address: 'INT1N7mmuKjQXnw4gMa2gdgYx4WL6z3CpwjoD',secret: '0101e260f77bc100d5c70dc2b01bc69b7248e210eb3b1f23ad6e0277e3c3fc6c' }

privateKeyToPublicKey

intjs.privateKeyToPublicKey(privateKey);

Create public key from private key

Parameters

  1. String - The private key.

Returns

Object - The public key and address.

Example

let result = intjs.privateKeyToPublicKey('c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { address: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',pubkey: '03aaf4a716649646bc0e67de63013abd59c2f568623e450e1f044d3878896e3d28' }

publicKeyToAddress

intjs.publicKeyToAddress(pubkey);

Create address from public key

Parameters

  1. String - The public key.

Returns

Object - The address.

Example

let result = intjs.publicKeyToAddress('03aaf4a716649646bc0e67de63013abd59c2f568623e450e1f044d3878896e3d28');
console.log(result); // { address: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ' }

getPrice

intjs.getPrice();

Get current price

Parameters

Returns

Promise - Current price of the latest two blocks.

Example

let result = await intjs.getPrice();  // 200000000000

or

intjs.getPrice().then(
    (result) => {
        // 200000000000
    },
    (err) => {

    }
);

getTransactionLimit

intjs.getTransactionLimit(method, input);

Get transaction limit

Parameters

  1. String - The method name of the transaction.
  2. Object - The input of the transaction.

Returns

Promise - Transaction limit with the transaction method name and input.

Example

let result = await intjs.getTransactionLimit('transferTo', { to: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ'});  // 39000

or

intjs.getTransactionLimit('transferTo', { to: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ'}).then(
    (result) => {
        // 39000
    },
    (err) => {

    }
);

getBlock

intjs.getBlock(which, transactions);

Returns information of a block by block hash or block number

Parameters

  1. String | Number - The block hash or block number.
  2. Boolean - Default false. If true, the returned block will contain all transactions as array.

Returns

Promise returns Object: The block object:

  • err - Number: 0 if the block was successful.
  • block - Object:
    • hash - String: Hash of the block where this transaction was in.
    • number - Number: Block number where this transaction was in.
    • timestamp - Number: The unix timestamp for when the block was collated.
    • preBlock - String: Hash of the previous block.
    • merkleRoot - String: The root of the transaction trie of the block.
    • coinbase - String: The coinbase address to which mining rewards will go.
    • creator - String: The creater address of the block.
    • wage - String: The reward of the block.
  • transactions - Array:
    • hash - String: Hash of the transaction.
    • method - String: The name of the function to call.
    • input - Array: The input data of the transaction.
    • nonce - Number: The number of transactions made by the sender prior to this one.
    • caller - String: The sender of this transaction.
    • value - String: The value transferred for this transaction in min unit (attoINT).
    • limit - String: Limit provided by the sender.
    • price - String: Price provided by the sender min unit (attoINT).

Example

let result = await intjs.getBlock('82015370d98471c83886fd42d4ed97056ad4a2964a51c864f0e1311d6512f795', true);
console.log(result); 

>{ err: 0,
   block: 
    { hash: '82015370d98471c83886fd42d4ed97056ad4a2964a51c864f0e1311d6512f795',
      number: 850,
      timestamp: 1539065927,
      preBlock: 'c09155c9a74c1eacd684c778531884fd10ce1ed75283bae8c16973c9603d1761',
      merkleRoot: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
      coinbase: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
      creator: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
      wage: '1'
    },
   transactions: 
    [ { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
        method: 'vote',
        input: ['INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4'
               ],,
        nonce: 7,
        caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
        value: '0',
        limit: '100000' 
        price: '300000000000' 
      }
    ] 
 }

or

intjs.getBlock('82015370d98471c83886fd42d4ed97056ad4a2964a51c864f0e1311d6512f795', true).then(
    (result) => {
        console.log(result); 
        >{ err: 0,
           block: 
            { hash: '82015370d98471c83886fd42d4ed97056ad4a2964a51c864f0e1311d6512f795',
              number: 850,
              timestamp: 1539065927,
              preBlock: 'c09155c9a74c1eacd684c778531884fd10ce1ed75283bae8c16973c9603d1761',
              merkleRoot: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
              coinbase: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
              creator: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
              wage: '1' 
            },
           transactions: 
            [ { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
                method: 'vote',
                input: ['INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                        'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                        'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4'
                        ],
                nonce: 7,
                caller: '12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                value: '0',
                limit: '100000' 
                price: '300000000000' 
               }
            ] 
         }
    },
    (err) => {
        console.log(err);
    }
);

getBlockNumber

intjs.getBlockNumber();

Get current block number

Parameters

Returns

Promise returns Number: The current block number.

Example

let result = await intjs.getBlockNumber();
console.log(result); // 1028

or

intjs.getBlockNumber().then(
    (result) => {
        console.log(result); // 1028
    },
    (err) => {
        console.log(err);
    }
);

getTransactionReceipt

intjs.getTransactionReceipt(txhash);

Get transaction receipt by transaction hash

Parameters

  1. String - The transaction hash.

Returns

Promise returns Object: The transaction receipt object:

  • err - Number: 0 if the transaction was successful.
  • block - Object:
    • hash - String: Hash of the block where this transaction was in.
    • number - Number: Block number where this transaction was in.
    • timestamp - Number: The unix timestamp for when the block was collated.
    • preBlock - String: Hash of the previous block.
    • merkleRoot - String: The root of the transaction trie of the block.
    • coinbase - String: The coinbase address to which mining rewards will go.
    • creator - String: The creater address of the block.
  • tx - Object:
    • hash - String: Hash of the transaction.
    • method - String: The name of the function to call.
    • input - Array: The input data of the transaction.
    • nonce - Number: The number of transactions made by the sender prior to this one.
    • caller - String: The sender of this transaction.
    • value - String: The value transferred for this transaction in min unit (attoINT).
    • limit - String: Limit provided by the sender.
    • price - String: Price provided by the sender min unit (attoINT).
  • receipt - Object:
    • hash - String: Hash of the transaction.
    • returnCode - Number: 0 if the transaction was successful.
    • logs - Array: Log of the transaction.
    • cost - String: The actual fee for the transaction in min unit (attoINT).

Example

let result = await intjs.getTransactionReceipt('014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78');
console.log(result); 

>{ err: 0,
  block: 
   { hash: '82015370d98471c83886fd42d4ed97056ad4a2964a51c864f0e1311d6512f795',
     number: 850,
     timestamp: 1539065927,
     preBlock: 'c09155c9a74c1eacd684c778531884fd10ce1ed75283bae8c16973c9603d1761',
     merkleRoot: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
     coinbase: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
     creator: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79' },
  tx: 
   { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
     method: 'vote',
     input: 
      [ 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
        'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
        'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4' ],
     nonce: 7,
     caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
     value: '10000000',
     limit: '100000',
     price: '300000000000'
    },
  receipt: 
   { transactionHash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
     returnCode: 0,
     logs: [],
     cost: '9360000000000000' 
   }
}

or

intjs.getTransactionReceipt('40ede67a3d4ece64db65154687d9f6429ff88990f10b75f4ff47b92c18bf1705').then(
    (result) => {
        console.log(result); 
        >{ err: 0,
          block: 
           { hash: '82015370d98471c83886fd42d4ed97056ad4a2964a51c864f0e1311d6512f795',
             number: 850,
             timestamp: 1539065927,
             preBlock: 'c09155c9a74c1eacd684c778531884fd10ce1ed75283bae8c16973c9603d1761',
             merkleRoot: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
             coinbase: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
             creator: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79' },
          tx: 
           { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
             method: 'vote',
             input: 
              [ 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4' ],
             nonce: 7,
             caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
             value: '0',
             limit: '100000',
             price: '300000000000'
           },
          receipt: 
           { transactionHash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
             returnCode: 0,
             logs: [],
             cost: '9360000000000000' 
           } 
        }
    },
    (err) => {
        console.log(err);
    }
);

getPendingTransactions

intjs.getPendingTransactions();

Get pending transactions

Parameters

Returns

Promise returns Object: The transaction receipt object:

  • err - Number: 0 if the transaction was successful.
  • pendingTransactions - Array:
    • Object:
      • tx - Object:
        • hash - String: Hash of the transaction.
        • method - String: The name of the function to call.
        • input - Array: The input data of the transaction.
        • nonce - Number: The number of transactions made by the sender prior to this one.
        • caller - String: The sender of this transaction.
        • value - String: The value transferred for this transaction in min unit (attoINT).
        • limit - String: Limit provided by the sender.
        • price - String: Price provided by the sender min unit (attoINT).
      • ct - Number: The unix timestamp for when the transaction was created.

Example

let result = await intjs.getPendingTransactions();
console.log(result); 

>{ err: 0,
  pendingTransactions:[
    {
      tx: 
         { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
           method: 'vote',
           input: 
           [ 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
             'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
             'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4' ],
           nonce: 7,
           caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
           value: '10000000',
           limit: '100000',
           price: '300000000000'
         },
      ct: 1541155729363
    },
    {
       tx: 
          { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
            method: 'vote',
            input: 
            [ 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
              'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
              'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4' ],
            nonce: 7,
            caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
            value: '10000000',
            limit: '100000',
            price: '300000000000'
          },
       ct: 1541155729363
    },
   ]
}

or

intjs.getPendingTransactions().then(
    (result) => {
        console.log(result); 
        >{ err: 0,
          pendingTransactions:[
            {
              tx: 
                 { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
                   method: 'vote',
                   input: 
                   [ 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                     'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                     'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4' ],
                   nonce: 7,
                   caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                   value: '10000000',
                   limit: '100000',
                   price: '300000000000'
                 },
              ct: 1541155729363
            },
            {
               tx: 
                  { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78',
                    method: 'vote',
                    input: 
                    [ 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                      'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                      'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4' ],
                    nonce: 7,
                    caller: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                    value: '10000000',
                    limit: '100000',
                    price: '300000000000'
                  },
               ct: 1541155729363
            },
           ]
        }
    },
    (err) => {
        console.log(err);
    }
);

getBalance

intjs.getBalance (address);

Get balance of the address

Parameters

  1. String - The address to get balance.

Returns

Promise returns Object: The balance of the address in min unit (attoINT).

Example

let result = await intjs.getBalance('INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79');
console.log(result); // { balance: '100000000' }

or

intjs.getBalance('INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79').then(
    (result) => {
        console.log(result); // { balance: '100000000' }
    },
    (err) => {
        console.log(err);
    }
);

sendSignedTransaction

intjs.sendSignedTransaction(txBuffer);

Sends an already signed transaction

Parameters

  1. Buffer - From writer.render().toString('hex').

Returns

Promise returns Object: The transaction hash.

Example

let address = client.addressFromSecretKey('64d8284297f40dc7475b4e53eb72bc052b41bef62fecbd3d12c5e99b623cfc11');
let tx = new client.ValueTransaction();

tx.method = 'transferTo';
tx.value = new client.BigNumber('100000');
tx.limit = new client.BigNumber('100000');
tx.price = new client.BigNumber('300000000000');
tx.input = {to: 'INT1CHpy1NayZHXxLe21LuzpTMLSs32Xk9D1K'};

let { err, nonce } = await intjs.chainClient.getNonce({ address });
if (!err) {
    tx.nonce = nonce + 1;
    tx.sign('64d8284297f40dc7475b4e53eb72bc052b41bef62fecbd3d12c5e99b623cfc11');
    let writer = new core.BufferWriter();
    let errTx = tx.encode(writer);
    if (!errTx) {
        let result = await intjs.sendSignedTransaction(writer.render().toString('hex'));
        console.log(result); // { hash: '40ede67a3d4ece64db65154687d9f6429ff88990f10b75f4ff47b92c18bf1705' }
    }
}

or

let address = client.addressFromSecretKey('64d8284297f40dc7475b4e53eb72bc052b41bef62fecbd3d12c5e99b623cfc11');
let tx = new client.ValueTransaction();

tx.value = new client.BigNumber('100000');
tx.limit = new client.BigNumber('100000');
tx.price = new client.BigNumber('300000000000');
tx.input = {to: 'INT1CHpy1NayZHXxLe21LuzpTMLSs32Xk9D1K'};

let { err, nonce } = await intjs.chainClient.getNonce({ address });
if (!err) {
    tx.nonce = nonce + 1;
    tx.sign('64d8284297f40dc7475b4e53eb72bc052b41bef62fecbd3d12c5e99b623cfc11');
    let writer = new core.BufferWriter();
    let errTx = tx.encode(writer);
    if (!errTx) {
        intjs.sendSignedTransaction(writer.render().toString('hex')).then(
            (result) => {
                console.log(result); // { hash: '40ede67a3d4ece64db65154687d9f6429ff88990f10b75f4ff47b92c18bf1705' }
            },
            (err) => {
                console.log(err);
            }
        );
    }
}

sendTransaction

intjs.sendTransaction(params);

Send a transaction to the network

Parameters

  1. Object - The transaction object to send:
    • from - String: The address for the sending account.
    • method - String: The name of the function to call.
    • value - String: The value transferred for the transaction in min unit (attoINT).
    • limit - String: Limit provided by the sender.
    • price - String: Price provided by the sender min unit (attoINT).
    • input - Object: The input data of the transaction.
    • password - String: The password of the sending account.

Returns

Promise returns Object: The hash of the transaction.

Example

let params = {
    from: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
    method: 'transferTo',
    value: '1000',
    limit: '100000',
    price: '300000000000',
    input: {to: 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79'},
    password: '123456789'
}
let result = await intjs.sendTransaction(params);
console.log(result); // { hash: '92c068208f24a084f757dae9e76edceac162e93a899f4a111c5b3b5527f45a96' }

or

let params = {
    from: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
    method: 'transferTokenTo',
    value: '0',
    limit: '100000',
    price: '300000000000',
    input: {tokenid: 'INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', to: '1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79', amount: '1000000000'},
    password: '123456789'
}
intjs.sendTransaction(params).then(
    (result) => {
        console.log(result); // { hash: '92c068208f24a084f757dae9e76edceac162e93a899f4a111c5b3b5527f45a96' }
        },
    (err) => {
        console.log(err);
    }
);

getNonce

intjs.getNonce(address);

Returns the number of transactions sent from an address.

Parameters

  1. String - INT address.

Returns

Promise returns Object: The nonce of the address.

Example

let result = await intjs.getNonce('INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ');
console.log(result); // { nonce: 10 }

or

intjs.getNonce('INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ').then(
    (result) => {
        console.log(result); // { nonce: 10 }
    },
    (err) => {
        console.log(err);
    }
);

transferTo

intjs.transferTo(to, amount, limit, price, secret);

Transfer INT

Parameters

  1. String - The destination address to send INT to.
  2. String - The amount transferred for the transaction in min unit (attoINT).
  3. String - Limit provided by the sender.
  4. String - Price provided by the sender min unit (attoINT).
  5. String - The private key.

Returns

Promise returns Object: The hash of the transaction.

Example

let result = await intjs.transferTo('INT1CmGDLeZmyPsKGyurBPEtJoPYv9hkx3y3X', '5000000000000000000', '100000', '300000000000', '64d8284297f40dc7475b4e53eb72bc052b41bef62fecbd3d12c5e99b623cfc11');
console.log(result); // { hash: 'ec4be015131d3781c1a50e1e324e098c03bc0510a4da54b0dd8ee8e6874e5f24' }

or

intjs.transferTo('INT1CmGDLeZmyPsKGyurBPEtJoPYv9hkx3y3X', '5000000000000000000', '100000', '300000000000', '64d8284297f40dc7475b4e53eb72bc052b41bef62fecbd3d12c5e99b623cfc11').then(
    (result) => {
        console.log(result); // { hash: 'ec4be015131d3781c1a50e1e324e098c03bc0510a4da54b0dd8ee8e6874e5f24' }
        },
    (err) => {
        console.log(err);
    }
);

createToken

intjs.createToken(amount, limit, price, name, symbol, secret)

Create token

Parameters

  1. String - The total supply of the token.
  2. String - Limit provided by the sender.
  3. String - Price provided by the sender min unit (attoINT).
  4. String - The full name of the token.
  5. String - The symbol of the token.
  6. String - The private key of the creater.

Returns

Promise returns Object: The transaction hash and token id.

Example

let result = await intjs.createToken('100000000000000000000', '100000', '300000000000', 'Test Coin', 'TC', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { hash: '1ce88b2541105aa5803fe493457daae7e8e0d6f3b5c34f38d2ba2e748bcc1b42', tokenid: '17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z' }

or

intjs.createToken('100000000000000000000', '100000', '300000000000', 'Test Coin', 'TC', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2').then(
    (result) => {
        console.log(result); // { hash: '1ce88b2541105aa5803fe493457daae7e8e0d6f3b5c34f38d2ba2e748bcc1b42', tokenid: '17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z' }
    },
    (err) => {
        console.log(err);
    }
);

transferTokenTo

intjs.transferTokenTo (tokenid, to, amount, limit, price, secret)

Transfer token

Parameters

  1. String - The tokenid of the token.
  2. String - The destination address to send token to.
  3. String - The amount transferred for the transaction in min unit of the token.
  4. String - Limit provided by the sender.
  5. String - Price provided by the sender min unit (attoINT).
  6. String - The private key of the sender.

Returns

Promise returns Object: The transaction hash.

Example

let result = await intjs.transferTokenTo('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', '1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79', '10000', '100000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { hash: '40c86fc19acd2d2de63ba66ee8cad32a0e7cf02b761f86d7aa6287b82ed5ae72' }

or

intjs.transferTokenTo('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79', '10000', '100000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2').then(
    (result) => {
        console.log(result); // { hash: '40c86fc19acd2d2de63ba66ee8cad32a0e7cf02b761f86d7aa6287b82ed5ae72' }
    },
    (err) => {
        console.log(err);
    }
);

getTokenBalance

intjs.getTokenBalance (tokenid, address);

Get the balance of the address

Parameters

  1. String - The tokenid of the token.
  2. String - The address to get balance.

Returns

Promise returns Object: The balance of the address in min unit of the token.

Example

let result = await intjs.getTokenBalance('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79');
console.log(result); // { balance: '1000000' }

or

intjs.getTokenBalance('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79').then(
    (result) => {
        console.log(result); // { balance: '1000000' }
    },
    (err) => {
        console.log(err);
    }
);

getTokenTotalSupply

intjs.getTokenTotalSupply (tokenid);

Returns token total supply

Parameters

  1. String - The tokenid of the token.

Returns

Promise returns Object: The total supply of the token.

Example

let result = await intjs.getTokenTotalSupply('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z');
console.log(result); // { balance: '100000000000000000000' }

or

intjs.getTokenTotalSupply('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z').then(
    (result) => {
        console.log(result); // { balance: '100000000000000000000' }
    },
    (err) => {
        console.log(err);
    }
);

transferOwnership

intjs.transferOwnership(tokenid, newOwner, limit, price, secret);

Transfer the ownership to the new owner

Parameters

  1. String - The tokenid of the token.
  2. String - The address of the new owner.
  3. String - Limit provided by the sender.
  4. String - Price provided by the sender min unit (attoINT).
  5. String - The private key of who was approved.

Returns

Promise returns Object: The transaction hash.

Example

let result = await intjs.transferOwnership('INT17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79', '100000', '30000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { hash: '2177ae787b1763257a8a68c7b78a889dbd5e8cffc498d68c846689f85667982e' }

or

intjs.transferOwnership('INR17YsGmQ8FcqPy9C99McgebWrs5UrYxXY2Z', 'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79', '100000', '30000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2').then(
    (result) => {
        console.log(result); // { hash: '2177ae787b1763257a8a68c7b78a889dbd5e8cffc498d68c846689f85667982e' }
    },
    (err) => {
        console.log(err);
    }
);

register

intjs.register(coinbase, limit, price, secret);

Regist as miner

Parameters

  1. String - Receive block and weight rewards.
  2. String - Limit provided by the sender.
  3. String - Price provided by the sender min unit (attoINT).
  4. String - The private key of the miner.

Returns

Promise returns Object: The transaction hash.

Example

let result = await intjs.register('INT1HgnmnHF1Y2kVjMx5w5muMGooQYRLqw6N8', '100000', '300000000000', 'b48bc45d1522d6131e0aa076157aff5418abe9bec332798855098a27ea3304b3');
console.log(result); // { hash: 'a78144be458b08ce3ef5bce4002e1962f9f244bf11a0e5c81e166ee4b2d3aedf' }

or

intjs.register('INT1HgnmnHF1Y2kVjMx5w5muMGooQYRLqw6N8', '100000', '300000000000', 'b48bc45d1522d6131e0aa076157aff5418abe9bec332798855098a27ea3304b3').then(
    (result) => {
        console.log(result); // { hash: 'a78144be458b08ce3ef5bce4002e1962f9f244bf11a0e5c81e166ee4b2d3aedf' }
    },
    (err) => {
        console.log(err);
    }
);

mortgage

intjs.mortgage(amount, limit, price, secret);

mortgage

Parameters

  1. String - The amount of INT to mortgage.
  2. String - Limit provided by the sender.
  3. String - Price provided by the sender min unit (attoINT).
  4. String - The private key of the sender.

Returns

Promise returns Object: The transaction hash.

Example

let result = await intjs.mortgage('100000000', '1000000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { hash: '52f617bdefcd74f853a79f1ec638ab2193f2ed1124ce662f6126e62dcef6e3fa' }

or

intjs.mortgage('100000000', '1000000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2').then(
    (result) => {
        console.log(result); // { hash: '52f617bdefcd74f853a79f1ec638ab2193f2ed1124ce662f6126e62dcef6e3fa' }
    },
    (err) => {
        console.log(err);
    }
);

unmortgage

intjs.unmortgage(amount, limit, price, secret);

unmortgage

Parameters

  1. String - The amount of stake to unmortgage.
  2. String - Limit provided by the sender.
  3. String - Price provided by the sender min unit (attoINT).
  4. String - The private key of the sender.

Returns

Promise returns Object: The transaction hash.

Example

let result = await intjs.unmortgage('100000000', '1000000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { hash: '8d49bb56794e4a343a364ddf59ce539fa51cd57f5351bab9fef7bc80b39e237a' }

or

intjs.unmortgage('100000000', '1000000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2').then(
    (result) => {
        console.log(result); // { hash: '8d49bb56794e4a343a364ddf59ce539fa51cd57f5351bab9fef7bc80b39e237a' }
    },
    (err) => {
        console.log(err);
    }
);

vote

intjs.vote(candidates, limit, price, secret);

Vote for peer

Parameters

  1. String - The candidates of INT Chain.
  2. String - Limit provided by the sender.
  3. String - Price provided by the sender min unit (attoINT).
  4. String - The private key of the sender.

Returns

Promise returns Object: The transaction hash.

Example

let result = await intjs.vote(['INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79','INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ','INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4'], '100000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2');
console.log(result); // { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78' }

or

intjs.vote(['INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79','INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ','INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4'], '100000', '300000000000', 'c07ad83d2c5627acece18312362271e22d7aeffb6e2a6e0ffe1107371514fdc2').then(
    (result) => {
        console.log(result); // { hash: '014e33a615f460b6b6fdb81030e5248497371da62d0a1817fd37479dfb796e78' }
    },
    (err) => {
        console.log(err);
    }
);

getVote

intjs.getVote();

Get the result of the vote

Parameters

Returns

Promise returns Array: The stake of the candidates.

Example

let result = await intjs.getVote();
console.log(result);    //[ { address: 'INT12CdrtMEKwRqycjYWHw2gSUVTHKoF4wULx',
                          // vote: BigNumber { s: 1, e: 22, c: [Array] } },
                          // { address: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                          //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                          // { address: 'INT13CS9dBwmaboedj2hPWx6Dgzt4cowWWoNZ',
                          //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                          // { address: 'INT16SvD3wWP7g3PWZHdAP2fG58kM2RSz8tGM',
                          //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                          // { address: 'INT18YQ9fHJbwJPzBBqJvBNMswPinsa1fXe9e',
                          //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                          // { address: 'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4',
                          //   vote: BigNumber { s: 1, e: 22, c: [Array] } }
                        // ]

or

intjs.getVote().then(
    (result) => {
        console.log(result);     //[ { address: 'INT12CdrtMEKwRqycjYWHw2gSUVTHKoF4wULx',
                                   // vote: BigNumber { s: 1, e: 22, c: [Array] } },
                                   // { address: 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                                   //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                                   // { address: 'INT13CS9dBwmaboedj2hPWx6Dgzt4cowWWoNZ',
                                   //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                                   // { address: 'INT16SvD3wWP7g3PWZHdAP2fG58kM2RSz8tGM',
                                   //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                                   // { address: 'INT18YQ9fHJbwJPzBBqJvBNMswPinsa1fXe9e',
                                   //   vote: BigNumber { s: 1, e: 22, c: [Array] } },
                                   // { address: 'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4',
                                   //   vote: BigNumber { s: 1, e: 22, c: [Array] } }
                                 // ]
    },
    (err) => {
        console.log(err);
    }
);

getStake

intjs.getStake(address);

Get stake

Parameters

  1. String - The address to get stake.

Returns

Promise returns Object: The stake of the address.

Example

let result = await intjs.getStake('INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ');
console.log(result); // { stake: 100000000 }

or

intjs.getStake('INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ').then(
    (result) => {
        console.log(result); // { stake: 100000000 }
    },
    (err) => {
        console.log(err);
    }
);

getCandidates

intjs.getCandidates();

Get all candidates

Parameters

Returns

Promise returns Array: The candidates.

Example

let result = await intjs.getCandidates();
console.log(result);    //[ 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                        //  'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                        //  'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4',
                        //  'INT13CS9dBwmaboedj2hPWx6Dgzt4cowWWoNZ' ]

or

intjs.getCandidates().then(
    (result) => {
        console.log(result);     //[ 'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                                 //  'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                                 //  'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4',
                                 //  'INT13CS9dBwmaboedj2hPWx6Dgzt4cowWWoNZ' ]
    },
    (err) => {
        console.log(err);
    }
);

getMiners

intjs.getMiners();

Get miners list.

Parameters

Returns

Promise returns Object : The miners list.

Example

let result = await intjs.getMiners();
console.log(result); // { miners:  
                     //    [
                     //      'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                     //      'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                     //      'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4',
                     //      'INT13CS9dBwmaboedj2hPWx6Dgzt4cowWWoNZ' 
                     //    ] 
                     // }

or

intjs.getMiners().then(
    (result) => {
        console.log(result);     // { miners: 
                                 //    [
                                 //      'INT1EYLLvMtXGeiBJ7AZ6KJRP2BdAQ2Bof79',
                                 //      'INT12nD5LgUnLZDbyncFnoFB43YxhSFsERcgQ',
                                 //      'INT1LuwjNj8wkqo237N7Gh8nZSSvUa6TZ5ds4',
                                 //      'INT13CS9dBwmaboedj2hPWx6Dgzt4cowWWoNZ' 
                                 //    ]  
                                 // }
    },
    (err) => {
        console.log(err);
    }
);
Copyright © developer@intchain.io 2018 all right reserved,powered by GitbookLast modified: 2019-01-24 11:19:26

results matching ""

    No results matching ""