Subscribe to our Blog

Subscribe to Crossmint's blog to receive updates on the latest case studies, Web3 technical guides, and more.

Subscribe Crossmint Blog cover image
Alfonso Gomez Jordana profile image Alfonso Gomez Jordana

How to Create Wallets on Polygon?

Learn how to create custodial wallets for your users on Polygon in under 5 mins!

Creating polygon (MATIC) wallets

Simplify user onboarding in Web3 by creating custodial wallets effortlessly using Crossmint's Wallets API.

Why Use Custodial Wallets?

Onboarding new users to Web3 can be challenging. Crossmint’s custodial wallets provide a seamless experience by abstracting blockchain complexity, allowing users to interact with your application without managing complex wallet credentials.

You can use Crossmint Auth to manage custodial wallets and authenticate users using web3 or traditional sign-in methods like Email OTP, Social Accounts (Google, Apple, X, etc) and Farcaster.

Additionally, Crossmint also offers Smart Wallets which are non-custodial wallets where your users control the private keys and handle transaction signing. This type of wallet is perfect for traditional web3 experiences where users want direct control over their assets.

This guide will show you how to create custodial wallets for your users on Polygon using Crossmint.

Getting Started: Prerequisites

1. Create a Crossmint Developer Account

2. Generate API Keys

Navigate to the "Developers" section and create a Server-side API Key:

  • Select essential scopes:
    • "wallets.read"
    • "wallets.create"

You need the scopes specified above to create wallets.

Creating Custodial Wallets on Polygon

Use the following code to create wallets via email:

const options = {
  method: "POST",
  headers: {
    "X-API-KEY": "<your-api-key-here>",
    "Content-Type": "application/json"
  },
  body: '{"email":"yourEmail@email.com","chain":"polygon"}'
};

fetch("<https://www.crossmint.com/api/v1-alpha1/wallets>", options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));

  • Replace "<your-api-key-here>" with the API key that you created earlier.
  • Replace "yourEmail@email.com" with the actual email address of the user that you are trying to create the wallet for.

Alternatively, you can create wallets by UserID:

const options = {
  method: "POST",
  headers: {
    "X-API-KEY": "<your-api-key-here>",
    "Content-Type": "application/json"
  },
  body: '{"userId":"anyUserId","chain":"polygon"}'
};

fetch("<https://www.crossmint.com/api/v1-alpha1/wallets>", options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));

Response Example

{
  "chain": "polygon",
  "publicKey": "0xYourWalletAddress"
}

Pro Tips

  • Use the staging environment (staging.crossmint.com/console) for testing
  • Replace placeholders with your actual API key and user information
  • Run the script using Node.js: node createWallet.js

Next Steps

Ready to dive deeper?

Need Support?

Sign up developer console