|
| 1 | +{ |
| 2 | + "openrpc": "1.0.0", |
| 3 | + "info": { |
| 4 | + "title": "MetaMask Solana Wallet Snap JSON-RPC API", |
| 5 | + "description": "JSON-RPC API of the MetaMask Solana Wallet Snap. This snap brings official Solana support to MetaMask. Create accounts, check balances, and use Solana dApps right from your MetaMask wallet. Simple, secure, and seamless.", |
| 6 | + "version": "1.0.0", |
| 7 | + "contact": { |
| 8 | + "name": "New Networks Team" |
| 9 | + }, |
| 10 | + "license": { |
| 11 | + "name": "MIT" |
| 12 | + } |
| 13 | + }, |
| 14 | + "servers": [ |
| 15 | + { |
| 16 | + "name": "MetaMask Solana Wallet Snap", |
| 17 | + "url": "snap://npm:@metamask/solana-wallet-snap" |
| 18 | + } |
| 19 | + ], |
| 20 | + "methods": [ |
| 21 | + { |
| 22 | + "name": "client_signAndSendTransactionWithIntent", |
| 23 | + "summary": "Sign and send a transaction with verified intent", |
| 24 | + "description": "Allows the client (MetaMask) to request the snap to sign and send a transaction with verified intent.\n\n**Process:**\n\n1. **Verify Backend Signature** - Ensures the payload `{ intent, signature }` was signed by the trusted Swaps API\n2. **Match Transaction to Intent** - Verifies the transaction performs exactly what the intent describes\n3. **Sign Transaction** - If all validation pass, signs the transaction with the user's account specified in the intent\n4. **Send Transaction** - Sends the transaction to the Solana network", |
| 25 | + "params": [ |
| 26 | + { |
| 27 | + "name": "intent", |
| 28 | + "summary": "The user's intent describing the desired swap/bridge operation", |
| 29 | + "required": true, |
| 30 | + "schema": { |
| 31 | + "$ref": "#/components/schemas/Intent" |
| 32 | + } |
| 33 | + }, |
| 34 | + { |
| 35 | + "name": "transaction", |
| 36 | + "summary": "The base64-encoded transaction to sign and send", |
| 37 | + "required": true, |
| 38 | + "schema": { |
| 39 | + "type": "string" |
| 40 | + } |
| 41 | + }, |
| 42 | + { |
| 43 | + "name": "signature", |
| 44 | + "summary": "The result of signing the payload `{intent, transaction}` using <TODO SIGNING ALGORITHM> with the Swaps API's private key.", |
| 45 | + "required": true, |
| 46 | + "schema": { |
| 47 | + "type": "string" |
| 48 | + } |
| 49 | + } |
| 50 | + ], |
| 51 | + "result": { |
| 52 | + "name": "SignAndSendTransactionWithIntentResult", |
| 53 | + "summary": "The result of signing and sending a transaction with intent", |
| 54 | + "schema": { |
| 55 | + "$ref": "#/components/schemas/SignAndSendTransactionWithIntentResult" |
| 56 | + } |
| 57 | + }, |
| 58 | + "examples": [ |
| 59 | + { |
| 60 | + "name": "signAndSendTransactionWithIntentExample", |
| 61 | + "description": "Example of signing and sending a transaction with intent, where user wants to swap 1 SOL for 161.18 USDC.", |
| 62 | + "params": [ |
| 63 | + { |
| 64 | + "name": "intent", |
| 65 | + "value": { |
| 66 | + "id": "c76b3834-b9a8-4dfd-91da-72c26a216fb2", |
| 67 | + "timestamp": "2021-01-01T00:00:00Z", |
| 68 | + "accountId": "9ce0cc70-9c04-48f7-a3dc-d9c1496ac229", |
| 69 | + "from": { |
| 70 | + "assetType": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501", |
| 71 | + "amount": "1000000000" |
| 72 | + }, |
| 73 | + "to": { |
| 74 | + "assetType": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", |
| 75 | + "amount": "161180000" |
| 76 | + } |
| 77 | + } |
| 78 | + }, |
| 79 | + { |
| 80 | + "name": "transaction", |
| 81 | + "value": "gAEAChfds67pR0IYlL1XKFGjzC+zBZIA7vT1dj7nUBTUwAs7rBn3hrWmXImk+UetGwvWumZpcEhF+xT5THD5os2Svp67H8GdfJ4jkOslaYOff/X0SeF33Cha5Ij9DKlo3QaosfIhtgnDmdJAVdjfmyv5dEGsSWgYEYPaqW8v8hSJozhYIzcQa4p5MinFjNMq4vDm+n249hE5Vmwe+Adkq87GTDegPbdaVhuqlrT5hZnIkdcW67eCFvm9ZzXM9jeWm2GwnLBGfnLp6qHLD5IgtqLXr5clzwoa2ns4KdysosGA2y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JAg8EBgoMCwYQBw==" |
| 82 | + }, |
| 83 | + { |
| 84 | + "name": "signature", |
| 85 | + "value": "DuvWiKG54eKcB1s777TgaZWtF9R23sVuEaugRufdXyqhCf6owy5hYqxeL8sa6zoCPVQu3NxxhjWuz91CKgLE6SB" |
| 86 | + } |
| 87 | + ], |
| 88 | + "result": { |
| 89 | + "name": "signAndSendTransactionWithIntentResult", |
| 90 | + "value": { |
| 91 | + "signature": "DuvWiKG54eKcB1s777TgaZWtF9R23sVuEaugRufdXyqhCf6owy5hYqxeL8sa6zoCPVQu3NxxhjWuz91CKgLE6SB", |
| 92 | + "intent": { |
| 93 | + "id": "c76b3834-b9a8-4dfd-91da-72c26a216fb2", |
| 94 | + "timestamp": "2021-01-01T00:00:00Z", |
| 95 | + "accountId": "9ce0cc70-9c04-48f7-a3dc-d9c1496ac229", |
| 96 | + "from": { |
| 97 | + "assetType": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501", |
| 98 | + "amount": "1000000000" |
| 99 | + }, |
| 100 | + "to": { |
| 101 | + "assetType": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", |
| 102 | + "amount": "161180000" |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + ] |
| 109 | + } |
| 110 | + ], |
| 111 | + "components": { |
| 112 | + "schemas": { |
| 113 | + "Iso8601Timestamp": { |
| 114 | + "type": "string", |
| 115 | + "format": "date-time", |
| 116 | + "description": "An ISO 8601 timestamp", |
| 117 | + "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", |
| 118 | + "examples": ["2021-01-01T00:00:00Z", "2021-01-01T00:00:00.000Z"] |
| 119 | + }, |
| 120 | + "UuidV4": { |
| 121 | + "type": "string", |
| 122 | + "format": "uuid", |
| 123 | + "description": "A UUID version 4 identifier", |
| 124 | + "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", |
| 125 | + "examples": [ |
| 126 | + "550e8400-e29b-41d4-a716-446655440000", |
| 127 | + "6ba7b810-9dad-11d1-80b4-00c04fd430c8" |
| 128 | + ] |
| 129 | + }, |
| 130 | + "Intent": { |
| 131 | + "type": "object", |
| 132 | + "description": "Represents a user's intent to perform a swap or bridge operation", |
| 133 | + "properties": { |
| 134 | + "id": { |
| 135 | + "$ref": "#/components/schemas/UuidV4", |
| 136 | + "description": "Unique identifier for the intent" |
| 137 | + }, |
| 138 | + "timestamp": { |
| 139 | + "$ref": "#/components/schemas/Iso8601Timestamp", |
| 140 | + "description": "ISO 8601 timestamp when the intent was created" |
| 141 | + }, |
| 142 | + "accountId": { |
| 143 | + "type": "string", |
| 144 | + "description": "The identifier of the account to sign the transaction with" |
| 145 | + }, |
| 146 | + "from": { |
| 147 | + "$ref": "#/components/schemas/AssetAmount", |
| 148 | + "description": "The asset and amount the user wants to send" |
| 149 | + }, |
| 150 | + "to": { |
| 151 | + "$ref": "#/components/schemas/AssetAmount", |
| 152 | + "description": "The asset and amount the user expects to receive" |
| 153 | + } |
| 154 | + }, |
| 155 | + "required": ["id", "timestamp", "accountId", "from", "to"], |
| 156 | + "additionalProperties": false |
| 157 | + }, |
| 158 | + "AssetAmount": { |
| 159 | + "type": "object", |
| 160 | + "description": "Represents an asset and its amount", |
| 161 | + "properties": { |
| 162 | + "assetType": { |
| 163 | + "type": "string", |
| 164 | + "description": "CAIP-19 asset type (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501' for SOL)" |
| 165 | + }, |
| 166 | + "amount": { |
| 167 | + "type": "string", |
| 168 | + "description": "Amount in the asset's smallest unit (e.g., lamports for SOL)" |
| 169 | + } |
| 170 | + }, |
| 171 | + "required": ["assetType", "amount"], |
| 172 | + "additionalProperties": false |
| 173 | + }, |
| 174 | + "SignAndSendTransactionWithIntentResult": { |
| 175 | + "type": "object", |
| 176 | + "description": "Result of signing and sending a transaction with intent", |
| 177 | + "properties": { |
| 178 | + "signature": { |
| 179 | + "type": "string", |
| 180 | + "description": "The transaction signature returned after successful execution on Solana" |
| 181 | + }, |
| 182 | + "intent": { |
| 183 | + "$ref": "#/components/schemas/Intent", |
| 184 | + "description": "The original intent that was fulfilled, returned for assurance that the intent was fulfilled" |
| 185 | + } |
| 186 | + }, |
| 187 | + "required": ["signature", "intent"], |
| 188 | + "additionalProperties": false |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | +} |
0 commit comments