1.0.54 • Published 1 year ago

@cardstack/cardpay-sdk v1.0.54

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

cardpay-sdk

This is a package that provides an SDK to use the Cardpay protocol. The SDK is divided into two main parts currently Cardpay and Champer. See here for full documentation

Champer

Champer is the newer part of the SDK that interact with our safe modules.

Cardpay

Cardpay is the older part of the SDK that interact with our protocol smart contracts and token bridge.

  • Assets: Utility to query native and ERC20 token balances
  • Safes: Utility to query safes in our protocol
  • LayerOneOracle: Utility to get the current exchange rates in USD and ETH on layer 1
  • LayerTwoOracle: Utility get the current exchange rates in USD and ETH on layer 2

  • TokenBridgeForeignSide: Interact with the foreign-side bridge ie the bridge contract receiving the tokens on layer 1

  • TokenBridgeHomeSide: Interact with the home-side bridge ie the bridge contract minting the tokens on layer 2

  • PrepaidCard: Create and interact with prepaid cards that are used to pay merchants

  • RevenuePool: Register merchants and claim revenue

  • PrepaidCardMarket: Provision prepaid cards to people who buy them

  • PrepaidCardMarketV2: Similar as PrepaidCardMarket but using updated v2 pattern where prepaid cards are provisioned before being created
  • RewardManager: Register and manage reward program
  • RewardPool: Submit rewards with merkle roots and claim rewards as a user

Installation

yarn add @cardstack/cardpay-sdk

Usage

yarn add @cardstack/cardpay-sdk@1.0.47 ethers@5.7.2 node-fetch@2.6.1
import fetch from "node-fetch";
import { getSDK, JsonRpcProvider } from "@cardstack/cardpay-sdk";
import { Wallet } from "ethers";

//@ts-ignore polyfilling fetch
global.fetch = fetch;

(async () => {
  const mnemonic =
    "<Your mnemonic>";
  const signer = Wallet.fromMnemonic(mnemonic);
  const rpcUrl = "https://eth-goerli.public.blastapi.io";
  const networkId = 5; // 5 for goerli
  const ethersProvider = new JsonRpcProvider(rpcUrl, networkId);
  const scheduledPaymentModule = await getSDK(
    "ScheduledPaymentModule",
    ethersProvider,
    signer
  );
  const { safeAddress } =
    await scheduledPaymentModule.createSafeWithModuleAndGuard(
      undefined,
      undefined,
      { from: signer.address }
    );
  console.log(`Your new safe ${safeAddress} has been created`);
})();

Special Considerations

One item to note that all token amounts that are provided to the API must strings and be in native units of the token (usually wei) unless otherwise noted. All token amounts returned by the API will also be in native units (again, this usually means wei). You can use Web3.utils.toWei() and Web3.utils.fromWei() to convert to and from units of wei. Because ethereum numbers can be so large, it is unsafe to represent these natively in Javascript, and in fact it is very common for a smart contract to return numbers that are simply too large to be represented natively in Javascript. For this reason, within Javascript the only safe way to natively handle numbers coming from Ethereum is as a string. If you need to perform math on a number coming from Ethereum use the BigNumber feature of the ethers library.

1.0.54

1 year ago

1.0.53

2 years ago

1.0.51

2 years ago

1.0.52

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.49

2 years ago

1.0.50

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.29

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.23

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago

0.28.34

3 years ago

0.28.33

3 years ago

0.28.32

3 years ago

0.28.31

3 years ago

0.28.37

3 years ago

0.28.36

3 years ago

0.28.35

3 years ago

0.28.29

3 years ago

0.28.28

3 years ago

0.28.27

3 years ago

0.28.26

3 years ago

0.28.21

3 years ago

0.28.20

3 years ago

0.28.19

3 years ago

0.28.18

3 years ago

0.28.17

3 years ago

0.28.12

3 years ago

0.28.1

3 years ago

0.27.44

3 years ago

0.28.11

3 years ago

0.28.0

3 years ago

0.27.43

3 years ago

0.28.10

3 years ago

0.27.42

3 years ago

0.27.41

3 years ago

0.28.16

3 years ago

0.28.15

3 years ago

0.28.14

3 years ago

0.28.13

3 years ago

0.28.9

3 years ago

0.28.7

3 years ago

0.27.40

3 years ago

0.28.2

3 years ago

0.27.38

3 years ago

0.27.33

3 years ago

0.27.32

3 years ago

0.27.31

3 years ago

0.27.30

3 years ago

0.27.37

3 years ago

0.27.36

3 years ago

0.27.35

3 years ago

0.27.34

3 years ago

0.27.29

3 years ago

0.27.28

3 years ago

0.27.26

3 years ago

0.27.25

3 years ago

0.27.24

3 years ago

0.27.22

3 years ago

0.27.20

3 years ago

0.27.23

3 years ago

0.27.19

3 years ago

0.27.18

3 years ago

0.27.17

3 years ago

0.27.16

3 years ago

0.27.15

3 years ago

0.27.14

3 years ago

0.27.13

3 years ago

0.27.2

3 years ago

0.27.1

3 years ago

0.27.0

3 years ago

0.26.10

3 years ago

0.27.9

3 years ago

0.27.8

3 years ago

0.27.6

3 years ago

0.27.5

3 years ago

0.27.4

3 years ago

0.27.3

3 years ago

0.27.11

3 years ago

0.27.10

3 years ago

0.26.9

3 years ago

0.26.8

3 years ago

0.26.3

3 years ago

0.26.5

3 years ago

0.26.4

3 years ago

0.26.2

3 years ago

0.26.1

3 years ago

0.26.0

3 years ago

0.25.2

3 years ago

0.25.1

3 years ago

0.25.0

3 years ago

0.24.5

3 years ago

0.24.4

3 years ago

0.24.3

3 years ago

0.24.2

3 years ago

0.24.1

3 years ago

0.23.0

3 years ago

0.22.1

3 years ago

0.22.0

3 years ago

0.21.5

3 years ago

0.21.3

3 years ago

0.21.2

3 years ago

0.21.1

3 years ago

0.21.0

3 years ago

0.19.50

3 years ago

0.19.48

3 years ago

0.19.49

3 years ago

0.19.47

3 years ago

0.19.45

3 years ago

0.19.46

3 years ago

0.19.44

3 years ago

0.19.43

3 years ago

0.19.42

3 years ago

0.19.40

3 years ago

0.19.41

3 years ago

0.19.39

3 years ago

0.19.38

3 years ago

0.19.37

3 years ago

0.19.36

3 years ago

0.19.34

3 years ago

0.19.29

3 years ago

0.19.33

3 years ago

0.19.30

3 years ago

0.19.32

3 years ago

0.19.26

3 years ago

0.19.23

3 years ago

0.19.24

3 years ago

0.19.25

3 years ago

0.19.22

4 years ago

0.19.21

4 years ago

0.19.18

4 years ago

0.19.19

4 years ago

0.19.11

4 years ago

0.19.12

4 years ago

0.19.13

4 years ago

0.19.14

4 years ago

0.19.15

4 years ago

0.19.16

4 years ago

0.19.10

4 years ago

0.19.9

4 years ago

0.19.8

4 years ago

0.19.7

4 years ago

0.19.6

4 years ago

0.19.5

4 years ago

0.19.4

4 years ago

0.19.3

4 years ago

0.19.2

4 years ago

0.19.1

4 years ago