The Safes API is used to query the card protocol about the gnosis safes in the layer 2 network in which the Card Protocol runs. This can includes safes in which bridged tokens are deposited as well as prepaid cards (which in turn are actually gnosis safes). The Safes 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 safes = await getSDK('Safes', web3);

Hierarchy

  • Safes

Implements

Constructors

Properties

layer2Web3: default
layer2Signer?: Signer

Methods

  • This call is used to view a specific safe in the layer 2 network in which the Card Protocol runs.

    Returns

    promise for an object that contains a Safe and the block number at which the subgraph was last indexed:

    Example

    let safeDetails = await safes.viewSafe(safeAddress); // returns { safe: Safe | undefined; blockNumber: number; }
    

    Parameters

    • safeAddress: string

    Returns Promise<ViewSafeResult>

  • This call will return the gas estimate for sending tokens from a safe.

    Remarks

    Note that the returned amount is in units of the token specified in the function params, tokenAddress

    Parameters

    • safeAddress: string

      the address of the gnosis safe

    • tokenAddress: string

      the address of the token contract

    • recipient: string

      the address of the recipient

    • amount: string

      optionally, amount of tokens to send as a string in native units of the token (e.g. wei)

    Returns Promise<string>

  • This call is used to send tokens from a gnosis safe to an arbitrary address in the layer 2 network. Note that the gas will be paid with the token you are transferring so there must be enough token balance in teh safe to cover both the transferred amount of tokens and gas.

    Returns

    a promise for a web3 transaction receipt.

    Example

    let cardCpxd = await getAddress('cardCpxd', web3);
    let result = await safes.sendTokens(
    depotSafeAddress,
    cardCpxd,
    relayTxnFunderAddress
    [10000000000000000000000]
    );

    Remarks

    Note that the returned amount is in units of the token specified in the function params, tokenAddress

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • safeAddress: string
    • tokenAddress: string
    • recipient: string
    • Optional amount: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • tokenAddress: string
    • recipient: string
    • amount: BN

    Returns string

Generated using TypeDoc