Paymeter

Paymeter

new Paymeter()

Handles all function related to paymeter

Source:

Methods

(async) createWallet(options) → {Promise.<string>}

Creates a new wallet in the blockcluster account

Parameters:
Name Type Description
options object

Wallet configuration

Properties
Name Type Attributes Description
coinType string

Coin type Eg: ETH, ERC20 etc

walletName string

Name of the wallet

network string

Network on which the wallet will function Eg: testnet or mainnet

password string

Password for the wallet

contractAddress string <optional>

Contract address for ERC20 type token

tokenSymbol string <optional>

Symbol for ERC20 token

Source:
Returns:

Wallet id

Type
Promise.<string>
Example

Creates a wallet

const walletId = await paymeter.createWallet({coinType: 'ETH', walletName: 'My ETH Wallet', network: 'mainnet', password: '1234567890' });
console.log(walletId);
// Prints the walletId <random string>

(async) getDeposits(walletId) → {Promise.<array>}

Fetches all the deposits happend for a wallet

Parameters:
Name Type Description
walletId string

Id of the wallet for which the transactions need to be fetched

Source:
Returns:

Array of deposits

Type
Promise.<array>
Example

Fetches all deposits for a wallet

const deposits = await paymeter.getDeposits('abcdefghi');
console.log(deposits);
// Prints [{...deposit1}, {...}, ...]

(async) getWallets(walletIdopt) → {Promise.<(array|object)>}

Fetches all the wallets or a single wallet details

Parameters:
Name Type Attributes Description
walletId string <optional>

Id of the wallet for the details needs to be fetched. If undefined then fetches all wallets

Source:
Returns:

An array of wallets or single wallet description

Type
Promise.<(array|object)>
Examples

Fetches all wallets

const wallets = await paymeter.getWallets();
console.log(wallets);
// Prints [{_id: '...', ...}, ...]

Fetches details of single wallet

const wallet = await paymeter.getWallets('abcdefghi');
console.log(wallet);
// Prints {_id: 'abcdefghi', ...}

(async) getWithdrawals(walletId) → {Promise.<array>}

Fetches all the withdrawals happend for a wallet

Parameters:
Name Type Description
walletId string

Id of the wallet for which the transactions need to be fetched

Source:
Returns:

Array of withdrawals

Type
Promise.<array>
Example

Fetches all withdrawals for a wallet

const withdrawals = await paymeter.getWithdrawals('abcdefghi');
console.log(withdrawals);
// Prints [{...withdrawal1}, {...}, ...]

(async) refreshBalance(walletId) → {Promise.<boolean>}

Force refreshes balance in a wallet. This can be used in case deposits are coming from a smart contract

Parameters:
Name Type Description
walletId string

ID of the wallet to refresh balance of

Source:
Returns:

True if call succeeded

Type
Promise.<boolean>

(async) send(options) → {Promise.<string>}

Transfers token from a wallet to specified address

Parameters:
Name Type Description
options object

Wallet configuration

Properties
Name Type Attributes Description
fromWalletId string

Id of the wallet from which to transfer tokens

toAddress string

Address to which tokens are to be transferred

amount string

Amount of tokens to be transferred. Maximum of 5 decimal places

password string

Password for the wallet from which tokens are to be transferred

feeWalletId string <optional>

Only for ERC20 tokens, wallet Id from where the transaction fee is to be deducted

feeWalletPassword string <optional>

Only for ERC20 tokens, password for the feeWallet specified (Required if feeWalletId is specified)

feeCollectWalletId string <optional>

Wallet ID to which the gas fees is to be collected

tokenValueInEth string <optional>

Value of ERC20 token in ETH i.e., 1 ERC20 Token = ? ETH (Required if feeCollectWalletId is specified)

sendExactAmount boolean <optional>

If true, then sends exact amount to the receiver. Total amount debited will be the specified amount + network charges. If false, network charges will be debited from the specified amount

functionCallData string(hex) <optional>

Raw transaction data to call functions of smart contract. Only applicable for ETH wallets

Source:
Returns:

Transaction id

Type
Promise.<string>
Examples

Transfers tokens (Fees debited from the amount specified)

const txnId = await paymeter.send({
  fromWalletId: 'wallet1ID',
  toAddress: '0x1234567890abcdef',
  amount: 1,
  password: 'wallet1Password'
});
console.log(txnId);
// Prints 0x...

Transfers tokens (Fees debited above the specifed amount)

const txnId = await paymeter.send({
  fromWalletId: 'wallet1ID',
  toAddress: '0x1234567890abcdef',
  amount: 1,
  password: 'wallet1Password'
  sendExactAmount: true
});
console.log(txnId);
// Prints 0x...

Transfers token from but fees deducted from another wallet

const txnId = await paymeter.send({
  fromWalletId: 'wallet1ID',
  toAddress: '0x1234567890abcdef',
  amount: 1,
  password: 'wallet1Password'
  feeWalletId: 'wallet2ID',
  feeWalletPassword: 'wallet2Password'
});
console.log(txnId);
// Prints 0x...

Transfers token from with fees credits to separate wallet

const txnId = await paymeter.send({
  fromWalletId: 'wallet1ID',
  toAddress: '0x1234567890abcdef',
  amount: 1,
  password: 'wallet1Password'
  feeCollectWalletId: 'wallet3ID',
});
console.log(txnId);
// Prints 0x...

Transfers token using raw transactions

const contractAddress = '0x12341234567890abcd';
const contract = new web3.eth.Contract(abi, contractAddress);
const data = await contract.methods.sign().encodeABI();
const txnId = await paymeter.send({
  fromWalletId: 'wallet4ID',
  password: 'wallet4Password',
  toAddress: contractAddress,
  functionCallData: data,
});
console.log(txnId);
// Prints 0x...