import jsonimport cobo_waas2from cobo_waas2 import ( WalletType, WalletSubtype,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret api_private_key="<YOUR_API_SECRET>", # Use the development environment host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.WalletsApi(api_client) try: # Query enabled chains api_response = wallet_api_instance.list_enabled_chains( wallet_type=WalletType.SMARTCONTRACT, wallet_subtype=WalletSubtype.SAFE_WALLET ) print(f"The response of WalletsApi->list_enabled_chains:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling WalletsApi->list_enabled_chains, %s\n", e)
import jsonimport cobo_waas2from cobo_waas2 import ( WalletType, WalletSubtype,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret api_private_key="<YOUR_API_SECRET>", # Use the development environment host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.WalletsApi(api_client) try: # Query enabled tokens api_response = wallet_api_instance.list_enabled_tokens( wallet_type=WalletType.SMARTCONTRACT, wallet_subtype=WalletSubtype.SAFE_WALLET ) print(f"The response of WalletsApi->list_enabled_tokens:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling WalletsApi->list_enabled_tokens, %s\n", e)
import jsonimport uuidimport cobo_waas2from cobo_waas2 import ( CreateAddressRequest, AddressEncoding, TransferParams, TransferSource, MpcTransferSource, WalletSubtype, TransferDestination, AddressTransferDestination, TransferDestinationType, AddressTransferDestinationAccountOutput,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret. api_private_key="<YOUR_API_SECRET>", # Use the development environment. host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class transaction_api_instance = cobo_waas2.TransactionsApi(api_client) try: # List deposit transactions api_response = transaction_api_instance.list_transactions( types="Deposit", statuses="Confirming, Completed", wallet_ids="<YOUR_WALLET_ID>" ) print("The response of TransactionsApi->list_transactions:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling TransactionsApi->list_transactions, %s\n", e)
import jsonimport uuidimport cobo_waas2configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret api_private_key="<YOUR_API_SECRET>", # Use the development environment host="https://api.dev.cobo.com/v2")def get_delegate(wallet_id, request: cobo_waas2.SafeWalletDelegates):# 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 wallet_api_instance = cobo_waas2.WalletsSmartContractWalletsApi(api_client) try: # Call the List Delegates operation to retrieve available Delegates api_response = wallet_api_instance.list_safe_wallet_delegates( wallet_id=wallet_id, safe_wallet_delegates=request ) if not api_response: raise Exception("No delegate found") print("The response of WalletsApi->list_safe_wallet_delegates:") print(json.dumps(api_response[0].to_dict(), indent=2)) # Return the first Delegate return api_response[0] except Exception as e: print("Exception when calling WalletsApi: %s\n", e)def get_wallet(wallet_id) -> cobo_waas2.SafeWallet: with cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.WalletsApi(api_client) try: # Call the Get wallet information operation to retrieve the wallet information, including the wallet address api_response = wallet_api_instance.get_wallet_by_id( wallet_id=wallet_id ) print("The response of WalletsApi->get_wallet_by_id:") print(json.dumps(api_response.to_dict(), indent=2)) return api_response.actual_instance.actual_instance except Exception as e: print("Exception when calling WalletsApi: %s\n", e)token_id = "<TOKEN_ID>"# Enther the receiving addressreceiver_address = "<TARGET_ADDRESS>"# Enter the wallet ID found on Cobo Portal wallet_id = "<YOUR_WALLET_ID>"# Enter the amount of tokens you want to transferamount = "<AMOUNT>"transfer_request = cobo_waas2.SafeWalletDelegates( actual_instance=cobo_waas2.SafeWalletDelegatesTransfer( request_type=cobo_waas2.EstimateFeeRequestType.TRANSFER, token_id=token_id, address=receiver_address, ) )# Retrieve a list of available Delegatesdelegate = get_delegate(wallet_id, transfer_request)# Retrieve detailed information about the Safe{Wallet}wallet = get_wallet(wallet_id)with cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.TransactionsApi(api_client) try: # Initiate token transfer through a Delegate api_response = wallet_api_instance.create_transfer_transaction( cobo_waas2.TransferParams( request_id=str(uuid.uuid4()), # Set the sending address and the Delegate source=cobo_waas2.TransferSource( actual_instance=cobo_waas2.SafeTransferSource( source_type=cobo_waas2.WalletSubtype.SAFE_WALLET, wallet_id=wallet_id, address=wallet.safe_address, delegate=delegate, ) ), token_id=token_id, # Set the receiving address and withdrawal amount destination=cobo_waas2.TransferDestination( actual_instance=cobo_waas2.AddressTransferDestination( destination_type=cobo_waas2.TransferDestinationType.ADDRESS, account_output=cobo_waas2.AddressTransferDestinationAccountOutput( address=receiver_address, amount=amount, ), ), ), category_names=["<CATEGORY_NAME>"], description="<DESCRIPTION>", ) ) print("The response of TransactionsApi->create_transfer_transaction:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling WalletsApi: %s\n", e)
import jsonimport uuidimport cobo_waas2from cobo_waas2 import ( CreateAddressRequest, AddressEncoding, TransferParams, TransferSource, MpcTransferSource, WalletSubtype, TransferDestination, AddressTransferDestination, TransferDestinationType, AddressTransferDestinationAccountOutput,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret. api_private_key="<YOUR_API_SECRET>", # Use the development environment. host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class transaction_api_instance = cobo_waas2.TransactionsApi(api_client) try: # Get transaction by ID api_response = transaction_api_instance.get_transaction_by_id( transaction_id="<YOUR_TRANSACTION_ID>" ) print("The response of TransactionsApi->get_transaction_by_id:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling TransactionsApi->get_transaction_by_id, %s\n", e)
import jsonimport cobo_waas2configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret api_private_key="<YOUR_API_SECRET>", # Use the development environment host="https://api.dev.cobo.com/v2")def get_delegate(wallet_id, request: cobo_waas2.SafeWalletDelegates):# 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 wallet_api_instance = cobo_waas2.WalletsSmartContractWalletsApi(api_client) try: # Call the List Delegates operation to retrieve available Delegates api_response = wallet_api_instance.list_safe_wallet_delegates( wallet_id=wallet_id, safe_wallet_delegates=request ) if not api_response: raise Exception("No delegate found") print("The response of WalletsApi->list_safe_wallet_delegates:") print(json.dumps(api_response[0].to_dict(), indent=2)) return api_response[0] except Exception as e: print("Exception when calling WalletsApi: %s\n", e)def get_wallet(wallet_id) -> cobo_waas2.SafeWallet: with cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.WalletsApi(api_client) try: # Call the Get wallet information operation to retrieve the wallet information, including the wallet address api_response = wallet_api_instance.get_wallet_by_id( wallet_id=wallet_id ) print("The response of WalletsApi->get_wallet_by_id:") print(json.dumps(api_response.to_dict(), indent=2)) return api_response.actual_instance.actual_instance except Exception as e: print("Exception when calling WalletsApi: %s\n", e)# Set the destination address contract_address = "<CONTRACT_ADDRESS>"# Set the transaction calldatadata = "<DATA>"# Set the transfer amountvalue = "<VALUE>"contract_call_request = cobo_waas2.SafeWalletDelegates( actual_instance=cobo_waas2.SafeWalletDelegatesContractCall( request_type=cobo_waas2.EstimateFeeRequestType.CONTRACTCALL, address=contract_address, calldata=data, value=value, ) )# Retrieve a list of available Delegates.delegate = get_delegate(wallet_id, contract_call_request)# Retrieve detailed information about the Safe{Wallet}.wallet = get_wallet(wallet_id)with cobo_waas2.ApiClient(configuration) as api_client: wallet_api_instance = cobo_waas2.TransactionsApi(api_client) try: # Call the smart contract api_response = wallet_api_instance.create_contract_call_transaction( cobo_waas2.ContractCallParams( request_id=str(uuid.uuid4()), chain_id=wallet.chain_id, source=cobo_waas2.ContractCallSource( actual_instance=cobo_waas2.SafeContractCallSource( source_type=cobo_waas2.ContractCallSourceType.SAFE_WALLET, wallet_id=wallet_id, address=wallet.safe_address, delegate=delegate, ) ), destination=cobo_waas2.ContractCallDestination( actual_instance=cobo_waas2.EvmContractCallDestination( destination_type=cobo_waas2.ContractCallDestinationType.EVM_CONTRACT, address=contract_address, calldata=data, value=value, ), ), category_names=["<CATEGORY_NAME>"], description="<DESCRIPTION>", ) ) print("The response of TransactionsApi->create_contract_call_transaction:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling TransactionsApi: %s\n", e)