How to Create a Personal Access Token (API Key) on the Hedera Portal
In the Hedera Portal, the Personal Access Token (API key) is a new feature for seamless application development and management. This feature facilitates the process of account recreation and querying for account ID after a test network (Testnet or Previewnet) resets. Whenever the testnet is reset, developers have to manually log in to the portal, recreate an account, get the account ID, and input the new account ID into their development environment. Utilizing this new feature to generate an API key eliminates the need to manually recreate accounts. There are no prerequisites for this tutorial.
By the end of this tutorial, you will know how to:
Step 1: Create a Hedera Portal Profile
To create your Hedera Portal profile, register here and follow the instructions to complete your profile. Once you've completed setting up your profile, select the test network (Testnet or Previewnet) from the network drop-down menu and create an account.
Note: For the purposes of this tutorial, we will be using the Hedera Testnet to demonstrate token creation, but the steps to create tokens for both Testnet and Previewnet are identical.
Step 2: Create a New Personal Access Token
Navigate to the Hedera Portal token creation page by clicking on the profile icon in the top-right corner of the portal dashboard and select Personal Access Tokens from the dropdown menu. This page is dedicated to the creation and management of your personal access tokens.
Once you're on the token management page, you will find the option to create a new token. Start by typing in a description for your token in the Description field. This description should ideally reflect the intended use or scope of the token. Click the CREATE TOKEN button after entering the description.
🚨 Note: Once your Personal Access Token (API key) is generated, please copy and securely save it in a location where only you have access. Be aware that once you navigate away from the page, the API key will no longer be visible. If you do not save your key, you will need to create a new one, as there is no way to retrieve it later.
Step 3: API Calls to List and Get Accounts
Copy your new API token key and save it in a secure place where only you can access it. This key will be used in the API calls below.
API calls using curl
Either of these APIs will trigger the account to be recreated in the background if the account does not exist (due to a testnet reset).
Example API call response
The data returned by the curl
command is a JSON object detailing information about the accounts on the Hedera network. Here's a breakdown of each field and what it represents:
accountNum
: Account identifier, e.g., "7685875".shard
: Shard ID, part of the account address, e.g., "0".realm
: Realm ID within the shard, e.g., "0".balanceLimit
: Maximum account balance, e.g., "100000000000".network
: Network type - mainnet, testnet, previewnet.keyType
: Cryptographic key type (ECDSA, ED25519), here "ecdsa".lastDisbursementAt
: Last disbursement timestamp, e.g., "2024-01-22 15:29:40.004689+00".publicKey
: Account's public key in hexadecimal.privateKey
: Account's private key in hexadecimal.scheduledForDisbursement
: Indicates if disbursement is scheduled, herefalse
.balance
: Contains_valueInTinybar
, the account balance in tinybar units, e.g., "100000000000".
Last updated