Token Management
Token Resource Overview
Understanding token creation and balance retrieval within the OmniSafe API.
This document explains how to create tokens and retrieve balances within the OmniSafe API.
1
Creating a Token and Minting Initial Supply
To create a new token and mint an initial supply to a specified owner address, use the POST /v1/tokens
endpoint.
- Endpoint:
POST /v1/tokens
- Create Token and Mint API Reference - Summary: Create a token and mint.
- Description: Creates a new token and mints an initial supply to a specified owner address. OmniSafe handles the necessary blockchain interactions to register the token and assign the initial tokens to the owner on the blockchain.
Request Body:
The request body should conform to the TokenMintDto
schema (defined in the OpenAPI specification). It typically includes:
symbol
: The token’s symbol (e.g., “MYTOKEN”).name
: The token’s name (e.g., “My Token”).decimals
: The number of decimal places for the token (e.g., 18).initialQuantity
: The initial quantity of tokens to mint.ownerAddress
: The wallet address to receive the initial supply of tokens.
Response:
201 Created
: Returns the created token address (as plain text). Example:"0x1234567890abcdef..."
Important Considerations:
- Token Standards: OmniSafe handles the underlying blockchain interactions. Ensure the parameters you provide are compatible with the supported token standards.
- Owner Address: The
ownerAddress
must be a valid wallet address within the OmniSafe system. - Asynchronous Creation: Token creation might involve asynchronous blockchain operations. It is recommended to check the token’s status using separate API (if implemented) or to monitor the token creation transaction on chain explorers.
2
Getting Token Balance
To retrieve the token/ETH balance for a specific wallet address, use the GET /v1/tokens/{token-address}/{owner}
endpoint.
- Endpoint:
GET /v1/tokens/{token-address}/{owner}
- Get Balance API Reference - Summary: Get balance.
- Description: Retrieves the token balance for a specific wallet address on the blockchain.
Parameters:
token-address
(path parameter, required): The address of the token, obtained from thePOST /v1/tokens
response.owner
(path parameter, required): The address of the wallet for which you want to retrieve the balance.
Response:
200 OK
: Returns the wallet balance (as a number). Example:1000
Important Considerations:
- Token Address: The
token-address
must be a valid token address that was previously created through thePOST /v1/tokens
endpoint. - Owner Address: The
owner
address must be a valid wallet address within the OmniSafe system.