@pledgecamp/blockchain-utils v0.1.1
Pledgecamp Blockchain Utils
A NodeJS CLI project that allows a user to perform some basic operations (specific to Pledgecamp) with either the Binance or Ethereum network.
Further documentation: https://docs.pledgecamp.com/utilities/blockchain-utils.html
Usage (npm tasks)
Scripts take most of their configuration from environment variables. See the Environment Variables section below.
Append :dev
to scripts to run in development mode, e.g. npm run balance:dev
Balance check
npm run balance
Block Info
npm run block-info
Transfer
npm run transfer
Key directories
- ./src/chains - Helper functions for dealing with supported blockchains (Binance, Ethereum)
- ./src/cli - Command line tools
- ./src/config - Library configuration
Environment variables
This section lists all configurable environment variables. These are read from .env
. .env.dist
can be used as a template.
- NODE_ENV - Project environment setting
BLOCKCHAIN SETTINGS
- BLOCKCHAIN_MNEMONIC_PHRASE - 24 word mnemonic phrase
BLOCKCHAIN_MNEMONIC_PASS - Wallet password
CURRENT_BIP_INDEX - Marker for latest final BIP wallet index (for looping through all drop wallet balances)
BALANCE_BINANCE_ASSET - Symbol for Binance DEX PLG token
- BALANCE_BINANCE_COMMON - Common name for Binance DEX PLG token
- BALANCE_CONTRACT_ASSET - Symbol for ERC20 PLG token
- BALANCE_CONTRACT_COMMON - Common name for ERC20 PLG token
- BINANCE_INITIAL_WALLET_INDEX - Marker for first BIP wallet index for Binance transactions
- BINANCE_COMMUNAL_WALLET_INDEX - Marker for BIP wallet index for Binance communal wallet
- BINANCE_BLOCK_TIME - Expected time to wait for a block to complete confirmation process
- BINANCE_CONFIRMATIONS_NEEDED - Expected number of confirmation to wait for before deeming transaction as confirmed and complete
- BINANCE_API_URL - Binance API address
- BINANCE_NETWORK - Identifier for different testnet or mainnet network settings
BINANCE_DECIMAL_PLACES - Number of decimal places for Binance DEX token
ETHEREUM_INITIAL_WALLET_INDEX - Marker for first BIP wallet index for Ethereum transactions
- ETHEREUM_COMMUNAL_WALLET_INDEX - Marker for BIP wallet index for Ethereum communal wallet
- ETHEREUM_BLOCK_TIME - Expected time to wait for a block to complete confirmation process
- ETHEREUM_CONFIRMATIONS_NEEDED - Expected number of confirmation to wait for before deeming transaction as confirmed and complete
- ETHEREUM_NETWORK_ID - Ethereum Network ID
- ETHEREUM_TOKEN_SYMBOL - Ethereum token symbol for PLG
- ETHEREUM_TOKEN_DECIMAL_PLACES - Number of decimal places for ERC20 token
- ETHEREUM_BIP_TOKEN_INDEX - BIP Token index code for Ethereum
- ETHERSCAN_API_URL - Etherscan API addres
- ETHERSCAN_API_KEY - Etherscan API key
- ETHERSCAN_RATE_LIMIT - Etherscan API call rate limit
- ETHEREUM_RPC_PROVIDER_URL - RPC provider URL
- ETHEREUM_RPC_PROVIDER_METHOD - RPC Provider connection method
ETHEREUM_CONTRACTS_PATH - Path to Pledgecamp contract artifacts built with Hardhat
ETHEREUM_CONTRACT_ACCOUNT_MANAGER_ADDRESS - Deployed Account Manager contract address
- ETHEREUM_CONTRACT_ACCOUNT_STORAGE_ADDRESS - Deployed Account Storage contract address
- ETHEREUM_CONTRACT_ADMINISTRATOR_ADDRESS - Deployed Administrator contract address
- ETHEREUM_CONTRACT_CAMPSHARE_MANAGER_ADDRESS - Deployed CampShare Manager contract address
- ETHEREUM_CONTRACT_CAMPSHARE_STORAGE_ADDRESS - Deployed CampShare Storage contract address
- ETHEREUM_CONTRACT_MODERATOR_ADDRESS - Deployed Moderator contract address
- ETHEREUM_CONTRACT_TOKEN_ADDRESS - Deployed PLG Token contract address
GAS CALCULATION
ETHEREUM_GAS_OPS_LVX
refer to gas multipliers for determining transaction gas price. LV1 is the highest, and results in a more expensive (faster) transaction. LV6 is the lowest, and results in a cheaper (slower) transaction.
- ETHEREUM_GAS_API_URL - URL for EthGasStation API
- ETHEREUM_GAS_API_KEY - EthGasStation API key
- ETHEREUM_GAS_LEVEL_CRITICAL - When a wallet balance has passed this critically low balance threshold a warning will be triggered. This value represents the absolute wallet balance value in wei
- ETHEREUM_GAS_LEVEL_WARNING_PERCENT - When a wallet balance has passed this low balance threshold a warning will be triggered. This value represents a percentage (in whole numbers) above the critical gas level
- ETHEREUM_GAS_PRICE_CHECK_INTERVAL - Setting of time interval between each extraction of gas prices from EthGasStation
- ETHEREUM_GAS_OPS_LV1 - Level 1 (highest) gas multiplier
- ETHEREUM_GAS_OPS_LV2 - Level 2 gas multiplier
- ETHEREUM_GAS_OPS_LV3 - Level 3 gas multiplier
- ETHEREUM_GAS_OPS_LV4 - Level 4 gas multiplier
- ETHEREUM_GAS_OPS_LV5 - Level 5 gas multiplier
- ETHEREUM_GAS_OPS_LV6 - Level 6 (lowest) gas multiplier
Testing
Run unit tests using the following command:
npm run test