(token)
- tokenPrice - Token Price
- tokenBalance - Token Balance
- tokenTransfer - Transfer Tokens
Retrieves the price of a token in USD.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.token.tokenPrice({
token: "USDC",
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { tokenTokenPrice } from "@compass-labs/api-sdk/funcs/tokenTokenPrice.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await tokenTokenPrice(compassApiSDK, {
token: "USDC",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokenTokenPrice failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.V1TokenPriceRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.TokenPriceResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Returns the balance of a specific ERC20 token for a given user address.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.token.tokenBalance({});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { tokenTokenBalance } from "@compass-labs/api-sdk/funcs/tokenTokenBalance.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await tokenTokenBalance(compassApiSDK, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokenTokenBalance failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.V1TokenBalanceRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.TokenBalanceResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Sends native ETH or ERC20 tokens from the sender's address to another address.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.token.tokenTransfer({
to: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc44",
token: "USDC",
amount: 1.5,
chain: "ethereum",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { tokenTokenTransfer } from "@compass-labs/api-sdk/funcs/tokenTokenTransfer.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await tokenTokenTransfer(compassApiSDK, {
to: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc44",
token: "USDC",
amount: 1.5,
chain: "ethereum",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("tokenTokenTransfer failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.TokenTransferRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.TransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |