Providers Package
Provider API Reference
Cede Provider

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.

  1. Basic usage
  2. Read methods
  3. Write methods
  4. Custom methods

Provider API

Provider state

Cede Provider has 3 state variables:

  • isConnected - true means that the provider can serve RPC requests. If false, the dApp page should be reloaded.
  • isUnlocked - true means that the extension is unlocked and dApp can call any available method. If false, the dApp should first call "connect" method
  • vaultPreviews - 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

CodeMessageDescription
5000Dispatcher default errorAn error occured while executing the method.
5001Approval not foundThe approval isn't found. This can happen if the approval is not in pending approvals array
5002Vault is not allowed to accessYou aren't allowed to access to this vault
5003Account does not have sufficient permissions to perform this actionThe account doesn't have the permission to perform this action. If the account is read-only, you can't perform trades/withdrawals
5004Method not allowedYou aren't available to access to the given method
5005Not connectedConnect with cede.store to perfom this request
5006Not initializedRaised when cede.store has been downloaded but not initialized. The user must set up at least one vault in the cede.store first
5007Access token revokedRaised when user adds an account via OAuth2. The user must remove and add the account again to get the new access token.
5008This feature is not supported by the {account}Verify if the feature is supported by the CEX
5009User denied approvalUser denied approval
5010Invalid set of permissionsThe account has an invalid set of permissions
5011Method not availableThe provider was requested to perform an action on an exchange that does not support the action
5012Invalid key permissionsAPI key permissions aren't valid, you should add missing permissions to the key and try again
5100Vault not foundThe vault was not found. Verify the vauld id
5101Vault account not foundThe account was not found. Verify the account name
5102Vaults cannot be retrievedRaised when the vaults cannot be retrieved from cede.store
5103An error occured while generating the account nameThe generate account name method shouldn't fail
5104An error occured while validating the account nameThe validate account name method shouldn't fail
5105An error occured while updating the account nameVerify if the old account name is valid because we are using it to update the account
5106An error occured while getting the accountVerify if the account id is valid
5107An error occured while getting the accountsVerify if the vault id is valid
5108The account is not an OAuth accountThis error is raised when we try to perform an action on an OAuth account and the account is not using OAuth
5109The account already contains these API keysThe account already contains the API keys added for different permissions. The CEX requires different keys for different permissions.
5201Cannot fetch ticker from tokenRaised when the ticker for a given token symbol cannot be retrieved from the CEX
5202Token not foundRaised when the token cannot be found on the CEX
5203Market not foundRaised when the market cannot be found on the CEX
5204Exchange's server is downRaised when the exchange server status is offline.
5205Exchange is under maintenanceRaised when the exchange server status is under maintenance.
5206Supported tokens not foundRaised when getSupportedTokens returns an error.
5207The exchange is not available in this countryRaised when the exchange is not available in this country
5210Cannot retrieve vault portfolio from CEXRaised when the portfolio cannot be retrieved from the CEX
5211NFTs cannot be fetched from CEXRaised when the NFTs cannot be retrieved from the CEX
5220Cannot retrieve vault transactionsRaised when the transactions cannot be retrieved from the CEX
5230Cannot get depositable tokensRaised when the depositable tokens cannot be retrieved from the CEX
5231Cannot get deposit addressRaised when the deposit address cannot be retrieved from the CEX
5240Error encountered while posting orderRaised when the order cannot be posted to the CEX
5241Market pairs cannot be fetchedRaised when the market pairs cannot be retrieved from the CEX
5242Tickers cannot be fetched from symbolsRaised when the tickers cannot be retrieved from the CEX
5243Order not foundRaised when the order cannot be found on the CEX
5244Minimum amount errorRaised when the amount is too low to execute the trade
5245Ticker not foundRaised when the ticker cannot be found on the CEX
5246Invalid order requestThis 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.
5247Market rates cannot be fetchedRaised when market rates cannot be retrieved from the CEX
5248Trade path cannot be fetchedRaised when trade path cannot be retrieved from the CEX
5250Network not foundRaised when the network isn't found
5251Network not providedRaised when the network is not provided, but required
5252Networks are not standardizedRaised when the networks are not standardized
5260Error encountered while withdrawing token to DeFi addressRaised when the withdrawal cannot be posted to DeFi address
5261Error encountered while withdrawing token to another CEXRaised when the withdrawal cannot be posted to the CEX
5262Withdrawal not foundRaised when the withdrawal isn't found
5263Withdrawal info errorRaised when the withdrawal info cannot be retrieved from the CEX
5265Not enough balance to withdrawRaised when the balance hasn't enough funds to execute the withdrawal
5266Amount under the minimum withdrawal amountRaised when the amount is under the minimum withdrawal amount
5267Amont over the maximum withdrawal amountRaised when the amount is over the maximum withdrawal amount
5268Invalid addressRaised when the address is invalid
5270Coinbase account not foundRaised when the account for currency cannot be found on the CEX
5280Read-only Binance account not providedRaised when the read-only Binance account was not provided
5290Error encountered while registering an exchange instanceRaised when the exchange id isn't recognized
5291Error encountered while getting an exchange instanceRaised when the exchange instance id isn't recognized
5292Error encountered while checking credentials of an exchange instanceRaised when the credentials are invalid
5293Exchange instance not foundRaised when the exchange instance was not found
5300Authentication flow not supportedRaised when the authentication flow is not supported
5301Connection has been interrupted. Please try again.Raised when the OAuth flow is interrupted by the user (e.g. user closes the authorization popup)
5400NFTs are not supportedNFTs aren't supported on the given exchange
1000cede.store default errorSomething went wrong in cede.store

RPC Errors

CodeMessageDescription
-32700JSON parsing errorAn error occurred on the server while parsing the JSON text
-32600Invalid request objectThe JSON sent is not a valid Request object
-32601Method not foundThe method does not exist / is not available
-32602Invalid method parameter(s)Provided parameters do not match the method signature
-32603Internal JSON-RPC errorSomething went wrong in the communication engine of cede.store

Exchange Specific Errors

CodeMessageDescription
3000CEX errorThe exchange has a system abnormality. The original exchange error is provided.
3001Request expiredThe request has expired

You can retrieve the errors in the following way:

  import {CedeErrors} from "@cedelabs/providers";