Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs]: Update Spend Permissions Page + Sidebar with more details #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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