Overview
Simple Crypto's wallet solves all of the major user experience painpoints with a simple integration. Our wallet provides:
- email-authenticated custody
- embedded fiat to crypto onramp and offramp
- gasless and batched transactions
- NFT purchases with a card
- customized and whitelabeled UI
- ...and much more!
Getting started
The Simple Crypto Wallet SDK can only be used within browser environments because it relies
on browser globals like document
and window
. If your interface currently
uses Server Side Rendering and you need help integrating our SDK please reach
out.
Install
npm i @simplecrypto/wallet-sdk
pnpm i @simplecrypto/wallet-sdk
yarn add @simplecrypto/wallet-sdk
Import
ES Modules / Typescript
import SimpleCryptoSDK from "@simplecrypto/wallet-sdk";
const simpleCryptoWallet = new SimpleCryptoSDK();
CommonJS
const SimpleCryptoSDK = require("@simplecrypto/wallet-sdk");
const simpleCryptoWallet = new SimpleCryptoSDK();
Log a User In
Prompt the user to create an account or login using activate()
:
import SimpleCryptoSDK from "@simplecrypto/wallet-sdk";
const simpleCryptoWallet = new SimpleCryptoSDK();
const userAccount = await simpleCryptoWallet.activate();
You can also use the request()
function to log a user in. Under the hood, activate()
uses request()
but provides a more familiar interface.
import SimpleCryptoSDK from "@simplecrypto/wallet-sdk";
const simpleCryptoWallet = new SimpleCryptoSDK();
const [userAccount] = await simpleCryptoWallet.request({ method: "eth_requestAccounts" });
Send a Transaction
There are a couple ways to send transactions through Simple Crypto. In this example, we'll transfer the ERC20 token USDC on Polygon using the popular Ethereum library ethers.js.
ERC20 is a fungible token standard on Ethereum that many of the major tokens follow including USDC, USDT, and UNI.
import { ethers } from "ethers";
import SimpleCryptoSDK from "@simplecrypto/wallet-sdk";
const USDC_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
const TO_ADDRESS = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";
const simpleCryptoWallet = new SimpleCryptoSDK();
const provider = new ethers.providers.Web3Provider(simpleCryptoWallet);
/**
* Create an ethers.js Contract class which is a helpful class for interacting with your smart contracts.
* The constructor takes 3 arguments:
* 1. The address of the contract.
* 2. The ABI of the contract. Normally this is a JSON file but ethers also supports
* human readable ABIs like you see below
* 3. A "signer" which is used for signing and handling all requests to the blockchain.
* The signer will need to use Simple Crypto under the hood to make requests to Simple Crypto.
*/
const usdcContract = new ethers.Contract(
USDC_ADDRESS,
["function transfer(address to, uint256 amount) public returns (bool)"],
provider.getSigner(),
);
const transfer = await usdcContract.transfer(TO_ADDRESS, 1_000_000); // transfer 1 USDC