Create Addresses
Create Addresses
Section titled “Create Addresses”Introduction
Section titled “Introduction”In this tutorial, we will cover how to create addresses for Polygon, Binance Smart Chain, Ethereum, and Tron using Chaingateway. We will provide examples in various programming languages, including Shell (cURL), PHP (Guzzle), Python (Requests), and JavaScript (Axios). In this tutorial, we will cover how to create addresses for Polygon, Binance Smart Chain, Ethereum, and Tron using Chaingateway. We will provide examples in various programming languages, including Shell (cURL), PHP (Guzzle), Python (Requests), and JavaScript (Axios). For obtaining an API key and learning about authorization, please refer to the Quickstart section of the Chaingateway documentation.
Creating Addresses
Section titled “Creating Addresses”When creating a new address for an EVM based blockchain, we need to create a keystore. This is a security mechanism to keep your information safe. The keystore will be encrypted with a password. With this mechanism, you do not need to send your private key within your transaction payload but only your password. A person that has only the keystore file or only the password cannot access the address.
To create the address, send a request to the Chaingateway API.
Parameters
Section titled “Parameters”- password: This is a user-defined password for the new address. It is used to secure the address and will be required for performing transactions with this address. It is essential to store this password securely as Chaingateway does not store or have access to it. If the password is lost, the address cannot be accessed.
Authorization Header
Section titled “Authorization Header”Replace YOUR_API_TOKEN with your actual API token.
Example Code (Password Protected Wallet)
Section titled “Example Code (Password Protected Wallet)”curl --request POST\ --url https://api.chaingateway.io/v2/ethereum/addresses\ --header 'Accept: application/json'\ --header 'content-type: application/json'\ --header 'Authorization: YOUR_API_TOKEN'\ --data '{"password":"test123"}'import requests
url = "https://api.chaingateway.io/v2/ethereum/addresses"payload = {"password": "test123"}headers = { 'Accept': 'application/json', 'content-type': 'application/json', 'Authorization': 'YOUR_API_TOKEN'}
response = requests.post(url, json=payload, headers=headers)print(response.json())const axios = require('axios');
const url = 'https://api.chaingateway.io/v2/ethereum/addresses';const payload = { password: 'test123' };const headers = { 'Accept': 'application/json', 'content-type': 'application/json', 'Authorization': 'YOUR_API_TOKEN'};
axios.post(url, payload, { headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error); });<?phprequire 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();$response = $client->post('https://api.chaingateway.io/v2/ethereum/addresses', [ 'headers' => [ 'Accept' => 'application/json', 'content-type' => 'application/json', 'Authorization' => 'YOUR_API_TOKEN', ], 'json' => ['password' => 'test123']]);
echo $response->getBody();?>Response
Section titled “Response”{ "status": 201, "ok": true, "message": "Address created", "data": { "adderess": "0x7d3bC832A0860fD882FF4C2359e10268f4E5CCf8" }}Example Code (Non Protected Wallet)
Section titled “Example Code (Non Protected Wallet)”curl --request POST\ --url https://api.chaingateway.io/v2/tron/addresses\ --header 'Accept: application/json'\ --header 'content-type: application/json'\ --header 'Authorization: YOUR_API_TOKEN'import requests
url = "https://api.chaingateway.io/v2/tron/addresses"headers = { 'Accept': 'application/json', 'content-type': 'application/json', 'Authorization': 'YOUR_API_TOKEN'}
response = requests.post(url, headers=headers)print(response.json())const axios = require('axios');
const url = 'https://api.chaingateway.io/v2/tron/addresses';const headers = { 'Accept': 'application/json', 'content-type': 'application/json', 'Authorization': 'YOUR_API_TOKEN'};
axios.post(url, {}, { headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error); });<?phprequire 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();$response = $client->post('https://api.chaingateway.io/v2/tron/addresses', [ 'headers' => [ 'Accept' => 'application/json', 'content-type': 'application/json', 'Authorization' => 'YOUR_API_TOKEN', ]]);
echo $response->getBody();?>The response should look like this:
{ "status": 201, "ok": true, "message": "Address created", "data": { "privateKey": "59f1c6200e01a2ca9471411f10198bfa63678d0e87cc2ca30f9c4a68dee78edc", "publicKey": "040fe6e677442c36f7fdd5535ba3ff1cef0110d78363420f7e24b65298990e3467aed68b9a67e1396d84753db25b32a2fa3e1fc0a673f01638e9bcfab2d8f4ceb5", "hexAddress": "41a56a6505ffbee78eb916dd44f4846874deddaebd", "address": "TR3qx91smURF3R455V1ubqtoUsZbgqikfg" }}You should store the privateKey and address on a secure place in your app
Important Information
Section titled “Important Information”For creating transactions, users need to provide the password of the address or the private key . Chaingateway does not store these sensitive pieces of information. Therefore, users must store them in a safe place. If these are lost, Chaingateway cannot assist in recovery as it does not have access to this information.
For obtaining an API key and learning about authorization, please refer to the Getting Started section of the Chaingateway documentation.