Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
hughescoin committed Dec 21, 2024
1 parent 4efce08 commit 7429a11
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
## Coinbase Wallet API
# Coinbase Wallet API - Spend Permissions

### `coinbase_fetchPermissions`
The `coinbase_fetchPermissions` RPC method retrieves permissions associated with a specific account, chain, and spender. This method excludes permissions that have expired or been revoked.

A utility API endpoint for recalling permissions previously granted for a specific user.
Excludes permissions that have expired or been revoked.
## Overview

#### Schema
**RPC Method:** `coinbase_fetchPermissions`

**Endpoint:** `https://rpc.wallet.coinbase.com`

This RPC method allows you to query active spend permissions for an account on a specific chain and spender.

## Example Request

Below is an example of how to use the `coinbase_fetchPermissions` method with a cURL request:

```bash
curl --location 'https://rpc.wallet.coinbase.com' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "coinbase_fetchPermissions",
"params": [
{
"account": "0xfB2adc8629FC9F54e243377ffcECEb437a42934C",
"chainId": "0x14A34",
"spender": "0x2a83b0e4462449660b6e7567b2c81ac6d04d877d"
}
],
"id": 1
}'
```

## Request Schema

```typescript
type FetchPermissionsRequest = {
chainId: string; // hex, uint256
account: string; // address
spender: string; // address
pageOptions?: {
pageSize number; // number of items requested, defaults to 50
cursor string; // identifier for where the page should start
}
}
pageSize: number; // number of items requested, defaults to 50
cursor: string; // identifier for where the page should start
};
};
```

### Parameters

- **`chainId`**: The ID of the blockchain, in hexadecimal format.
- **`account`**: The address of the account whose permissions are being queried.
- **`spender`**: The entity granted with the permission to spend the `account`'s funds.
- **`pageOptions`** _(optional)_:
- **`pageSize`**: The number of permissions to fetch in a single request (default: 50).
- **`cursor`**: A unique identifier to start fetching from a specific page.

## Response Schema

```typescript
type FetchPermissionsResult = {
permissions: FetchPermissionsResultItem[];
pageDescription: {
pageSize number; // number of items returned
nextCursor string; // identifier for where the next page should start
}
}
pageSize: number; // number of items returned
nextCursor: string; // identifier for where the next page should start
};
};

type FetchPermissionsResultItem = {
createdAt: number; // UTC timestamp for when the permission was granted
Expand All @@ -43,5 +80,33 @@ type FetchPermissionsResultItem = {
salt: string; // base 10 numeric string
extraData: string; // hex
};
}
};
```

### Fields

- **`permissions`**: An array of permission objects.
- **`pageDescription`**:
- **`pageSize`**: Number of permissions returned in this response.
- **`nextCursor`**: The cursor to be used for the next page of results.

### Permission Object

- **`createdAt`**: The UTC timestamp when the permission was granted.
- **`permissionHash`**: A unique hash representing the permission.
- **`signature`**: The cryptographic signature for the permission.
- **`permission`**:
- **`account`**: The address of the account granting the permission.
- **`spender`**: The address of the spender receiving the permission.
- **`token`**: The address of the token involved.
- **`allowance`**: The amount allowed, represented as a base 10 numeric string.
- **`period`**: Duration of the permission in Unix seconds.
- **`start`**: Start time of the permission in Unix seconds.
- **`end`**: End time of the permission in Unix seconds.
- **`salt`**: A unique salt value as a base 10 numeric string.
- **`extraData`**: Additional data in hexadecimal format.

## Notes

- Ensure the `chainId`, `account`, and `spender` parameters are correctly formatted and valid for the blockchain you are querying.
- This RPC method only returns active permissions.
2 changes: 1 addition & 1 deletion vocs.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default defineConfig({
link: "/guides/spend-permissions/api-reference/spendpermissionmanager",
},
{
text: "coinbase_fetchPermissions",
text: "Fetch Permissions API",
link: "/guides/spend-permissions/api-reference/coinbase-fetchpermissions",
},
{
Expand Down

0 comments on commit 7429a11

Please sign in to comment.