Create a New Crypto Address
Now that we have an Assed Pool and taken the id
from the previous request, we can use it to generate crypto addresses within that Pool. The list of available cryptocurrency addresses that can be added is given in the Supported Assets and Protocols guide.
In this page of the guide, we will be using the Create a new addressAPI. This is a POST request that will create a new address of the crypto type that we define, which will then be associated with AssetPoolId
that we give in the request.
Request Breakdown
The details to be sent in this request are detailed below:
Field | Description |
---|---|
network | The blockchain network where the asset is hosted. |
asset | The type of cryptocurrency asset. |
reference | A unique reference for the crypto address |
customerId | The unique identifier of the customer. |
assetPoolId | The unique identifier of the asset pool, id from the previous request. |
Example Request
Here is how an example request might look:
curl --location --globoff 'https://api.sandbox.layer1.com/digital/v1/addresses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJEQ3JxYThETGtXc3ZQcHplbktyN2QtaldhbW40RU1TS09FOWRHYk8xaGdvIn0.eyJleHAiOjE3MTc1MjcwOTksImlhdCI6MTcxNzUyNjc5OSwianRpIjoiM2NlODVkMjItODFjMy00ZTZlLTg2YWYtODFlNDg4MDIwM2E4IiwiaXNzIjoiaHR0cHM6Ly9hdXRoLnNhbmRib3gubGF5ZXIxLmNvbS9hdXRoL3JlYWxtcy9idm5rIiwiYXVkIjpbImJ2bmstY2VudHJpZnVnbyIsImJ2bmstYXBpLWdhdGV3YXkiLCJhY2NvdW50Il0sInN1YiI6IjIzNWI4NTQwLTIwMmEtNDFhYi05YzliLWZjNzRiMjkyZDljMSIsInR5cCI6IkJlYXJlciIsImF6cCI6Im1hc3Rlci1pZCIsInNlc3Npb25fc3RhdGUiOiI2MjJiM2ZhNy00NTExLTQ2YTMtYmU5Ni00NjljNDIyMGQzNWYiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsibGF5ZXIxOnJvbGU6dGVuYW50Om9wZXJhdG9yIiwibGF5ZXIxOnJvbGU6Y3J5cHRvOm1vbml0b3IiLCJsYXllcjE6cm9sZTp0cmFkZTp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OnRlbmFudElkIjoiMjM1Yjg1NDAtMjAyYS00MWFiLTljOWItZmM3NGIyOTJkOWMxIn0.ndXgU5AjlLgUBhez9Y6B8WbyKFGJzi4CjOZ8CzERWV8dH18DgPV0TzF56FGP-gWarIJCyK9nbsDmGn7H0I041HbnZrOS72MRgteU1V-5zbFMEhsM9Ksqujbxa6yo57dlfHmtLLrMUfdruyUoxi-0KZm6g8ADxu2h-0dn1UA9CqAW60iFbqOZaTDZyoIADDoOSOCrNjwIobFEO-7GP46-kjUOCivsm7atZiRomCB0jrbGBuhOuAf2H5SNDfxi4RbWjEgj2XGf_gJ46Bzp6IOGUBI6ANVD4jfff0DUGlERIKdhgwhwhiCMI41zHMUvV4EaY8Nob81hwhKPdcfLQQ73OA' \
--data '
{
"network": "ETHEREUM",
"asset": "ETH",
"reference": "First Eth Address",
"customerId": "customerOne",
"assetPoolId": "2be1cc9c-a5af-47e2-9dba-b7b82317e600"
}'
Example Response
Upon successfully submitting the request, you'll receive a response like the following with a 202 code:
{
"assetPoolId": "2be1cc9c-a5af-47e2-9dba-b7b82317e600",
"keyPairId": "44cf54df-93e9-4dd9-84c9-e96f0cf90f3e",
"reference": "First Eth Address"
}
The resulting fields in the response are:
Field | Description |
---|---|
assetPoolId | The unique identifier of the asset pool. |
keyPairId | The unique identifier of the key pair. |
reference | A unique reference for the crypto address. |
At this point, the address is created on the relevant blockchain, which is then delivered asynchronously through a webhook to the destination set up in the first step of this guide.
Address Created Webhook
The address created webhook will be sent to any destination that has subscribed to the event layer1:digital:address:created
. It will look like the following:
{
"event": "layer1:digital:address:created",
"timestamp": "2024-05-30T20:03:54.075299611Z",
"data": {
"id": "d18a869f-1919-44a0-9e5e-784d7ca8f45a",
"address": "0xc4b21fb39aaf5fc07d3cd4420bf3ee74a61642e9",
"network": "ETHEREUM",
"keyPairId": "44cf54df-93e9-4dd9-84c9-e96f0cf90f3e",
"reference": "First Eth Address",
"customerId": "customerOne",
"assetPoolId": "2be1cc9c-a5af-47e2-9dba-b7b82317e600"
}
}
The resulting fields are given as:
Field | Description |
---|---|
event | The event type that triggered the webhook. |
timestamp | The time when the event occurred in ISO 8601 format. |
data | A nested object containing the details of the created address. |
data.id | The unique identifier of the address. |
data.address | The crypto address that was created. |
data.network | The blockchain network where the address is hosted. |
data.keyPairId | The unique identifier of the key pair. |
data.reference | A unique reference for the crypto address. |
data.customerId | The unique identifier of the customer. |
data.assetPoolId | The unique identifier of the asset pool. |
The address can be extracted from data.address
, and you can now display it to the user you are expecting th deposit from, who can the pay in the correct cryptocurrency.
Updated 5 months ago