Send Account Funds Externally

Sending funds from your iPeakoin Account to external blockchain wallets is one of the most basic primitives of the APIs. This quickstart walks through sending USDC externally, the same steps would be taken when sending USDT, ETH and BTC too.

Send Funds

To send account funds externally, you will need a blockchain address.

The sandbox environment is connected to the Ethereum Goerli testing network, so the destination blockchain address has to be a valid Goerli address.

๐Ÿ”Ž

USDC is connected to testing networks on other blockchains as well. This guide focuses on Ethereum but works similarly for other blockchains. For information on other testing networks see Test USDC

To send funds externally, you will use the create account withdrawal endpoint.

Since iPeakoin APIs are designed for multiple future chains and currencies, you have to specify the currency and chain you want to utilize. You can create a transfer by using the command below.

# Replace ${YOUR_API_ACCESS_TOKEN} with your API access token
curl --request POST \
     --url https://api-sandbox.ipeakoin.com/open-api/v1/asset/wallets/withdrawals \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-ipeakoin-access-token: ${YOUR_API_ACCESS_TOKEN}' \
     --data  '{
        "currency": "USDC",
        "chain": "ETH",
        "amount": "1",
        "address": "0x493A9869E3B5f846f72267ab19B76e9bf99d51b1"
    }'

You should receive a response like the below.

{
    "id": "fda5dd13-57c4-4e14-92a4-7fadf624bf7a",
    "accountId": "d37deed7-f0e7-4635-a43a-781af0cb59f0",
    "balanceId": "93ca2b1a-c0af-46cd-b5c0-bfa6532c399b",
    "chain": "ETH",
    "currency": "USDC",
    "amount": "1.01",
    "fee": "0",
    "status": "Pending",
    "createTime": "2023-03-15T03:06:46.000Z",
    "updateTime": "2023-03-15T03:06:46.000Z"
}

Check the Status of the Withdrawal

You can use the get withdrawal endpoint to retrieve details about the status of the transaction. You can use it as in the command below.

# Replace ${YOUR_API_ACCESS_TOKEN} with your API access token
curl --request GET \
     --url https://api-sandbox.ipeakoin.com/open-api/v1/asset/wallets/withdrawals?id=fda5dd13-57c4-4e14-92a4-7fadf624bf7a \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-ipeakoin-access-token: ${YOUR_API_ACCESS_TOKEN}'

You will receive a response like below.

{
    "data": [{
        "id": "fda5dd13-57c4-4e14-92a4-7fadf624bf7a",
        "createTime": "2023-03-15T03:06:46.000Z",
        "updateTime": "2023-03-15T03:09:56.000Z",
        "accountId": "d37deed7-f0e7-4635-a43a-781af0cb59f0",
        "balanceId": "93ca2b1a-c0af-46cd-b5c0-bfa6532c399b",
        "chain": "ETH",
        "currency": "USDC",
        "amount": "1.01",
        "fee": "0",
        "status": "Closed",
        "transactionHash": "0x8558135eaaed89c59736a904cb5fda991085cb2e4e7625c8df5a4a95cc8e726c"
    }],
}

The very first state transition for a withdrawal sets the status to created and the transactionHash to null - at that point iPeakoin has just started processing the on-chain send. After success, iPeakoin will broadcast the transfer and so its status changes to running while also displaying the transactionHash that can be used to track such transfer on chain (you can look it up on Etherscan's tracker on Goerli).

At this point you can consider the transaction complete because it has been successfully broadcasted to the network. iPeakoin systems will continue to track the transfer for 30 confirmations and its status will at that point change to complete. Except for a few specialized applications you do not have to worry about waiting for the complete state - that's important when receiving external transfers. You can read more about block confirmations here.

๐ŸŽ‰ Congratulations! You have successfully sent cryptocurrency using iPeakoin APIs.