Optional
layer2Signer: SignerPrivate
prepaidProtected
layer2Private
Optional
layer2This call will return the price in terms of the specified token of how much it costs to have a face value in the specified units of SPEND (§). This takes into account both the exchange rate of the specified token as well as gas fees that are deducted from the face value when creating a prepaid card. Note though, that the face value of the prepaid card in SPEND will drift based on the exchange rate of the underlying token used to create the prepaid card. (However, this drift should be very slight since we are using stable coins to purchase prepaid cards (emphasis on "stable"). Since the units of SPEND are very small relative to wei (§ 1 === $0.01 USD), the face value input is a number type. This API returns the amount of tokens required to achieve a particular face value as a string in native units of the specified token (e.g. wei
).
// You must send 'amountInDai' to the prepaidCardManager contract
// to achieve a prepaid card with §5000 face value
let amountInDAI = await prepaidCard.priceForFaceValue(daiCpxdAddress, 5000);
Note that if you are creating multiple cards or splitting cards, use this API to ensure the amount to provision for each prepaid card you want to create in order to achieve teh desired face values for each of the prepaid cards created.
This call will return the gas fee in terms of the specified token for the creation of a prepaid card. All prepaid cards will be seeded with some CARD.CPXD
in order to pay our gnosis safe relayer for gas. In order to offset these costs, a small fee will be charged when creating or splitting a prepaid card. The gas fee that is charged is returned as a string value in native units of the specified token (e.g. wei
). This is the same fee that is accounted for in the PrepaidCard.priceForFaceValue
API.
let gasFeeInDai = await prepaidCard.gasFee(daiCpxdAddress);
This call will return the prepaid card payment limits in units of SPEND (we return a number types since it is safe to represent SPEND as a number in javascript).
a promise object containing min and max number
let { min, max } = await prepaidCard.getPaymentLimits();
since the limits are in units of SPEND, it is totally safe to represent as a number vs a string
This call will pay a merchant from a prepaid card.
a promise for a web3 transaction receipt.
let { min, max } = await prepaidCard.getPaymentLimits();
since the limits are in units of SPEND, it is totally safe to represent as a number vs a string
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThis call will transfer a prepaid card from an issuer to a customer. Note that currently, once a prepaid card has been transferred to a customer (and EOA that did not create the prepaid card), then it becomes no longer transferrable. Additionally, if a prepaid card was used to fund a prepaid card split, the funding prepaid card also becomes non-transferrable, as it is considered the issuer's own personal prepaid card at that point.
a promise for a web3 transaction receipt.
let result = await prepaidCard.transfer(prepaidCardAddress, newOwner);
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThis call will use a prepaid card as the source of funds when creating more prepaid cards, in effect "splitting" the prepaid card being used to fund the transaction. Prepaid cards created from the split command are automatically placed in the PrepaidCardInventory. (Note that the prepaid card that is used to fund the creation of more prepaid cards may not be transferred and is considered the issuer's own personal prepaid card.) The creation mechanisms for prepaid cards created via a PrepaidCard.split
are identical to PrepaidCard.create
in terms of the total cost and gas charges.
let result = await prepaidCard.split(
prepaidCardAddress,
[5000, 4000], // split into 2 cards: §5000 SPEND face value and §4000 SPEND face value
undefined,
"did:cardstack:56d6fc54-d399-443b-8778-d7e4512d3a49"
);
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThis call will create a new prepaid card from a gnosis safe, specifically a gnosis safe that holds tokens that were bridged to the layer 2 network from teh TokenBridge
api. From this call you can create 1 or more prepaid cards from the *.CPXD
layer 2 tokens (in the Gnosis Chain network, for example). When a token is bridged to a layer 2 network like Gnosis Chain, it will obtain a *.CPXD
suffix, indicating that it can participate in the Card Protocol on Gnosis Chain. The face value for the prepaid card does not include the amount of tokens consumed by the gas to create the card as well as fees to create a prepaid card. (Note that the XD in CPXD originally comes from "XDai" the former name of Gnosis Chain.)
total cost in *.CPXD = (Face value in § * token exchange rate) + fees + gas
Note that gas is charged in the *.CPXD
token which will be deducted from your safe. You can use the PrepaidCard.costForFaceValue
method to determine what the final cost for a card with a particular face value in units of § will be in the token of your choosing. You can use this amount to create the desired face value for your prepaid card.
faceValues An array of face values in units of § SPEND as numbers. Note there is a maximum of 15 prepaid cards that can be created in a single transaction and a minimum face value of §100 is enforced for each card.
let daicpxd = await getAddress('daiCpxd', web3);
let result = await prepaidCard.create(
safeAddress,
daicpxd,
[5000], // §5000 SPEND face value
undefined,
"did:cardstack:56d6fc54-d399-443b-8778-d7e4512d3a49"
);
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsOptional
force: booleanProtected
getPrivate
getPrivate
getPrivate
getPrivate
getPrivate
executePrivate
executePrivate
executePrivate
createGenerated using TypeDoc
The
PrepaidCard
API is used to create and interact with prepaid cards within the layer 2 network in which the Card Protocol runs. ThePrepaidCard
API can be obtained fromgetSDK()
with aWeb3
instance that is configured to operate on a layer 2 network (like Gnosis Chain or Sokol).Example