Skip to main content

Mint A Token

POST /v1/trovo-api/tokens/mint

Protocol To Mint A Token

Minting only happens within a profile and subwallets within it. Attempts to mint a token to a different wallet will fail. Token and transaction bound interactions typically happen in two phases. Initial call with base parameters which then pre-fills the other parameter.

  • First create a subwallet that will be an asset issuer,
  • Then create a subwallet that will be receiving the minted tokens (used as destination)

NOTE: It is advisable to use a sub-wallet for minting. So that shared access can be enabled on the issuer. When using a sub-wallet with shared access, ENSURE TO GRANT THE owner an INITIATOR PRIVILEGE on the subwallet.

The returned object contains the submitted information as well as all needed information that will help complete signing of transactions. When the transaction is signed, then append it to the right key in the returned object and then submit the entire object back to the API. Once the signatures are verified and transaction integrity is determined, then it is submitted to the blockchain for execution or saved for approvals in case of shared access transactions. The JSON response object is the same as the JSON body object. But for convenience and clarity, we will specify only the basic JSON body required parameters for the initial request. This means that other fields can be left empty.

Destination: is the public key or trovo app username of the subwallet that will receive the minted token. Note: If you specify a wallet public key that is not a subwallet of the trovo app profile, the transaction will fail, either due to inadequate signatures or the signature of the outside wallet cannot be obtained. Required.

Memo: this is max of 28bytes (character) which can be used to denote the transaction. This is Optional.

AssetIssuer: this is the 56 character public key of the wallet that is to issue the asset/token. Required.

AssetCode: Max of 12 alphanumeric characters that represents the code of the token to be minted.

Amount: this is the amount of token units to be minted to the destination wallet.

Transaction: this is the composed base64Txn XDR transaction string for the operation that is returned as a response after the initial call with the initial JSON BODY. This transaction would be signed with the proper stellar SDK. The signature obtained from the singing progress is then appended to the TransactionSignature key. Mandatory return with the second call to the API. The value must be used exactly as it was returned.

TransactionSignature: should hold the resulting string from signing of the Transaction that was retrieved from the initial call to the api. SAMPLE CODE

TransactionID: is returned after the second call to the API, if it is successful and blockchain execution occurred, then it will return a TRANSACTION HASH for the execution on the blockchain. If it is a shared access operation, then it will return PENDING_AUTH as a string, which indicates the signers should approve the transaction on their wallets.

NetworkPassPhrase: is returned after the initial call. This is the network passphrase that would be used during signing of the transaction returned on the initial call to API. The string should be used exactly as it is.

DestinationFirstName/DestinationLastName/DestinationThumbnail: depicts the corresponding data of the destination specified.

SignatureRequired: value of 1 indicates that the transaction signature is required and the client must sign the attached transaction and append the transaction signature in the right key. Value 0 means the client does not need to sign the transaction.

Commit: this is for all shared access operations that are being submitted by an initiator. When an initiator submits a request request, it should initially be sent with Commit = 0, and when you have confirmed the information returned, you can alter the commit = 1 and send back the objects. This will commit the request and notify all stakeholders that the operation concerns. If you are doing operations from a wallet that is not a shared access wallet, this should be ignored.

Messages: This is a list of messages and warnings from the api service that concerns your transaction you submitted. Usually it is an array of messages to be shown to the user or ignored.

Specific Headers

  • X-TW-PUBLIC-KEY must be the public key of the wallet that is minting the token. This means you use the same public key as the issuer.
  • X-TW-SIGNER must be the signer of the issuer wallet. Usually it is the same as the issuer public key.

Initial Json Body (first call to the API to indicate intention to mint)

{
"Destination": "string",
"Memo": "string",
"AssetIssuer": "string",
"AssetCode": "string",
"Amount": "string"
}

Initial Json Response/Second Json Body

{
"Destination": "string",
"Memo": "string",
"AssetIssuer": "string",
"AssetCode": "string",
"amount": "string",
"Transaction": "string",
"TransactionSignature": "string",
"TransactionId": "string",
"NetworkPassPhrase": "string",
"DestinationFirstName": "string",
"DestinationLastName": "string",
"DestinationThumbnail": "string",
"SignatureRequired": 0,
"Commit": 0,
"Messages": []
}

Burn Token

To burn a token, simply send the token as a payment, using the Issuer public key as the destination. Any tokens sent back to the issuer are burnt/destroyed.