MintToken
MintToken creates and distributes tokens to the specified address.
- Overview
- Protobuf
Method Options​
Authorisation specification of the MintToken method.
| Type | METHOD_TYPE_WRITE |
|---|---|
| Access Level | METHOD_ACCESS_LEVEL_PUBLIC |
| Roles |
Parameters​
Request and response parameter message overview:
Input: MintTokenRequest Message​
| Field | Type | Required | Description |
|---|---|---|---|
Amount |
| True | The amount of tokens to mint. Must be specified. |
Address |
| True | The blockchain address to mint tokens to. Must be specified. |
Options |
| False | Optional parameters for customizing the mint operation. |
Returns: MintTokenResponse Message​
No response fields documented.
syntax = "proto3";
package meshtrade.testing.ledger.token_tap.v1;
import "buf/validate/validate.proto";
import "meshtrade/option/method_options/v1/method_options.proto";
import "meshtrade/testing/ledger/token_tap/v1/option.proto";
import "meshtrade/type/v1/amount.proto";
import "meshtrade/type/v1/token.proto";
option go_package = "github.com/meshtrade/api/go/testing/ledger/token_tap/v1;token_tap_v1";
option java_package = "co.meshtrade.api.testing.ledger.token_tap.v1";
/*
TokenTapService provides token distribution and minting functionality for testing
and development purposes. It enables initialization of token taps, querying
available tokens, and minting tokens to specified addresses.
*/
service TokenTapService {
// InitialiseTokenTaps initialises the available token taps.
rpc InitialiseTokenTaps(InitialiseTokenTapsRequest) returns (InitialiseTokenTapsResponse) {
option (meshtrade.option.method_options.v1.method_options) = {
type: METHOD_TYPE_WRITE
access_level: METHOD_ACCESS_LEVEL_PUBLIC
};
}
// ListTokenTaps retrieves the list of available tokens for minting.
rpc ListTokenTaps(ListTokenTapsRequest) returns (ListTokenTapsResponse) {
option (meshtrade.option.method_options.v1.method_options) = {
type: METHOD_TYPE_READ
access_level: METHOD_ACCESS_LEVEL_PUBLIC
};
}
// MintToken creates and distributes tokens to the specified address.
rpc MintToken(MintTokenRequest) returns (MintTokenResponse) {
option (meshtrade.option.method_options.v1.method_options) = {
type: METHOD_TYPE_WRITE
access_level: METHOD_ACCESS_LEVEL_PUBLIC
};
}
}
// InitialiseTokenTapsRequest is the message used to initialize token taps.
message InitialiseTokenTapsRequest {}
// InitialiseTokenTapsResponse is the response message from initializing token taps.
message InitialiseTokenTapsResponse {}
// ListTokenTapsRequest is the message used to retrieve available tokens.
message ListTokenTapsRequest {}
// ListTokenTapsResponse contains a list of available tokens for minting.
message ListTokenTapsResponse {
// Available tokens that can be minted.
repeated type.v1.Token tokens = 1;
}
// MintTokenRequest is the message used to mint tokens to an address.
message MintTokenRequest {
// The amount of tokens to mint. Must be specified.
type.v1.Amount amount = 1 [(buf.validate.field) = {required: true}];
// The blockchain address to mint tokens to. Must be specified.
string address = 2 [(buf.validate.field) = {required: true}];
// Optional parameters for customizing the mint operation.
meshtrade.testing.ledger.token_tap.v1.MintTokenOptions options = 3;
}
// MintTokenResponse is the response message from minting tokens.
message MintTokenResponse {}
Code Examples​
Select supported SDK in the language of your choice for a full example of how to invoke the this method:
- Go
- Python
- Java
package main
import (
"context"
"log"
token_tapv1 "github.com/meshtrade/api/go/testing/ledger/token_tap/v1"
typev1 "github.com/meshtrade/api/go/type/v1"
)
func main() {
ctx := context.Background()
// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
service, err := token_tapv1.NewTokenTapService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()
// Create a test token (USDC on Stellar)
testToken := &typev1.Token{
Code: "USDC",
Issuer: "GBUQWP3BOUZX34ULNQG23RQ6F4BWFIDBIS7XYPV5NPROCEWV2E2YXNU",
Ledger: typev1.Ledger_LEDGER_STELLAR,
}
// Mint tokens to a test address with optional network-specific options
request := &token_tapv1.MintTokenRequest{
// Specify the amount to mint (required)
Amount: &typev1.Amount{
Token: testToken,
Value: &typev1.Decimal{
Value: "1000000",
},
},
// Specify the recipient address (required)
Address: "GDQXVHH7QVVQSHCXU7ZDM4C2DAQF7UEQWPX3JHG7LJ2YS6FLXJY5E2SZ",
// Optional: Network-specific options (Stellar or Solana)
Options: &token_tapv1.MintTokenOptions{
MintTokenOptions: &token_tapv1.MintTokenOptions_StellarMintOptions{
StellarMintOptions: &token_tapv1.StellarMintOptions{
Options: []*token_tapv1.StellarMintOption{
{
StellarMintOption: &token_tapv1.StellarMintOption_StellarMintTokenWithMemo{
StellarMintTokenWithMemo: &token_tapv1.StellarMintTokenWithMemo{
Memo: "test-mint-001",
},
},
},
},
},
},
},
}
// Call the MintToken method
response, err := service.MintToken(ctx, request)
if err != nil {
log.Fatalf("MintToken failed: %v", err)
}
// Token has been minted successfully
log.Printf("Token minted successfully: %+v", response)
}
from meshtrade.testing.ledger.token_tap.v1 import (
MintTokenOptions,
MintTokenRequest,
StellarMintOption,
StellarMintOptions,
StellarMintTokenWithMemo,
TokenTapService,
)
from meshtrade.type.v1 import (
Amount,
Decimal,
Ledger,
Token,
)
def main():
# Default configuration is used and credentials come from MESH_API_CREDENTIALS
# environment variable or default discovery methods. Zero config required
# unless you want custom configuration.
service = TokenTapService()
with service:
# Create a test token (USDC on Stellar)
test_token = Token(
code="USDC",
issuer="GBUQWP3BOUZX34ULNQG23RQ6F4BWFIDBIS7XYPV5NPROCEWV2E2YXNU",
ledger=Ledger.LEDGER_STELLAR,
)
# Mint tokens to a test address with optional network-specific options
request = MintTokenRequest(
# Specify the amount to mint (required)
amount=Amount(
token=test_token,
value=Decimal(value="1000000"),
),
# Specify the recipient address (required)
address="GDQXVHH7QVVQSHCXU7ZDM4C2DAQF7UEQWPX3JHG7LJ2YS6FLXJY5E2SZ",
# Optional: Network-specific options (Stellar or Solana)
options=MintTokenOptions(
stellar_mint_options=StellarMintOptions(
stellar_mint_options=[
StellarMintOption(
stellar_mint_token_with_memo=StellarMintTokenWithMemo(
memo="test-mint-001",
)
)
]
)
),
)
# Call the MintToken method
response = service.mint_token(request)
# Token has been minted successfully
print("Token minted successfully:", response)
if __name__ == "__main__":
main()
import co.meshtrade.api.testing.ledger.token_tap.v1.TokenTapService;
import co.meshtrade.api.testing.ledger.token_tap.v1.Service.MintTokenRequest;
import co.meshtrade.api.testing.ledger.token_tap.v1.Service.MintTokenResponse;
import co.meshtrade.api.testing.ledger.token_tap.v1.Option.MintTokenOptions;
import co.meshtrade.api.testing.ledger.token_tap.v1.Option.StellarMintOptions;
import co.meshtrade.api.testing.ledger.token_tap.v1.Option.StellarMintOption;
import co.meshtrade.api.testing.ledger.token_tap.v1.Option.StellarMintTokenWithMemo;
import co.meshtrade.api.type.v1.Amount;
import co.meshtrade.api.type.v1.Decimal;
import co.meshtrade.api.type.v1.Token;
import co.meshtrade.api.type.v1.Ledger;
import java.util.Optional;
public class MintTokenExample {
public static void main(String[] args) {
// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
try (TokenTapService service = new TokenTapService()) {
// Create a test token (USDC on Stellar)
Token testToken = Token.newBuilder()
.setCode("USDC")
.setIssuer("GBUQWP3BOUZX34ULNQG23RQ6F4BWFIDBIS7XYPV5NPROCEWV2E2YXNU")
.setLedger(Ledger.LEDGER_STELLAR)
.build();
// Create Stellar memo option
StellarMintTokenWithMemo memo = StellarMintTokenWithMemo.newBuilder()
.setMemo("test-mint-001")
.build();
StellarMintOption stellarOption = StellarMintOption.newBuilder()
.setStellarMintTokenWithMemo(memo)
.build();
StellarMintOptions stellarOptions = StellarMintOptions.newBuilder()
.addStellarMintOptions(stellarOption)
.build();
MintTokenOptions options = MintTokenOptions.newBuilder()
.setStellarMintOptions(stellarOptions)
.build();
// Mint tokens to a test address with optional network-specific options
MintTokenRequest request = MintTokenRequest.newBuilder()
// Specify the amount to mint (required)
.setAmount(
Amount.newBuilder()
.setToken(testToken)
.setValue(
Decimal.newBuilder()
.setValue("1000000")
.build()
)
.build()
)
// Specify the recipient address (required)
.setAddress("GDQXVHH7QVVQSHCXU7ZDM4C2DAQF7UEQWPX3JHG7LJ2YS6FLXJY5E2SZ")
// Set optional Stellar options
.setOptions(options)
.build();
// Call the MintToken method
MintTokenResponse response = service.mintToken(request, Optional.empty());
// Token has been minted successfully
System.out.println("Token minted successfully: " + response);
} catch (Exception e) {
System.err.println("MintToken failed: " + e.getMessage());
e.printStackTrace();
}
}
}
Advanced Configuration​
For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.
Other Methods​
- Testing/Ledger Token Tap v1 Method List - For Other methods