# Welcome to the Patch Docs

Welcome to the Patch Wallet Developer Documentation.

Patch wallets are web3 wallets attached to every Twitter, email, & phone number. The 1st "zero onboarding" wallet to send NFTs/tokens to your friends, family & customers.

Patch wallets use a [Kernel Account](https://github.com/PaymagicXYZ/zerodev-wallet-kernel) as its [EIP-4337 account abstraction](https://eips.ethereum.org/EIPS/eip-4337) smart contract wallet with the same address on all EVM chains.

Patch wallets are being used to:

* 🆕 Embed an Ethereum wallet in your app and remove "Connect Wallet" buttons entirely.
* 👨‍💼 Businesses can create wallets for users without onboarding, like Reddit Vaults.
* 🪂 Airdrop NFTs to all your Twitter followers or email audience. No need to collect ENS’s.
* 💐 Send an NFT birthday card to your mom’s Patch wallet.
* 🤲 Donate to a charity, cause, or artist via Twitter handle.

If you have questions, please reach out on [Discord](https://discord.gg/EAFPKSRyth).

**Quick Links**

* [Postman Collection](https://www.postman.com/paymagic/workspace/public-patch-wallet-api)
* [Kernel Account Smart Contracts](https://github.com/PaymagicXYZ/zerodev-wallet-kernel)
* [Read our origin story](https://launch.mirror.xyz/wDFf0PylbkZ70LKbxe_fmTeikvgbzsEfthcH7pCjlng)
* [Twitter](https://twitter.com/patchwallet)
* [Discord](https://discord.gg/EAFPKSRyth)


# Overview

Welcome to the Patch Wallet Developer Documentation.

This documentation provides the API references and information to use all Patch APIs.

## Quick Start

One API call to find a Web3 wallet address for anyone on the internet. 🌎

### 🔍 Get wallet address for a user\_id

To return a wallet address for **\******any*****\*** Twitter user, email, phone number, or other user ID, use:

1. [ENS Resolver](/api/ens-resolver-usr.id)
   1. ```
      const address = await provider.resolveName(`elonmusk.twitter.usr.id`);
      ```
2. [Resolver API](/api/resolver-api)
   1. ```powershell
      curl --location 'https://paymagicapi.com/v1/resolver' \
      --header 'Content-Type: text/plain' \
      --data-raw '{
          "userIds": "twitter:elonmusk,email:ur@mom69.com,tel:19198675309,github:torvalds"
      }'
      ```

[View examples on Postman](https://www.postman.com/paymagic/workspace/public-patch-wallet-api)

#### User IDs

Patch wallets function around the concept of a User ID, which gets you a unique account address.

A User ID is a unique provider and username ( like `twitter:elonmusk`, `tel:19198675309`, `email:test@gmail.com`) and returns a wallet address for them on a given chain (`matic:0xabc...123`).&#x20;

![](/files/mNZRZzYgofHDR5s3VjdI)

**Example userIds:**

* `twitter:elonmusk`
* `github:torvalds`
* `tel:19198675309`
* `email:your@mom.com`

### ✍️ Send a transaction or sign a message

To send a transaction or sign a message for a given Patch wallet, use the [Kernel Account API](/api/kernel-account-api).

You'll need to [authenticate](/api/app-authentication) first and then can send transactions like:

```powershell
curl --location 'https://paymagicapi.com/v1/kernel/tx' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
    "userId": "twitter:elonmusk",
    "chain": "matic",
    "to": ["0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"],
    "value": ["0"],
    "data": ["0xa9059cbb000000000000000000000000a969E3D8b4A376a59B15C70f29Deb08fbFab07810000000000000000000000000000000000000000000000000000000000002710"],
    "auth": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjc5NDYwODQ2LCJzdWIiOiI4YTFlODg2YS0xNmRjLTRlM2ItODg5MS04MWFiMjk3M2U5NjIiLCJlbWFpbCI6Imdlc2FnYTM0NzlAa2F1ZGF0LmNvbSIsInBob25lIjoiIiwiYXBwX21ldGFkYXRhIjp7InByb3ZpZGVyIjoiZW1haWwiLCJwcm92aWRlcnMiOlsiZW1haWwiXX0sInVzZXJfbWV0YWRhdGEiOnt9LCJyb2xlIjoiYXV0aGVudGljYXRlZCIsImFhbCI6ImFhbDEiLCJhbXIiOlt7Im1ldGhvZCI6Im90cCIsInRpbWVzdGFtcCI6MTY3OTQ1NzI0Nn1dLCJzZXNzaW9uX2lkIjoiMGRhMmQ4YmUtY2FiYS00MGRhLWE5ZTctOTliMjNlZmE4ZWExIn0.lfjj6YbJoCRSXRgW9vPg6Un0ck0NiBH6S97_gXUGKUE"
}'
```

### API Hostname

This API is maintained by [Paymagic Labs](https://paymagic.xyz/) and used at the `paymagicapi.com` hostname.

```bash
https://paymagicapi.com
```

If you have questions, please reach out on [Discord](https://discord.gg/EAFPKSRyth).

### Resources <a href="#authentication-and-rate-limiting" id="authentication-and-rate-limiting"></a>

<table data-view="cards"><thead><tr><th data-type="content-ref"></th><th></th></tr></thead><tbody><tr><td><a href="/pages/jdPyjuP4z0vRt0VKEtF1">/pages/jdPyjuP4z0vRt0VKEtF1</a></td><td>Create an API access token and authenticate your API requests.</td></tr><tr><td><a href="/pages/gVWwYXHJkruikFVlLUWm">/pages/gVWwYXHJkruikFVlLUWm</a></td><td>Learn about the API's error codes and how to handle them.</td></tr></tbody></table>


# App Authentication

Do not require authentication:

* [Resolver API](/api/resolver-api)

Do require authentication:

* [Kernel Account API](/api/kernel-account-api)

Authenticated Patch API endpoints use [OAuth 2.0 methods](https://oauth.net/2/) to authenticate requests.

**Get Started**

1. On [Discord](https://discord.gg/EAFPKSRyth), request a `client_id` and `client_secret`
2. Request a Bearer token via the `/v1/auth` endpoint
3. Provide the Bearer token in the `Authorization` header

### 1) Get a client\_id and client\_secret

On [Discord](https://discord.gg/EAFPKSRyth) request a `client_id` and `client_secret` to access the service.

### 2) Request a Bearer token

Use the script below to get a Bearer token for your `client_id` and `client_secret`.

```javascript
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("client_id", "demo-user-external");
urlencoded.append("client_secret", "k^yf57yg27MKo2SnuzwX");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://paymagicapi.com/v1/auth", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### 3) Call endpoints with Bearer token

API requests are authenticated using the [Bearer Auth scheme](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes). To authenticate a request, provide the Bearer token in the `Authorization` header of the request:

```bash
curl -H "Authorization: Bearer <your_bearer_token>" https://paymagicapi.com/v1
```

Bearer tokens expire every 60 minutes so a new one needs to be generated.


# User Authentication

All endpoints that require a Patch wallet signature, like to send transactions or sign a message, must go through user authentication. That includes the following endpoints:

* [Kernel Account API](/api/kernel-account-api)

There are 2 ways for Apps to authenticate users:

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Use native Patch auth:</strong></td><td><ul><li>Twitter</li><li>Email</li><li>Phone number</li><li>Github</li></ul></td></tr><tr><td><strong>Use your own auth:</strong></td><td><ul><li>Use Auth0, Clerk.com, or another service to authenticate users. Then push transactions through their wallets.</li><li>You get to choose your provider name like <code>uniswap</code>, <code>meta</code>, or <code>yourname</code>.</li></ul></td></tr></tbody></table>

### Use native Patch auth

{% hint style="info" %}
Due to the OAuth agreement and other restrictions, we only have Phone Number auth at this moment, other native auth are coming soon.
{% endhint %}

#### Phone Number

1. Trigger our auth server to send a verification token to a phone number

```bash
curl -L -X POST 'https://auth.paymagicapi.com/functions/v1/signInWithOTP' 
    --data '{"phone":"+1xxxxxxxxxx"}'
```

* Our server will send a SMS with 6 digit verification code to the phone number

## Trigger auth server to send verification token

<mark style="color:green;">`POST`</mark> `https://auth.paymagicapi.com/functions/v1/signInWithOTP`

#### Request Body

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| phone<mark style="color:red;">\*</mark> | String | US/Canada phone number with +1 area code |

{% tabs %}
{% tab title="200: OK {"message":"SMS Sent","user":null,"session":null,"messageId":"SM1edeccc59fc589d7ca8994df19a9ff75"}" %}

{% endtab %}
{% endtabs %}

2. Verify the code to get JWT token for transation authentication

```bash
curl -L -X POST 'https://auth.paymagicapi.com/functions/v1/verifyOTP' 
    --data '{"phone":"+1xxxxxxxxxx","token":"xxxxxx"}'

```

## Verify the code

<mark style="color:green;">`POST`</mark> `https://auth.paymagicapi.com/functions/v1/verifyOTP`

#### Request Body

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| phone<mark style="color:red;">\*</mark> | String | US/Canada phone number with +1 area code |
| token<mark style="color:red;">\*</mark> | String | 6 digit code from SMS                    |

### Use your own auth

1. On [Discord](https://discord.gg/EAFPKSRyth), request a `client_id` and `client_secret`
2. Tell us what type of auth provider you're using and we'll create a custom [Lit Action](https://developer.litprotocol.com/LitActions/intro) for signing.
3. Pass the specified data through the `auth` parameter on any Wallet API endpoints. During testing, you can leave the `auth` parameter blank.

```
curl --location 'https://paymagicapi.com/v1/kernel/tx' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
    "userId": "twitter:elonmusk",
    "chain": "matic",
    "to": ["0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"],
    "value": ["0"],
    "data": ["0xa9059cbb000000000000000000000000a969E3D8b4A376a59B15C70f29Deb08fbFab07810000000000000000000000000000000000000000000000000000000000002710"],
    "auth": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjc5NDYwODQ2LCJzdWIiOiI4YTFlODg2YS0xNmRjLTRlM2ItODg5MS04MWFiMjk3M2U5NjIiLCJlbWFpbCI6Imdlc2FnYTM0NzlAa2F1ZGF0LmNvbSIsInBob25lIjoiIiwiYXBwX21ldGFkYXRhIjp7InByb3ZpZGVyIjoiZW1haWwiLCJwcm92aWRlcnMiOlsiZW1haWwiXX0sInVzZXJfbWV0YWRhdGEiOnt9LCJyb2xlIjoiYXV0aGVudGljYXRlZCIsImFhbCI6ImFhbDEiLCJhbXIiOlt7Im1ldGhvZCI6Im90cCIsInRpbWVzdGFtcCI6MTY3OTQ1NzI0Nn1dLCJzZXNzaW9uX2lkIjoiMGRhMmQ4YmUtY2FiYS00MGRhLWE5ZTctOTliMjNlZmE4ZWExIn0.lfjj6YbJoCRSXRgW9vPg6Un0ck0NiBH6S97_gXUGKUE"
}'
```


# Resolver API

The Resolver API returns a wallet address for Twitter users, emails, phone numbers, and other user IDs.

One API call to find a Web3 wallet address for anyone on the internet.

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Web2 Providers</strong></td><td><ul><li><code>twitter</code></li><li><code>email</code></li><li><code>tel</code></li><li><code>github</code></li></ul></td></tr><tr><td><strong>App Providers</strong></td><td><ul><li>Get a wallet to embedded directly in your app. You control authentication.</li><li><em>Reach out on Discord</em></li></ul></td></tr><tr><td></td><td></td></tr></tbody></table>

### **How it Works**

Input a Twitter user, email, phone number, or any other user\_id and get a Patch Wallet address in return. It's that simple. The wallet is just like any other smart contract account and can store any tokens/NFTs.

{% hint style="info" %}
The Resolver API does not require authentication.
{% endhint %}

#### userId

A userId is a unique provider and username ( like `twitter:elonmusk`, `tel:19198675309`, `email:test@gmail.com`) and returns a wallet address for them on a given chain (`matic:0xabc...123`).&#x20;

**Example userIds:**

* `twitter:elonmusk`
* `github:torvalds`
* `tel:19198675309`
* `email:your@mom.com`

![](/files/mNZRZzYgofHDR5s3VjdI)

## Resolve userIds

To use, [check out our Postman collection here.](https://www.postman.com/paymagic/workspace/public-patch-wallet-api)

## Takes userIds and returns a list of account addresses

<mark style="color:green;">`POST`</mark> `https://paymagicapi.com/v1/resolver`

Takes userIds in the body seperated by "," and returns a list of account addresses.

*E.g.* `twitter:elonmusk,github:torvalds,email:test@gmail.com`&#x20;

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

#### Request Body

| Name                                      | Type   | Description                                                                 |
| ----------------------------------------- | ------ | --------------------------------------------------------------------------- |
| userIds<mark style="color:red;">\*</mark> | String | <p></p><p></p><p>a list of all the users separated by "," with no space</p> |

{% tabs %}
{% tab title="400: Bad Request Invalid request" %}

{% endtab %}

{% tab title="200: OK Return a list of wallet addresses" %}

```json
{
    "updatedAt":"2023-05-01T19:17:43.079Z",
    "users":
        [
            {
                "userId":"twitter:elonmusk",
                "accountAddress":"0x3A782C4B50CF4d82Ce489623E9204B8e4c6a133F"
            },
            {    
                "userId":"email:ur@mom69.com",
                "accountAddress":"0x65b49E21e717f115AadD4cA820f75EA65B69581f"
            },
            {
                "userId":"tel:19198675309",
                "accountAddress":"0xf1F4500871b4F7334De2577D0661Ac57FC94523A"
            },
            {
                "userId":"github:torvalds",
                "accountAddress":"0xDb17D7D1E13cbA8277B8F5FF55FE2d4606251C36"
            }
        ]
}
```

{% endtab %}
{% endtabs %}


# Kernel Account API

The Kernel Account API powers [Patch wallets](https://app.patchwallet.com) and controls the [EIP-4337 account abstraction](https://eips.ethereum.org/EIPS/eip-4337) smart contract wallets called, Kernel Accounts.

Kernel Accounts are a simple smart contract wallet with the same address on all EVM chains and connected to a user's email, social account, phone, or an app provider. The Kernel Account API can be used to submit a transaction or sign a message through a target wallet.

### Submit a Transaction

To send a transaction through a Kernel Account, see the Kernel Tx endpoint in Postman.

```javascript
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer {{access_token}}");

var raw = JSON.stringify({
  "userId": "test:elonmusk",
  "chain": "matic",
  "to": [
    "0x74427681c620DE258Aa53a382d6a4C865738A06C"
  ],
  "value": [
    "10000000000000"
  ],
  "data": [
    "0x"
  ],
  "delegatecall": 0, // Optional parameter. Set to 1 for a delegatecall().
  "auth": ""
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://paymagicapi.com/v1/kernel/tx", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### Sign a Message

Sign any arbitrary message using an EIP-1271 signature from your Patch wallet. Commonly used to sign into an application, submit a trade, or list an NFT on a marketplace.&#x20;

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://paymagicapi.com/v1/kernel/sign',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {{access_token}}'
  },
  body: JSON.stringify({
    "userId": "test:elonmusk",
    "hash": "0xec3608877ecbf8084c29896b7eab2a368b2b3c8d003288584d145613dfa4706c"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```


# ENS Resolver (usr.id)

Use the ENS resolver to find a wallet for any user

All Patch Wallets are compatible with ENS ([Ethereum Name Service](https://app.ens.domains/)) as a [usr.id](/api/ens-resolver-usr.id) subdomain, which means it's accessible in any wallet or dapp that supports ENS.

e.g. `elonmusk.twitter.usr.id` will resolve to Elon's Twitter Patch wallet. `19198675309.tel.usr.id` will resolve to the Patch wallet for that phone number.

All Patch Wallets ENS subdomains follow this format:

<table data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td></td><td>{username}.</td><td></td></tr><tr><td></td><td>{provider}</td><td></td></tr><tr><td></td><td>.usr.id</td><td></td></tr></tbody></table>

## Resolve a wallet

```javascript
// Resolve with ethers.js
const provider = new ethers.providers
const address = await provider.resolveName(`${username}.${provider}.usr.id`);
```


# Networks Supported

Patch Wallets are deployed on the chains below. Users' Patch wallets have the same address on all chains.

### Networks Supported

<table><thead><tr><th width="307">Chain</th><th width="126">Chain Type</th><th width="111">Contracts</th><th width="79">API</th><th>Patch App</th></tr></thead><tbody><tr><td>Polygon - <code>matic</code></td><td>Production</td><td>✅</td><td>✅</td><td>✅</td></tr><tr><td>Arbitrum - <code>arb1</code></td><td>Production</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Linea - <code>linea</code></td><td>Production</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Base - <code>base</code></td><td>Production</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Gnosis - <code>gno</code></td><td>Production</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Binance Smart Chain - <code>bnb</code></td><td>Production</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Zora - <code>zora-mainnet</code></td><td>Production</td><td>✅</td><td>🔜</td><td></td></tr><tr><td>Ethereum Mainnet - <code>eth</code></td><td>Production</td><td>✅</td><td>🔜</td><td></td></tr><tr><td>Optimism - <code>oeth</code></td><td>Production</td><td>🏗️</td><td></td><td></td></tr><tr><td>Polygon Mumbai - <code>maticmum</code></td><td>Testnet</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Optimism Goerli - <code>ogor</code></td><td>Testnet</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Arbitrum Goerli - <code>arb-goerli</code></td><td>Testnet</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Gnosis Testnet - <code>chi</code></td><td>Testnet</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Linea Testnet - <code>linea-testnet</code></td><td>Testnet</td><td>✅</td><td>✅</td><td></td></tr><tr><td>Zora Goerli - <code>zora-goerli</code></td><td>Testnet</td><td>✅</td><td>🔜</td><td></td></tr></tbody></table>

### Smart Contract Address

Smart contracts have the same address deployed to all EVM chains.

| Title                                     | Address                                                                                                                  |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| MultiECDSAFactoryPatch                    | [0x33DDF684dcc6937FfE59D8405aA80c41fB518C5c](https://polygonscan.com/address/0x33DDF684dcc6937FfE59D8405aA80c41fB518C5c) |
| MultiECDSAValidatorNew\.sol               | [0x9392c6a8a0b5d49cc697b8242d477509bae16700](https://polygonscan.com/address/0x9392c6a8a0b5d49cc697b8242d477509bae16700) |
| Patch Authority / Account owner (EOA)     | [0xdD664b8A02d3B13C0bdfB1878CbE66aA53B2de06](https://polygonscan.com/address/0xdD664b8A02d3B13C0bdfB1878CbE66aA53B2de06) |
| MultiECDSAKernelFactory.sol \[DEPRECATED] | [0xa7ac5B9d40D67e6cac7A975Bbf9b513Fb5EA8A60](https://polygonscan.com/address/0xa7ac5B9d40D67e6cac7A975Bbf9b513Fb5EA8A60) |
| KernelFactory.sol \[DEPRECATED]           | [0x83cc0a0869FB627C1154F2F263C1A438A1a5D51A](https://polygonscan.com/address/0x83cc0a0869FB627C1154F2F263C1A438A1a5D51A) |
| MultiECDSAValidator.sol \[DEPRECATED]     | [0x6549349c5B5269009748bdAD9F3cD63b57509411](https://polygonscan.com/address/0x6549349c5B5269009748bdAD9F3cD63b57509411) |
| BaseAccountFactory.sol \[DEPRECATED]      | [0x5d33b5b472c389355d97fe297cc7daf93d8bd4ab](https://polygonscan.com/address/0x5d33b5b472c389355d97fe297cc7daf93d8bd4ab) |

### Wallet Types

Patch wallets can have many different smart contract accounts attached to a user\_id but prioritizes one main account by default.

The past default accounts are below:

1. [Base Account](https://github.com/PaymagicXYZ/patch-base-account-contracts) - 2/27/2023 to 6/28/2023
2. [Kernel Account](https://github.com/PaymagicXYZ/zerodev-wallet-kernel) - 6/29/2023 to 8/28/2023
3. [Kernel 2.0 Account](https://github.com/PaymagicXYZ/kernel) - 8/29/2023


# Errors

Patch APIs uses conventional HTTP response codes to indicate the success or failure of an API request.

As a general rule:

* Codes in the `2xx` range indicate success
* Codes in the `4xx` range indicate incorrect or incomplete requests, like invalid paths, incorrect auth, or incorrect parameters for the request.
* Codes in the `5xx` range indicate an error in the server.


# Admin


# 🚧 🚧 🚧 Patch Maintenance 🚧 🚧 🚧

The Patch wallet app and API is down right now for maintenance.

The protocol smart contracts are accessible on all chains as always. 🙂

Check Twitter for when the app and API is back online:

<https://twitter.com/patchwallet>


# Other


# Request for Projects

#### *Wanna give a wallet to anyone on the internet?*

[Patch Wallet is a new account abstraction wallet](https://app.patchwallet.com/) tied to a user’s email, Twitter, or Github. It's a "zero onboarding wallet" so everyone on the internet has one automatically...without signing up.

Here are some of the project we'd like to see built on Patch wallets. If you'd like to work on any of them, [DM @patchwallet](https://twitter.com/patchwallet) and we'll help you get started and give you a bounty! 🤑

#### Request for Apps:

**EventDrop** - An app for crypto companies to use during events / conferences to distribute assets via email as they meet each other. Project should be able to setup a “campaign” which sends an NFT or group of tokens on demand. The Campaign has a page when anyone can enter their email and a trigger sends the digital assets to that wallet and sends an email to the user that they got assets. The email links for the user to view and transfer the assets.

**Mint a Tweet** - Anyone can submit any tweet and it’s minted as an NFT and anyone can pay to mint it. The point is to mint viral tweets early. All mint fees are split between the original tweeter, the first minter, and other early minters. Something like 40% to tweeter, 🥇30% to first minter, and 🏆2-10 split 30%. These early minters have an incentive to share the minted tweet to encourage more folks to participate.

**Alternative wallet UIs** - Every twitter/email user has a wallet address that can be found by calling [the /resolver endpoint](https://docs.paymagic.xyz/api/universal-resolver-api). From that wallet address you can query for token/NFT balances, tx history, and any other info via normal Polygon/Covalent/Alchemy APIs. Create a mobile app or browser extension that displays wallet information for each user…basically a better version of app.patchwallet.com!

**View celebrity / popular wallets** - Web apps for viewing popular twitter or celebrity wallets and allow easy tipping or sending NFTs.

**Tip ‘em** - Search for any user via their Twitter username, email, or soon telephone number and send them tokens or NFTs on Polygon. The user should get a notification that they received assets and be able to withdraw.

**Better SocialDrop.xyz** - Allow users to send out airdrops via Twitter/email/Github/phone number. Users get a notification and can claim the assets. A better version of SocialDrop.xyz.


# Base Account API \[DEPRECATED]

The Base Account API powers [Patch wallets](https://app.patchwallet.com) and controls the [EIP-4337 account abstraction](https://eips.ethereum.org/EIPS/eip-4337) smart contract wallets called, Base Accounts.

Base Accounts are a simple smart contract wallet with the same address on all EVM chains and connected to a user's email, social account, phone, or an app provider. They are centered around the concept of a `user_id` which is a combination of a `provider` and `username`.&#x20;

#### **user\_ids:**

* `twitter:elonmusk`
* `email:your@mom.com`
* `github:torvalds`
* `yourapp:userid123`

### Submit a Transaction

To send a transaction through a Base Account, see the [Base Tx endpoint on Postman](https://www.postman.com/paymagic/workspace/public-patch-wallet-api).

## Send a transaction through a Base Account on the target chain

<mark style="color:green;">`POST`</mark> `https://paymagicapi.com/v1/base/tx`

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

#### Request Body

| Name                                     | Type         | Description                                                                                                                                      |
| ---------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| data<mark style="color:red;">\*</mark>   | String Array | The data to pass in for the the transaction. Could be multiple fields for multiple transactions.                                                 |
| value<mark style="color:red;">\*</mark>  | String Array | The amount of native coins to send with the transaction. Could be multiple values for multiple transactions.                                     |
| to<mark style="color:red;">\*</mark>     | String Array | The contract address that the Base Account is calling. Could be multiple address for multiple transactions.                                      |
| chain<mark style="color:red;">\*</mark>  | String       | The ERC-3770 standard name for the target chain                                                                                                  |
| userId<mark style="color:red;">\*</mark> | String       | The userId of the wallet for the transaction                                                                                                     |
| auth<mark style="color:red;">\*</mark>   | String       | The corresponding auth token for the given wallet. The token will vary based on whether the userId is for a Twitter, email, or telephone wallet. |

{% tabs %}
{% tab title="400: Bad Request Invalid request" %}

{% endtab %}

{% tab title="200: OK Successfully submitted onchain" %}

{% endtab %}
{% endtabs %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{access_token}}");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "userId": "email:gesaga3479@kaudat.com",
  "chain": "matic",
  "to": [
    "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
  ],
  "value": [
    "0x00"
  ],
  "data": [
    "0xa9059cbb000000000000000000000000F2c47a58c1653b2b1E61010a2cE76ec8368C87Ba00000000000000000000000000000000000000000000000000000000000F4240"
  ],
  "auth": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjc5NDYwODQ2LCJzdWIiOiI4YTFlODg2YS0xNmRjLTRlM2ItODg5MS04MWFiMjk3M2U5NjIiLCJlbWFpbCI6Imdlc2FnYTM0NzlAa2F1ZGF0LmNvbSIsInBob25lIjoiIiwiYXBwX21ldGFkYXRhIjp7InByb3ZpZGVyIjoiZW1haWwiLCJwcm92aWRlcnMiOlsiZW1haWwiXX0sInVzZXJfbWV0YWRhdGEiOnt9LCJyb2xlIjoiYXV0aGVudGljYXRlZCIsImFhbCI6ImFhbDEiLCJhbXIiOlt7Im1ldGhvZCI6Im90cCIsInRpbWVzdGFtcCI6MTY3OTQ1NzI0Nn1dLCJzZXNzaW9uX2lkIjoiMGRhMmQ4YmUtY2FiYS00MGRhLWE5ZTctOTliMjNlZmE4ZWExIn0.lfjj6YbJoCRSXRgW9vPg6Un0ck0NiBH6S97_gXUGKUE"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("{{paymagicBaseUrl}}/base/tx", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### Sign a Message

*Coming Soon*


# DustSweeper API \[WIP]

Check open orders on DustSweeper

## Get Wallet Information

<mark style="color:blue;">`GET`</mark> `https://dustsweeper.com/api/[address]`

returns address, portfolio with token status, and past orders

#### Path Parameters

| Name                                      | Type   | Description                |
| ----------------------------------------- | ------ | -------------------------- |
| address<mark style="color:red;">\*</mark> | String | takes one ethereum address |

{% tabs %}
{% tab title="200: OK Returns balance, allowance, active orders, and past-orders." %}

```javascript
{
  "address": "0x4bd75fd7b7417d56f7c7a527d60cddb380c4955a",
  "portfolio": [
    {
      "token": {
        "symbol": "USDT",
        "contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "status": "sweepable"//sweepable, approved, unsupported
      },
      "balance": {
        "amount": 103,
        "asset_type": "USDT",
        "usd_value": 103.06413,
        "eth_value": 0.05124258793437055
      },
      "quote_rate": 1.0006226,
      "last_transferred_at": "2022-05-09T00:44:54Z",
      "sweeping_value": { "usd": 72.144891, "eth": 0.03586981155405939 }
    },
    ...
  ],
  "past_orders": [
    {
      "blockNum": 14706660,
      "time": "2022-05-03T19:59:02Z",
      "erc20": {
        "symbol": "YFI",
        "address": "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",
        "amount": "0.006"
      },
      "hash": "0x450da6ea901b0d5d48f5ce3aeae64f62a5978aa8bebe1af5e8b170e3d2f5e06d",
      "value": { "eth": "0.0261073722", "usd": 74.35802280915918 },
      "ethPrice": 2848.1619
    }...
  ]
}
```

{% endtab %}
{% endtabs %}

## Get All Orders:

<mark style="color:blue;">`GET`</mark> `https://dustsweeper.com/api/all-orders`

returns an array of all orders

{% tabs %}
{% tab title="200: OK returns an array of orders" %}

```javascript
{
  "balance": "1.897615593157632046",
  "symbol": "SUSHI",
  "maker": "0x049569adb8a1e8a9349e9f1111c7b7993a4612eb",
  "time": "2022-04-25T03:36:16Z",
  "tx": "0xb912085c60490ff4aa794ef6e566f19a0b24390553e2ce9d93f75e6eaea71bd7"
}
```

{% endtab %}
{% endtabs %}

## Get Open Orders:

<mark style="color:blue;">`GET`</mark> `https://dustsweeper.com/api/orders`

returns an array of open orders

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "balance": "18.978198959156383638",
  "token": ["SNX", "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f"],
  "maker": "0x492af9a0b99fed66dce727bb96ad133db83cdaf6",
  "time": "2022-03-17T04:52:12Z",
  "tx": "0xab51abf54b7d5a3d9687077135e24a0e0e89a7f04a9335c44eec80bb12dce028"
}
```

{% endtab %}
{% endtabs %}


# Safe Account API

The Safe Account API is centered around the concept of a [Gnosis Safe](https://gnosis-safe.io/) with a 1 of n multi-sig threshold where the customer controls one or more keys and Paymagic controls the other.

A Safe Accounts can be created automatically on any EVM network and used to automated transaction execution, batching, and gas management. Rather than worry about block reorgs, pending transactions, gas optimization, and rpc providers, developers can integrate with a simple RESTful API for executing any onchain transaction.

Once created, developers can access their Safe Account via a simple endpoint:

* On Ethereum Mainnet: */v1/**eth**/account/0xabc...def*
* On Goerli Testnet: */v1/**gor**/account/0xabc...def*
* On Polygon: */v1/**matic**/account/0xabc...def*
* On Optimism: */v1/**oeth**/account/0xabc...def*
* On Arbitrum: */v1/**arb1**/account/0xabc...def*

And use the Safe Account to:

* Submit any custom transaction
* Transfer any ERC20 and native token
* Disperse many ERC20 and native tokens
* Disperse many NFTs

| Supported Chains | Chain Type |
| ---------------- | ---------- |
| eth              | Live       |
| matic            | Live       |
| oeth             | Live       |
| arb1             | Live       |
| gor              | Testnet    |
| maticmum         | Testnet    |


# Accounts

Create a Safe Account or list the accounts you control via the endpoints below.

Technically, the endpoint creates a [Proxy Contract through the Gnosis Safe SDK](https://docs.gnosis-safe.io/build/sdks/core-sdk) and adds the signers parameter and Paymagic as a signer with a 1 of n threshold.

* POST /account
* POST /accounts


# Send Transactions

Once a Safe Account has been created, you can send transactions through that safe using the endpoints below.

* POST /custom
* POST /payout/disperse
* POST /payout/transfer
* POST /payout/disperseNFT


# View Transaction Status

Once you've submitted a transaction, you can check the transaction status using the endpoint below.

* GET /tx/{txUuid}


# Protocol


