import cobo_waas2
from cobo_waas2.models.auto_sweep_task import AutoSweepTask
from cobo_waas2.models.create_auto_sweep_task import CreateAutoSweepTask
from cobo_waas2.rest import ApiException
from pprint import pprint
# See configuration.py for a list of all supported configurations.
configuration = cobo_waas2.Configuration(
# Replace `<YOUR_PRIVATE_KEY>` with your private key
api_private_key="<YOUR_PRIVATE_KEY>",
# Select the development environment. To use the production environment, change the URL to https://api.cobo.com/v2.
host="https://api.dev.cobo.com/v2",
)
# Enter a context with an instance of the API client
with cobo_waas2.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = cobo_waas2.AutoSweepApi(api_client)
create_auto_sweep_task = cobo_waas2.CreateAutoSweepTask(
wallet_id="f47ac10b-58cc-4372-a567-0e02b2c3d479", token_id="ETH_USDT"
)
try:
# Create auto-sweep task
api_response = api_instance.create_auto_sweep_task(
create_auto_sweep_task=create_auto_sweep_task
)
print("The response of AutoSweepApi->create_auto_sweep_task:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AutoSweepApi->create_auto_sweep_task: %s\n" % e)
// Import classes:
import com.cobo.waas2.ApiClient;
import com.cobo.waas2.ApiException;
import com.cobo.waas2.Configuration;
import com.cobo.waas2.Env;
import com.cobo.waas2.api.AutoSweepApi;
import com.cobo.waas2.model.*;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Select the development environment. To use the production environment, replace `Env.DEV` with
// `Env.PROD
defaultClient.setEnv(Env.DEV);
// Replace `<YOUR_PRIVATE_KEY>` with your private key
defaultClient.setPrivKey("<YOUR_PRIVATE_KEY>");
AutoSweepApi apiInstance = new AutoSweepApi();
CreateAutoSweepTask createAutoSweepTask =
new CreateAutoSweepTask()
.walletId("f47ac10b-58cc-4372-a567-0e02b2c3d479")
.tokenId("ETH_USDT");
try {
AutoSweepTask result = apiInstance.createAutoSweepTask(createAutoSweepTask);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AutoSweepApi#createAutoSweepTask");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
package main
import (
"context"
"fmt"
coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
"github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2/crypto"
"os"
)
func main() {
createAutoSweepTask := *coboWaas2.NewCreateAutoSweepTask("f47ac10b-58cc-4372-a567-0e02b2c3d479", "ETH_USDT")
configuration := coboWaas2.NewConfiguration()
// Initialize the API client
apiClient := coboWaas2.NewAPIClient(configuration)
ctx := context.Background()
// Select the development environment. To use the production environment, replace coboWaas2.DevEnv with coboWaas2.ProdEnv
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// Replace `<YOUR_PRIVATE_KEY>` with your private key
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
Secret: "<YOUR_PRIVATE_KEY>",
})
resp, r, err := apiClient.AutoSweepAPI.CreateAutoSweepTask(ctx).
CreateAutoSweepTask(createAutoSweepTask).
Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AutoSweepAPI.CreateAutoSweepTask``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `CreateAutoSweepTask`: AutoSweepTask
fmt.Fprintf(os.Stdout, "Response from `AutoSweepAPI.CreateAutoSweepTask`: %v\n", resp)
}
const CoboWaas2 = require("@cobo/cobo-waas2");
// Initialize the API client
const apiClient = CoboWaas2.ApiClient.instance;
// Select the development environment. To use the production environment, replace `Env.DEV` with `Env.PROD`
apiClient.setEnv(CoboWaas2.Env.DEV);
// Replace `<YOUR_PRIVATE_KEY>` with your private key
apiClient.setPrivateKey("<YOUR_PRIVATE_KEY>");
// Call the API
const apiInstance = new CoboWaas2.AutoSweepApi();
const opts = {
CreateAutoSweepTask: CoboWaas2.CreateAutoSweepTask.constructFromObject({
wallet_id: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
token_id: "ETH_USDT",
}),
};
apiInstance.createAutoSweepTask(opts).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
},
);
{
"task_id": "aff0e1cb-15b2-4e1f-9b9d-a9133715986f",
"wallet_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"token_id": "ETH_USDT",
"status": "Submitted",
"created_timestamp": 1610445878970,
"transaction_ids": [
"0011039d-27fb-49ba-b172-6e0aa80e37ec"
],
"failed_reasons": [
"exist pending transaction"
],
"updated_timestamp": 1610445878970
}{
"error_code": 123,
"error_message": "<string>",
"error_id": "0b6ddf19083c4bd1a9ca01bec44b24dd"
}{
"error_code": 123,
"error_message": "<string>",
"error_id": "0b6ddf19083c4bd1a9ca01bec44b24dd"
}Create auto-sweep task
This operation creates an auto-sweep task for the specified wallet and token. The task triggers transactions to sweep the full balance of the specified token to the configured sweep-to address.
failed_reasons array of the auto-sweep task.status set to Submitted and an empty transaction_ids array; this is expected and does not indicate a failure. The transaction_ids array is populated only after status becomes TransactionCreated. To retrieve the transaction IDs, poll Get auto-sweep task details using the returned task_id until the status changes.import cobo_waas2
from cobo_waas2.models.auto_sweep_task import AutoSweepTask
from cobo_waas2.models.create_auto_sweep_task import CreateAutoSweepTask
from cobo_waas2.rest import ApiException
from pprint import pprint
# See configuration.py for a list of all supported configurations.
configuration = cobo_waas2.Configuration(
# Replace `<YOUR_PRIVATE_KEY>` with your private key
api_private_key="<YOUR_PRIVATE_KEY>",
# Select the development environment. To use the production environment, change the URL to https://api.cobo.com/v2.
host="https://api.dev.cobo.com/v2",
)
# Enter a context with an instance of the API client
with cobo_waas2.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = cobo_waas2.AutoSweepApi(api_client)
create_auto_sweep_task = cobo_waas2.CreateAutoSweepTask(
wallet_id="f47ac10b-58cc-4372-a567-0e02b2c3d479", token_id="ETH_USDT"
)
try:
# Create auto-sweep task
api_response = api_instance.create_auto_sweep_task(
create_auto_sweep_task=create_auto_sweep_task
)
print("The response of AutoSweepApi->create_auto_sweep_task:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AutoSweepApi->create_auto_sweep_task: %s\n" % e)
// Import classes:
import com.cobo.waas2.ApiClient;
import com.cobo.waas2.ApiException;
import com.cobo.waas2.Configuration;
import com.cobo.waas2.Env;
import com.cobo.waas2.api.AutoSweepApi;
import com.cobo.waas2.model.*;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Select the development environment. To use the production environment, replace `Env.DEV` with
// `Env.PROD
defaultClient.setEnv(Env.DEV);
// Replace `<YOUR_PRIVATE_KEY>` with your private key
defaultClient.setPrivKey("<YOUR_PRIVATE_KEY>");
AutoSweepApi apiInstance = new AutoSweepApi();
CreateAutoSweepTask createAutoSweepTask =
new CreateAutoSweepTask()
.walletId("f47ac10b-58cc-4372-a567-0e02b2c3d479")
.tokenId("ETH_USDT");
try {
AutoSweepTask result = apiInstance.createAutoSweepTask(createAutoSweepTask);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AutoSweepApi#createAutoSweepTask");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
package main
import (
"context"
"fmt"
coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
"github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2/crypto"
"os"
)
func main() {
createAutoSweepTask := *coboWaas2.NewCreateAutoSweepTask("f47ac10b-58cc-4372-a567-0e02b2c3d479", "ETH_USDT")
configuration := coboWaas2.NewConfiguration()
// Initialize the API client
apiClient := coboWaas2.NewAPIClient(configuration)
ctx := context.Background()
// Select the development environment. To use the production environment, replace coboWaas2.DevEnv with coboWaas2.ProdEnv
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// Replace `<YOUR_PRIVATE_KEY>` with your private key
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
Secret: "<YOUR_PRIVATE_KEY>",
})
resp, r, err := apiClient.AutoSweepAPI.CreateAutoSweepTask(ctx).
CreateAutoSweepTask(createAutoSweepTask).
Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AutoSweepAPI.CreateAutoSweepTask``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `CreateAutoSweepTask`: AutoSweepTask
fmt.Fprintf(os.Stdout, "Response from `AutoSweepAPI.CreateAutoSweepTask`: %v\n", resp)
}
const CoboWaas2 = require("@cobo/cobo-waas2");
// Initialize the API client
const apiClient = CoboWaas2.ApiClient.instance;
// Select the development environment. To use the production environment, replace `Env.DEV` with `Env.PROD`
apiClient.setEnv(CoboWaas2.Env.DEV);
// Replace `<YOUR_PRIVATE_KEY>` with your private key
apiClient.setPrivateKey("<YOUR_PRIVATE_KEY>");
// Call the API
const apiInstance = new CoboWaas2.AutoSweepApi();
const opts = {
CreateAutoSweepTask: CoboWaas2.CreateAutoSweepTask.constructFromObject({
wallet_id: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
token_id: "ETH_USDT",
}),
};
apiInstance.createAutoSweepTask(opts).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
},
);
{
"task_id": "aff0e1cb-15b2-4e1f-9b9d-a9133715986f",
"wallet_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"token_id": "ETH_USDT",
"status": "Submitted",
"created_timestamp": 1610445878970,
"transaction_ids": [
"0011039d-27fb-49ba-b172-6e0aa80e37ec"
],
"failed_reasons": [
"exist pending transaction"
],
"updated_timestamp": 1610445878970
}{
"error_code": 123,
"error_message": "<string>",
"error_id": "0b6ddf19083c4bd1a9ca01bec44b24dd"
}{
"error_code": 123,
"error_message": "<string>",
"error_id": "0b6ddf19083c4bd1a9ca01bec44b24dd"
}import cobo_waas2
from cobo_waas2.models.auto_sweep_task import AutoSweepTask
from cobo_waas2.models.create_auto_sweep_task import CreateAutoSweepTask
from cobo_waas2.rest import ApiException
from pprint import pprint
# See configuration.py for a list of all supported configurations.
configuration = cobo_waas2.Configuration(
# Replace `<YOUR_PRIVATE_KEY>` with your private key
api_private_key="<YOUR_PRIVATE_KEY>",
# Select the development environment. To use the production environment, change the URL to https://api.cobo.com/v2.
host="https://api.dev.cobo.com/v2",
)
# Enter a context with an instance of the API client
with cobo_waas2.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = cobo_waas2.AutoSweepApi(api_client)
create_auto_sweep_task = cobo_waas2.CreateAutoSweepTask(
wallet_id="f47ac10b-58cc-4372-a567-0e02b2c3d479", token_id="ETH_USDT"
)
try:
# Create auto-sweep task
api_response = api_instance.create_auto_sweep_task(
create_auto_sweep_task=create_auto_sweep_task
)
print("The response of AutoSweepApi->create_auto_sweep_task:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AutoSweepApi->create_auto_sweep_task: %s\n" % e)
// Import classes:
import com.cobo.waas2.ApiClient;
import com.cobo.waas2.ApiException;
import com.cobo.waas2.Configuration;
import com.cobo.waas2.Env;
import com.cobo.waas2.api.AutoSweepApi;
import com.cobo.waas2.model.*;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Select the development environment. To use the production environment, replace `Env.DEV` with
// `Env.PROD
defaultClient.setEnv(Env.DEV);
// Replace `<YOUR_PRIVATE_KEY>` with your private key
defaultClient.setPrivKey("<YOUR_PRIVATE_KEY>");
AutoSweepApi apiInstance = new AutoSweepApi();
CreateAutoSweepTask createAutoSweepTask =
new CreateAutoSweepTask()
.walletId("f47ac10b-58cc-4372-a567-0e02b2c3d479")
.tokenId("ETH_USDT");
try {
AutoSweepTask result = apiInstance.createAutoSweepTask(createAutoSweepTask);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AutoSweepApi#createAutoSweepTask");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
package main
import (
"context"
"fmt"
coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
"github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2/crypto"
"os"
)
func main() {
createAutoSweepTask := *coboWaas2.NewCreateAutoSweepTask("f47ac10b-58cc-4372-a567-0e02b2c3d479", "ETH_USDT")
configuration := coboWaas2.NewConfiguration()
// Initialize the API client
apiClient := coboWaas2.NewAPIClient(configuration)
ctx := context.Background()
// Select the development environment. To use the production environment, replace coboWaas2.DevEnv with coboWaas2.ProdEnv
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// Replace `<YOUR_PRIVATE_KEY>` with your private key
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
Secret: "<YOUR_PRIVATE_KEY>",
})
resp, r, err := apiClient.AutoSweepAPI.CreateAutoSweepTask(ctx).
CreateAutoSweepTask(createAutoSweepTask).
Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AutoSweepAPI.CreateAutoSweepTask``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `CreateAutoSweepTask`: AutoSweepTask
fmt.Fprintf(os.Stdout, "Response from `AutoSweepAPI.CreateAutoSweepTask`: %v\n", resp)
}
const CoboWaas2 = require("@cobo/cobo-waas2");
// Initialize the API client
const apiClient = CoboWaas2.ApiClient.instance;
// Select the development environment. To use the production environment, replace `Env.DEV` with `Env.PROD`
apiClient.setEnv(CoboWaas2.Env.DEV);
// Replace `<YOUR_PRIVATE_KEY>` with your private key
apiClient.setPrivateKey("<YOUR_PRIVATE_KEY>");
// Call the API
const apiInstance = new CoboWaas2.AutoSweepApi();
const opts = {
CreateAutoSweepTask: CoboWaas2.CreateAutoSweepTask.constructFromObject({
wallet_id: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
token_id: "ETH_USDT",
}),
};
apiInstance.createAutoSweepTask(opts).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
},
);
Authorizations
The API key. For more details, refer to API key.
In the API playground, enter your API secret, and your API key will be accordingly calculated.
Body
The request body to create an auto-sweep task.
Wallet and token information required to create an auto-sweep task.
ID of the wallet where the token will be swept.
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
ID of the token to be swept. You can retrieve the IDs of all the tokens you can use by calling List enabled tokens.
"ETH_USDT"
The minimum token balance threshold for auto sweep. If the token balance of an address is less than this threshold, the address will not be swept.
"0.01"
Response
Successfully created auto-sweep task.
Auto-sweep task information.
Auto-sweep task ID.
"aff0e1cb-15b2-4e1f-9b9d-a9133715986f"
Wallet ID.
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
Token ID of the swept token. You can retrieve the IDs of all the tokens you can use by calling List enabled tokens.
"ETH_USDT"
Auto-sweep task status:
Submitted: The auto-sweep task has been submitted.TransactionCreated: The auto-sweep task triggered one or more token sweeping transactions.
Submitted, TransactionCreated "Submitted"
The time when the task was created, in Unix timestamp format, measured in milliseconds.
1610445878970
IDs of the transactions triggered by the task. This array is empty while the task status is Submitted, and is populated only after the status becomes TransactionCreated. Poll Get auto-sweep task details until the transaction IDs are available.
Reasons why the task creation failed.
The time when the task was updated, in Unix timestamp format, measured in milliseconds.
1610445878970
Was this page helpful?
