Skip to main content

CalculateTransferFee

Calculates the transfer fee for a given transfer amount. Returns the calculated fee amount, VAT amount and VAT rate that would be applied to a transfer of the specified amount.

Method Options​

Authorisation specification of the CalculateTransferFee method.

TypeMETHOD_TYPE_READ
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_WALLET_ADMIN
  • ROLE_WALLET_VIEWER
  • ROLE_WALLET_TRANSFER_ADMIN
  • ROLE_WALLET_TRANSFER_VIEWER

Parameters​

Request and response parameter message overview:

Input: CalculateTransferFeeRequest Message​

FieldTypeRequiredDescription
Amount

meshtrade.type.v1.Amount

True

The transfer amount to calculate fees for.

Returns: CalculateTransferFeeResponse Message​

FieldTypeDescription
FeeAmount

meshtrade.type.v1.Amount

The calculated fee amount for the transfer.

VatAmount

meshtrade.type.v1.Amount

The VAT amount calculated on the fee.

VatRate

meshtrade.type.v1.Decimal

The VAT rate used for the fee calculation.

Code Examples​

Select supported SDK in the language of your choice for a full example of how to invoke the this method:

package main

import (
"context"
"log"

typev1 "github.com/meshtrade/api/go/type/v1"
transferv1 "github.com/meshtrade/api/go/wallet/transfer/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 := transferv1.NewTransferService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Create request with the transfer amount to calculate fees for
request := &transferv1.CalculateTransferFeeRequest{
Amount: &typev1.Amount{
Token: &typev1.Token{
Code: "USDC",
Issuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
Ledger: typev1.Ledger_LEDGER_STELLAR,
},
Value: &typev1.Decimal{Value: "1000.00"},
},
}

// Call the CalculateTransferFee method
response, err := service.CalculateTransferFee(ctx, request)
if err != nil {
log.Fatalf("CalculateTransferFee failed: %v", err)
}

// Display the fee breakdown
log.Printf("Transfer fee breakdown:")
log.Printf(" Fee Amount: %s %s", response.FeeAmount.Value.Value, response.FeeAmount.Token.Code)
log.Printf(" VAT Amount: %s %s", response.VatAmount.Value.Value, response.VatAmount.Token.Code)
log.Printf(" VAT Rate: %s", response.VatRate.Value)
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​