Skip to content

Payment infrastructure on top of the OpenST network

License

LGPL-3.0, Unknown licenses found

Licenses found

LGPL-3.0
LICENSE
Unknown
LICENSE.CONTRACTS
Notifications You must be signed in to change notification settings

rachinkapoor/openst-payments

 
 

Repository files navigation

OpenST Payments - Advance Payment infrastructure on top of the OpenST network

Latest version Travis Downloads per month Gitter: JOIN CHAT

While OpenST 0.9 is available as-is for anyone to use, we caution that this is early stage software and under heavy ongoing development and improvement. Please report bugs and suggested improvements.

Install OpenST Payments

npm install @openstfoundation/openst-payments --save

Run Test Chain

cd mocha_test/scripts/
sh start_test_chain.sh

Set EVN Variables

Setup Initial Setup Variables:

export OST_UTILITY_GETH_RPC_PROVIDER=''
export OST_UTILITY_DEPLOYER_ADDR=''
export OST_UTILITY_DEPLOYER_PASSPHRASE=''
export OST_UTILITY_OPS_ADDR=''
export OST_UTILITY_OPS_PASSPHRASE=''

Deploy Branded Token Contract:

node tools/deploy/EIP20TokenMock.js conversionRate symbol name decimals gasPrice

Deploy Workers Contract:

node tools/deploy/workers.js gasPrice chainId

Deploy Airdrop Contract:

node tools/deploy/airdrop.js brandedTokenContractAddress baseCurrency workerContractAddress airdropBudgetHolder gasPrice chainId

Set Caching Engine:

export OST_CACHING_ENGINE='none'
For using redis/memcache as cache engine refer - [OpenSTFoundation/ost-price-oracle](https://github.com/OpenSTFoundation/ost-price-oracle)

Set DB Details For Payments/Airdrop:

export OP_MYSQL_HOST=''
export OP_MYSQL_USER=''
export OP_MYSQL_PASSWORD=''
export OP_MYSQL_DATABASE=''
export OP_MYSQL_CONNECTION_POOL_SIZE='5'

Create Airdrop Tables:

node migrations/create_tables.js 

Example:

const OpenSTPayment = require('@openstfoundation/openst-payments')
  , deployer = new OpenSTPayment.deployer()
  , opsManaged = new OpenSTPayment.opsManaged(contractAddress, gasPrice, chainId)
  , workers = new OpenSTPayment.worker(workerContractAddress, chainId)
  , airdrop = new OpenSTPayment.airdrop(airdropContractAddress, chainId)
  , airdropManager = OpenSTPayment.airdropManager
;  
  // Deploy Contract
  deployer.deploy( contractName, constructorArgs, gasPrice, options);
  // Register Airdrop
  airdropManager.registerAirdrop(airdropContractAddress, chainId);
  // Set Ops Address
  opsManaged.setOpsAddress(deployerAddress, deployerPassphrase, opsAddress, options);
  // Set Worker
  workers.setWorker(senderAddress, senderPassphrase, workerAddress, deactivationHeight, gasPrice, options);
  // Set Price Oracle
  airdrop.setPriceOracle(senderAddress, senderPassphrase, currency, address, gasPrice, options);
  // Set Accepted Margin
  airdrop.setAcceptedMargin(senderAddress, senderPassphrase, currency, acceptedMargin, gasPrice, options);
  // Transfer Amount to airdrop budget holder
  airdropManager.transfer(senderAddress, senderPassphrase, airdropContractAddress, amount, gasPrice, chainId, options);
  // Approve airdrop budget holder
  airdropManager.approve(airdropContractAddress, airdropBudgetHolderPassphrase, gasPrice, chainId, options);
  // Allocate airdrop amount to users in batch
  airdropManager.batchAllocate(airdropContractAddress, transactionHash, airdropUsers, chainId);
  // Get Users Airdrop Balance
  airdropManager.getAirdropBalance(chainId, airdropContractAddress, userAddresses);
  // Call Pay method
  airdrop.pay(workerAddress,
              WorkerPassphrase,
              beneficiaryAddress,
              transferAmount,
              commissionBeneficiaryAddress,
              commissionAmount,
              currency,
              intendedPricePoint,
              spender,
              gasPrice,
              {tag:'airdrop.pay', returnType: 'txHash'});

For further implementation details, please refer to the API documentation.

About

Payment infrastructure on top of the OpenST network

Resources

License

LGPL-3.0, Unknown licenses found

Licenses found

LGPL-3.0
LICENSE
Unknown
LICENSE.CONTRACTS

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.1%
  • Shell 1.9%