MerchantSlate SDK is a TypeScript library for on-chain crypto payment databases, supporting front-end and back-end solutions across popular EVM chains. It enables product management, payment processing, and utility functions like fetching live token rates and data (e.g., relative to USDT). Install via npm, yarn, or CDN, and customize with RPCs.
Contract is currently deployed across popular EVM chains More Info
This package is implemented at merchantslate.com Example Website Repo
Install using yarn add merchantslate or npm install merchantslate
OR use in browsers through CDN
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/merchant.min.js"
></script>Note merchant is the browser global object for this library functions.
Accepts a MerchantConfigParams object (RPC urls, private key/seed, suffixes, contract address)
Note: Public RPCs obtained from https://chainlist.org/ are used as default for development only and should be updated using config
config({
/** wallet private key (optional)
* used if no wallet can be connected in the setup environment
*/
walletPrivateKey?: string,
/**
* wallet seed phrase (optional)
* used if no wallet can be connected in the setup environment
* cannot be used if private key is defined
*/
walletSeedPhrase?: string,
/** BSC RPC URL (same for any other chain)
* all chains list available as SUPPORTED_CHAINS
*/
BSC_RPC: string,
/** billion number suffix */
billionSuffix?: string,
/** million number suffix */
millionSuffix?: string,
/** MerchantSlate Contract Address (does not require change) */
merchantSlateContract?: string,
/** Chain RPC (pass as ${ChainId}_RPC) string for a single RPC or string[] for multiple RPCs */
BSC_RPC?: string | string[],
});Returns data of supported chains (BlockchainNetwork type)
getChainsData(): BlockchainNetwork[]Returns the current configuration object
getConfig(): MerchantConfigParamsThe currently selected chain ID
selectedChain: ChainIdsSets the selected chain
setSelectedChain(chain: ChainIds): voidThe zero address constant
ZERO_ADDRESS: EVMAddressObject of possible error codes / messages from smart contract
contractErrors: Record<string, string>Gets on-chain token metadata (symbol, name, decimals etc.)
getTokenData(
tokenAddress: EVMAddress,
chain: ChainIds
): Promise<TokenData>Maybe similar but includes additional data (e.g. balances?)
tokenOnchainData(
tokenAddress: EVMAddress,
chain: ChainIds
): Promise<OnchainTokenData>Gets current rate / price of token in some unit or relative value
getTokenRate(
tokenAddress: EVMAddress,
chain: ChainIds
): Promise<number>Fee required to register as merchant on given chain (in wei or string)
merchantFee(chain: ChainIds): Promise<string>Same as merchantFee but formatted as human readable text
merchantFeeValueText(chain: ChainIds): Promise<string>Initiate merchant signup transaction
merchantSignup(
chain: ChainIds
): Promise<{ hash?: string; merchantId?: string }>Get merchant id of connected wallet
getMerchantId(chain: ChainIds): Promise<string>Fee to add product on given chain
productFee(chain: ChainIds): Promise<string>Product fee formatted as text
productFeeText(chain: ChainIds): Promise<string>Add or update product details
addProduct(params: {
chain: ChainIds;
productPrice: string;
tokenAddress?: EVMAddress;
quantity?: string;
commissionAddress?: string;
commissionPercentage?: string;
productId?: string;
}): Promise<{
hash: string;
productId: string;
isNew: boolean
}>Update existing product
updateProduct(params: {
chain: ChainIds;
productPrice: string;
tokenAddress?: EVMAddress;
quantity?: string;
commissionAddress?: string;
commissionPercentage?: string;
productId?: string;
}): Promise<{
hash: string;
productId: string;
isNew: boolean
}>Delete a product; returns transaction hash
deleteProduct(
chain: ChainIds,
productId: string
): Promise<string>Fetch products with optional pagination / filter
getProducts(
chain: ChainIds,
pageNo?: string,
pageSize?: string,
isMerchantOnly?: boolean
): Promise<ProductDataAll>Get all data for a single product
getProductDetails(
chain: ChainIds,
productId: string
): Promise<ProductData>Similar to getProducts but wrapped for UI loading etc.
loadProducts(params: {
chain: ChainIds;
pageNo: string;
pageSize: string;
isMerchantOnly?: boolean
}): Promise<{ productsData: ProductDataAll }>Fetch payments with pagination and optional filters
getPayments(
chain: ChainIds,
pageNo?: string,
pageSize?: string,
isMerchantOnly?: boolean,
buyerWallet?: EVMAddress
): Promise<{
currentPage: string;
previousPage?: string;
nextPage?: string;
totalPages: string;
paymentsData: PaymentDataAll
}>Same as getPayments but wrapped for UI
loadPayments(params: {
chain: ChainIds;
pageNo: string;
pageSize: string;
isMerchantOnly: boolean;
buyerWallet?: EVMAddress;
}): Promise<{
currentPage: string;
previousPage?: string;
nextPage?: string;
totalPages: string;
paymentsData: PaymentDataAll
}>Initiate payment transaction
payProduct(
chain: ChainIds,
product: ProductChain,
quantity?: string
): Promise<{
hash?: string;
paymentId?: string
}>Payment value converted to human readable text
payValueText(
chain: ChainIds,
product: ProductChain,
quantity?: string
): Promise<string>Fetch transaction details for a list of payment IDs
payTxs(
chain: ChainIds,
paymentIds: string[]
): Promise<{
chainId: string,
token: TokenData,
amount: string,
txs: TxObj[]
}>Validate that payment inputs are acceptable etc.
payValidation(
chain: ChainIds,
product: ProductChain,
quantity?: string
): Promise<boolean>Returns total stake units/stake count on the contract
totalStakes(chain: ChainIds): Promise<number>Returns count of stakes held by wallet + offered stakes
stakesCount(
chain: ChainIds
): Promise<{
holdings: number;
offered: number
}>Owners offer stakes for public purchase
offerStake(
chain: ChainIds,
stakeUnits: string,
totalValueWei: string
): Promise<string>Get list of stake offers; optionally only for connected wallet
stakesOffered(
chain: ChainIds,
walletOnly?: boolean
): Promise<{
listedStakes: StakeOffers;
holderOffersCount: number
}>Transfer stakes to someone else
transferStake(
chain: ChainIds,
stakeUnits: string,
recipientAddress: EVMAddress
): Promise<string>Take an existing stake offer by id
takeStake(chain: ChainIds, offerId: string): Promise<string>Remove a previously created stake offer
removeStakeOffer(
chain: ChainIds,
offerId: string
): Promise<string>Returns the connected browser wallet signer or undefined
getBrowserWallet(): Promise<Signer | undefined>Returns the ethers provider based on the configuration
getProvider(): ProviderReturns the contract instance connected to the current chain
getContract(): ContractReturns address of connected wallet (if any)
getWalletAddress(): Promise<string | undefined>Normalize number/string into integer string (no decimals)
integerString(num: string | number): stringConvert from units to Wei (or smallest unit)
toWei(amount: string, decimals?: number): stringConvert from Wei to human readable units
fromWei(amount: string, decimals?: number): stringFormat numbers suitably (commas etc.)
processNumbers(input: number | string): stringFormat a timestamp into human‐readable AM/PM time
timeAMPM(timestamp: number | string): stringFormat into full date string (day, month, year etc.)
fullDateText(timestamp: number | string): stringShorten text with ellipsis etc.
truncateText(text: string, length: number): stringHere are major types exported:
BlockchainNetwork— info about chain (name, chainId, etc.)ChainIds— supported chain IDs typeChainIdsEnum— supported chain IDs enumEVMAddress— string type representing valid Ethereum‐style addressErrorResponse— structure returned when some contract interaction failsMerchantConfigParams— config input object (RPCs, keys, suffixes, etc.)PayTxsData— data returned bypayTxsPayment, PaymentChain, PaymentData, PaymentDataAll— various payment data shapesProductChain, ProductData, ProductDataAll— product data shapesTxObj— transaction object type