Managing Crypto Payments With Co:Create SDK

Crypto Payments is a module that lets users purchase for your Co:Create-issued using ERC-20 and native tokens, bringing crypto-customers to your app.

Why use Crypto Payments?

Managing crypto payments natively is a complex task. It involves handling multiple wallets, tokens, and blockchains and their inherent complexities.

This module abstracts away native Blockchain properties that are hard and tedious to handle, such as gas fees, token approvals, and token transfers.

The following functions are available, and you can leverage them with ethersjs or wagmi:

FunctionDescriptionLibrary
purchase1155WithERC20TokenBuying an ERC-1155 collectible in ERC-Token.wagmi
purchase1155WithNativeTokenBuying an ERC-1155 with a native token (ETH, MATIC).wagmi
purchase721WithERC20TokenBuying an ERC-721 with a native token.wagmi
purchase721WithNativeTokenBuying an ERC-721 with a native token (ETH, MATIC).wagmi
ERC1155PurchaseBuying an ERC-1155 with a native token.ethersjs
ERC721PurchaseBuying an ERC-721 with a native token.ethersjs

Let's look at an example in which we enable end-users to buy an ERC-1155 collectible in ERC-20 tokens.

Example: Buying an ERC-1155 Collectible in ERC-20 Tokens

Prerequisites

  • Node 16 LTS or higher

  • NPM or Yarn

  • Your app to serve on localhost:3000

Installation

    npm install @usecocreate/sdk

Usage

Import the crypto_payments module from the SDK.

    import { crypto_payments } from "@usecocreate/sdk";

The example below shows the purchase1155WithERC20Token function enables end-users to buy an ERC-1155 collectible in ERC-20 tokens.

The following code is a stub: it won't run

    import { crypto_payments } from '@usecocreate/sdk';

    const contractAddress = '0x6e78892aaf4d32f1a9f4915e60530665fa5ea354';
    crypto_payments.wagmi
    .purchase1155WithERC20Token(contractAddress, buyerAddress, tokenId)
    .then(({ data }) => console.log(data))
    .catch((err) => console.error(err));

πŸ‘

Get Help

If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].