Cede.store Provider API
Cede.store exposes its API via a JavaScript object in the web page. This object is called "the Provider". It partially
follows the EIP-1193 (opens in a new tab) specification that most DeFi wallets use. This object is
injected when the page loads and available as window.cede
. More detailed information on how to use our provider is
presented below on this page.
Why EIP-1193? Because it's the most popular standard for DeFi wallet interaction. As we work to simplify the integration with cede.store and maintain the same user experience (UX) as other DeFi wallets, we have chosen to follow this specification. However, we do not implement all of its methods, since we offer different features from traditional DeFi wallets. For example, we don't communicate with the blockchain, so we don't have any signing methods.
This API allows websites to request users' CEX accounts, read data from the CEX the user is connected to, read public data from CEX thanks to our infrastructure, and suggest HTTP requests for the user to sign and send those to CEX.
We recommend using our npm package @cedelabs/providers (opens in a new tab) to detect our provider. It provides a strongly typed interface of Provider API and automatic method versioning.
Provider API
Provider state
Cede Provider has 3 state variables:
isConnected
-true
means that the provider can serve RPC requests. Iffalse
, the dApp page should be reloaded.isUnlocked
-true
means that the extension is unlocked and dApp can call any available method. Iffalse
, the dApp should first call "connect" methodvaultPreviews
- Vault Previews object containing vaults and CEX (check connection example)
API calls
If you do not use our provider from @cedelabs/providers (opens in a new tab) package,
you need to provide the method version by adding a version
field to parameters.
To communicate with the extension, use:
provider.request( method: "method", params: { param1: "" })
If you do not use @cedelabs/providers (opens in a new tab) package, use:
window.cede.request( method: "method", params: { param1: "", version: 1 })
You'll find examples in the following pages.
Notifications
To handle notifications, you should subscribe to Cede Provider events like this:
provider.on("event type", () => console.log("your callback"));
Currently, Provider can emit the following event types:
"connect"
- when a communication channel is established between the dApp and cede.store (so we can call RPC methods)
"accountsChanged"
- when a dApp connects to cede.store (opens in a new tab) (user approved a new dApp connection or already known dApps has been connected)
- when there are vault modification (vault added/removed/changed)
- when a vault is connected/disconnected to a dApp
"unlock"
- when a dApp connects to cede.store (opens in a new tab) (user approved a new dApp connection or already known dApps has been connected)
- when a user unlocks the extension (though the popup)
"lock"
- when a user removes a dApps from connected dApps list
- when a user disonnects all the connected vaults
- when a user switches from a demo vault to real vault or vice versa: all connected dApps are removed
- when the extension locks due to the inactivity or because of the user (click on “lock” button)
"exchangesStatusesUpdate"
- when an exchange's server is back online
- when an exchange's server is offline
Errors
When making requests to cede.store extension, you can get the following list of errors. Note that the error codes are not following the JSON-RPC standard for now, but we are working on it.
Cede.store Errors
Code | Message | Description |
---|---|---|
5000 | Dispatcher default error | An error occured while executing the method. |
5001 | Approval not found | The approval isn't found. This can happen if the approval is not in pending approvals array |
5002 | Vault is not allowed to access | You aren't allowed to access to this vault |
5003 | Account does not have sufficient permissions to perform this action | The account doesn't have the permission to perform this action. If the account is read-only, you can't perform trades/withdrawals |
5005 | Not connected | Connect with cede.store to perfom this request |
5006 | Not initialized | Raised when cede.store has been downloaded but not initialized. The user must set up at least one vault in the cede.store first |
5008 | This feature is not supported by the {account} | Verify if the feature is supported by the CEX |
5009 | User denied approval | User denied approval |
5010 | Invalid set of permissions | The account has an invalid set of permissions |
5011 | Method not available | The provider was requested to perform an action on an exchange that does not support the action |
5012 | Invalid key permissions | API key permissions aren't valid, you should add missing permissions to the key and try again |
5100 | Vault not found | The vault was not found. Verify the vauld id |
5101 | Vault account not found | The account was not found. Verify the account name |
5102 | Vaults cannot be retrieved | Raised when the vaults cannot be retrieved from cede.store |
5103 | An error occured while generating the account name | The generate account name method shouldn't fail |
5104 | An error occured while validating the account name | The validate account name method shouldn't fail |
5105 | An error occured while updating the account name | Verify if the old account name is valid because we are using it to update the account |
5106 | An error occured while getting the account | Verify if the account id is valid |
5107 | An error occured while getting the accounts | Verify if the vault id is valid |
5108 | The account is not an OAuth account | This error is raised when we try to perform an action on an OAuth account and the account is not using OAuth |
5109 | The account already contains these API keys | The account already contains the API keys added for different permissions. The CEX requires different keys for different permissions. |
5201 | Cannot fetch ticker from token | Raised when the ticker for a given token symbol cannot be retrieved from the CEX |
5204 | Exchange's server is down | Raised when the exchange server status is offline. |
5205 | Exchange is under maintenance | Raised when the exchange server status is under maintenance. |
5206 | Supported tokens not found | Raised when getSupportedTokens returns an error. |
5207 | The exchange is not available in this country | Raised when the exchange is not available in this country |
5210 | Cannot retrieve vault portfolio from CEX | Raised when the portfolio cannot be retrieved from the CEX |
5211 | NFTs cannot be fetched from CEX | Raised when the NFTs cannot be retrieved from the CEX |
5220 | Cannot retrieve vault transactions | Raised when the transactions cannot be retrieved from the CEX |
5230 | Cannot get depositable tokens | Raised when the depositable tokens cannot be retrieved from the CEX |
5231 | Cannot get deposit address | Raised when the deposit address cannot be retrieved from the CEX |
5240 | Error encountered while posting order | Raised when the order cannot be posted to the CEX |
5241 | Market pairs cannot be fetched | Raised when the market pairs cannot be retrieved from the CEX |
5242 | Tickers cannot be fetched from symbols | Raised when the tickers cannot be retrieved from the CEX |
5243 | Order not found | Raised when the order cannot be found on the CEX |
5244 | Minimum amount error | Raised when the amount is too low to execute the trade |
5245 | Ticker not found | Raised when the ticker cannot be found on the CEX |
5246 | Invalid order request | This error is triggered by invalid order requests. It could arise due to inappropriate data inputs, such as a price set to zero. To streamline error handling, we avoid generating overly specific errors for each scenario. This approach assumes that proper data validation is performed within the dApp, ensuring user inputs are correct. |
5247 | Market rates cannot be fetched | Raised when market rates cannot be retrieved from the CEX |
5248 | Trade path cannot be fetched | Raised when trade path cannot be retrieved from the CEX |
5250 | Network not found | Raised when the network isn't found |
5251 | Network not provided | Raised when the network is not provided, but required |
5252 | Networks are not standardized | Raised when the networks are not standardized |
5260 | Error encountered while withdrawing token to DeFi address | Raised when the withdrawal cannot be posted to DeFi address |
5261 | Error encountered while withdrawing token to another CEX | Raised when the withdrawal cannot be posted to the CEX |
5262 | Withdrawal not found | Raised when the withdrawal isn't found |
5263 | Withdrawal info error | Raised when the withdrawal info cannot be retrieved from the CEX |
5268 | Invalid address | Raised when the address is invalid |
5270 | Coinbase account not found | Raised when the account for currency cannot be found on the CEX |
5293 | Exchange instance not found | Raised when the exchange instance was not found |
5301 | Connection has been interrupted. Please try again. | Raised when the OAuth flow is interrupted by the user (e.g. user closes the authorization popup) |
5400 | NFTs are not supported | NFTs aren't supported on the given exchange |
1000 | cede.store default error | Something went wrong in cede.store |
RPC Errors
Code | Message | Description |
---|---|---|
-32700 | JSON parsing error | An error occurred on the server while parsing the JSON text |
-32600 | Invalid request object | The JSON sent is not a valid Request object |
-32601 | Method not found | The method does not exist / is not available |
-32602 | Invalid method parameter(s) | Provided parameters do not match the method signature |
-32603 | Internal JSON-RPC error | Something went wrong in the communication engine of cede.store |
Exchange Specific Errors
Code | Message | Description |
---|---|---|
3000 | CEX error | The exchange has a system abnormality. The original exchange error is provided. |
3001 | Request expired | The request has expired |
You can retrieve the errors in the following way:
import {CedeErrors} from "@cedelabs/providers";