Token
In most cases, your code will need to interact with tokens. The SDK makes it easy to find metadata about tokens, including your wallet's balance and current Dexible spend allowance, using the "tokens" sub-component of the SDK instance.
It is very important that you perform a lookup on each token you intend to use. The lookup will verify that the token address you're using is valid. After lookup, then you can "verify" the token with Dexible to make sure Dexible will allow you to trade the token.
Looking up Tokens
The following code looks up a token by its address and uses the additional balance and spend allowance information to check errors or increase spending.
Increase Spending
The example above illustrated how easy it is to increase spending allowance for a token using the SDK. As mentioned earlier, we recommend increasing spending to a level you feel comfortable with but at least enough to cover the cost of the order input amount.
Verifying Tokens
As mentioned earlier, tokens must pass a verification check before they can be used in an order. The SDK provides a simple way to check whether a token you want to trade is acceptable.
The verify function will return a boolean or error depending on the result of evaluation. The error may give you clues as to why the token is unacceptable. We debated whether to put the verification directly in the token lookup function; but we decided the two functions have two different objectives: looking up token metadata and verifying that you can use the token for trading.
Last updated