The RevenuePool API is used register merchants and view/claim merchant revenue from prepaid card payments within the layer 2 network in which the Card Protocol runs. The RevenuePool API can be obtained from getSDK() with a Web3 instance that is configured to operate on a layer 2 network (like Gnosis Chain or Sokol).

Example

import { getSDK } from "@cardstack/cardpay-sdk";
let web3 = new Web3(myProvider); // Layer 2 web3 instance
let revenuePool = await getSDK('RevenuePool', web3);

Hierarchy

  • RevenuePoolClass

Constructors

Properties

revenuePool: undefined | Contract
layer2Web3: default
layer2Signer?: Signer

Methods

  • This call will return the fee in SPEND to register as a merchant.

    Returns

    a promise for a number which represents the amount of SPEND it costs to register as a merchant.

    Example

      let registrationFeeInSpend = await revenuePool.merchantRegistrationFee();
    registrationFee = 1000

    Returns Promise<number>

  • This call returns the balance in the RevenuePool for a merchant's safe address. As customers pay merchants with their prepaid cards, the payments accumulate as revenue that the merchants can claim using their merchant safes. This function reveals the revenue that has accumulated for the merchant. This function takes in a parameter, which is the merchant's safe address and returns a promise that is a list balances aggregated by token address (a merchant can accumulate balances for all the stable coin CPXD tokens that are allowed in the cardpay protocol).

    Returns

    he amount of the tokens specified as the token address in the parameters that are estimated to be used to pay for gas as a string in units of wei.

    Example

    let balances = await revenuePool.balances(merchantSafeAddress);
    for (let balanceInfo of balances) {
    console.log(`${balanceInfo.tokenSymbol} balance is ${fromWei(balanceInfo.balance)}`)
    }

    Parameters

    • merchantSafeAddress: string

    Returns Promise<RevenueTokenBalance[]>

  • This call will return the gas estimate for claiming revenue.

    Returns

    a promise for the amount of the tokens specified as the token address in the parameters that are estimated to be used to pay for gas as a string in units of wei

    Example

    let result = await revenuePool.claimGasEstimate(merchantSafeAddress, tokenAddress, claimAmountInWei);
    

    Parameters

    • merchantSafeAddress: string

      The merchant's safe address

    • tokenAddress: string

      The token address of the tokens the merchant is claiming

    • amount: string

      The amount of tokens that are being claimed as a string in native units of the token (e.g. wei)

    Returns Promise<string>

  • This call will transfer unclaimed merchant revenue from the revenue pool into the merchant's safe, thereby "claiming" the merchant's revenue earned from prepaid card payments.

    Returns

    This method returns a promise for a web3 transaction receipt

    Example

    let result = await revenuePool.claim(merchantSafeAddress, tokenAddress, claimAmountInWei);
    

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • merchantSafeAddress: string
    • tokenAddress: string
    • Optional amount: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • This call will register a merchant with the Revenue Pool. In order to register as a merchant a prepaid card is used to pay the merchant registration fee. As part of merchant registration a gnosis safe will be created for the merchant specifically to claim revenue from prepaid card payments from the Revenue Pool. When customers pay a merchant they must specify the merchant safe (created from this call) as the recipient for merchant payments. The parameters to this function are:

    • The merchant's prepaid card address that will be paying the merchant registration fee
    • The merchant's info DID which is an identifier string that can resolve merchant details like their name, URL, logo, etc.

    Example

      let { merchantSafe } = await revenuePool.registerMerchant(merchantsPrepaidCardAddress, infoDID);
    

    This call takes in as a parameter the prepaid card address that the merchant is using to pay the registration fee for becoming a new merchant.

    Returns

    promise for a web3 transaction receipt.

    Parameters

    • txnHash: string

    Returns Promise<{
        merchantSafe: MerchantSafe;
        txReceipt: SuccessfulTransactionReceipt;
    }>

  • Parameters

    • prepaidCardAddress: string
    • infoDID: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<{
        merchantSafe: MerchantSafe;
        txReceipt: SuccessfulTransactionReceipt;
    }>

Generated using TypeDoc