Gluwa SDK for .NET
If your service is developed in .NET, the features we provide are available through the SDK. The Gluwa SDK for .NET is a library with powerful features that enable .NET developers to easily make requests to the Gluwa APIs.
At the moment, our .NET SDK only supports Gluwacoin transfers. For Bitcoin transfers, please use the REST API.

Getting Started

The namespace of Gluwa SDK is Gluwa.SDK_dotnet. The SDK requires .NET Core 2.1 or above.
Gluwa.SDK_dotnet 1.2.2
nuget
Refer to the Microsoft documentation below to learn how to install Nuget packages.
Installing NuGet client tools
docsmsft

Clients

To use Gluwa API, you need to create a Client object and initialize it. There are two types of Clients:
  1. 1.
    GluwaClient for managing funds by creating or retrieving transaction
  2. 2.
    QRCodeClient for creating QR codes.
Input
Type
Description
bool
false by default. If you want to use the SandBox mode, set true

GluwaClient

1
GluwaClient gluwaClient = new GluwaClient();
2
// If you want to use the SandBox mode
3
GluwaClient gluwaClient = new GluwaClient(true);
Copied!

QRCodeClient

1
QRCodeClient qrCodeClient = new QRCodeClient();
2
// If you want to use the SandBox mode
3
QRCodeClient qrCodeClient = new QRCodeClient(true);
Copied!

Method Examples

GluwaClient

1
ECurrency currency = "{USDG or KRWG or NGNG or BTC}";
2
string address = "{Your Gluwacoin public Address}";
3
string privateKey = "{Your Gluwacoin Private Key}";
4
string amount = "{Transaction amount, not including the fee}";
5
string target = "{The address that the transaction will be sent to}";
6
string merchantOrderID = "{Identifier for the transaction that was provided by the merchant user}"; // default to null. Optional
7
string note = "{Additional information about the transaction that a user can provide}"; // default to null. Optional
8
string nonce = "{Nonce for the transaction. For Gluwacoin currencies only}"; // default to null. Optional
9
string idem = "{Idempotent key for the transaction to prevent duplicate transactions}"; // default to null. Optional
10
string paymentID = "{ID for the QR code payment}"; // default to null. Optional
11
string paymentSig = "{Signature of the QR code payment. Required if PaymentID is not null}"; // default to null. Optional
12
13
Result<bool, ErrorResponse> result = await gluwaClient.CreateTransactionAsync(
14
currency,
15
address,
16
privateKey,
17
amount,
18
target,
19
merchantOrderID, // optional, default = null
20
note, // optional, default = null
21
nonce, // optional, default = null
22
idem, // optional, default = null
23
paymentID, // optional, default = null
24
paymentSig // optional, default = null
25
);
26
27
if (result.IsFailure)
28
{
29
switch (result.Error.Code)
30
{
31
case "ErrorCode1":
32
// handle error 1
33
break;
34
case "ErrorCode2":
35
// handle error 2
36
break;
37
default:
38
// handle error
39
break;
40
}
41
}
42
else
43
{
44
// successful response. See result.Data for the response
45
}
46
Copied!
Returns true if successful and false if unsuccessful. Successful response means that the transaction has been accepted by Gluwa and will be included in the blockchain in a couple of minutes.
1
ECurrency currency = "{USDG or KRWG or NGNG or BTC}";
2
string address = "{Your Gluwacoin public Address}";
3
string privateKey = "{Your Gluwacoin Private Key}";
4
uint limit = "{Number of transactions to include in the result}"; // defaults to 100. Optional
5
ETransactionStatusFilter status = "{Incomplete or Confirmed}"; // defaults to Confirmed. Optional
6
uint offset = "{Number of transactions to skip}"; // default to 0. Optional”
7
8
Result<List<SuccessResponse>, ErrorResponse> result = await gluwaClient.GetTransactionListAsync(
9
currency,
10
address,
11
privateKey,
12
limit, // optional, default = 100
13
status, // optional, default = Confirmed,
14
offset // optional, default = 0
15
);
16
17
if (result.IsFailure)
18
{
19
switch (result.Error.Code)
20
{
21
case "ErrorCode1":
22
// handle error 1
23
break;
24
case "ErrorCode2":
25
// handle error 2
26
break;
27
default:
28
// handle error
29
break;
30
}
31
}
32
else
33
{
34
// successful response. See result.Data for the response
35
}
36
Copied!
1
ECurrency currency = "{USDG or KRWG or NGNG or BTC}";
2
string privateKey = "{Your Gluwacoin Private Key}";
3
string txnHash = "{Hash of the transaction on the blockchain}";
4
5
Result<SuccessResponse, ErrorResponse> result = await gluwaClient.GetTransactionDetailsAsync(
6
currency,
7
privateKey,
8
txnHash
9
);
10
11
if (result.IsFailure)
12
{
13
switch (result.Error.Code)
14
{
15
case "ErrorCode1":
16
// handle error 1
17
break;
18
case "ErrorCode2":
19
// handle error 2
20
break;
21
default:
22
// handle error
23
break;
24
}
25
}
26
else
27
{
28
// successful response. See result.Data for the response
29
}
30
Copied!
1
ECurrency currency = "{USDG or KRWG or NGNG or BTC}";
2
string address = "{Your Gluwacoin public Address}";
3
bool bUnspentOutputs = false; // (For BTC only) if true, the response includes unspent outputs for the address. Default to false. Optional
4
5
Result<SuccessResponse, ErrorResponse> result = await gluwaClient.GetBalanceAsync(
6
currency,
7
address,
8
bUnspentOutputs
9
);
10
11
if (result.IsFailure)
12
{
13
switch (result.Error.Code)
14
{
15
case "ErrorCode1":
16
// handle error 1
17
break;
18
case "ErrorCode2":
19
// handle error 2
20
break;
21
default:
22
// handle error
23
break;
24
}
25
}
26
else
27
{
28
// successful response. See result.Data for the response
29
}
30
Copied!

QRCodeClient

1
string apiKey = "{Your API Key}";
2
string secret = "{Your API Secret}";
3
string address = "{Your public address}";
4
string privateKey = "{Your private Key}";
5
EPaymentCurrency currency = "{USDG or KRWG or NGNG}";
6
string amount = "{Payment amount}";
7
string format = "{Desired image format}"; // defaults to null. Returns base64 string. Optional.
8
// if you want to receive an image file put ‘image/jpeg’ or ‘image/png’ instead.
9
string note = "{Additional information, used by the merchant user}"; // default to null. Optional
10
string merchantOrderID = "{Identifier for the payment, used by the merchant user}"; // default to null. Optional
11
int expiry = "{Time of expiry for the QR code in seconds}"; // default to 1800. Optional”
12
13
Result<string, ErrorResponse> result = await qRCodeClient.GetPaymentQRCodeAsync(
14
apiKey,
15
secret,
16
address,
17
privateKey,
18
currency,
19
amount,
20
format, //optional, default = null
21
note, //optional, default = null
22
merchantOrderID, //optional, default = null
23
expiry //optional, default = 1800
24
);
25
26
if (result.IsFailure)
27
{
28
switch (result.Error.Code)
29
{
30
case "ErrorCode1":
31
// handle error 1
32
break;
33
case "ErrorCode2":
34
// handle error 2
35
break;
36
default:
37
// handle error
38
break;
39
}
40
}
41
else
42
{
43
// successful response. See result.Data for the response
44
}
45
Copied!

Webhook Validation

A method for validating if the webhook is from Gluwa or not. Gluwa sends a webhook request when a transaction is created or completed. Learn more about webhooks from Gluwa here.
1
PayLoad payLoad = new PayLoad()
2
{
3
Data = new Data
4
{
5
MerchantOrderID = "My merchant order ID",
6
EventType = EEventType.TransactionConfirmed,
7
Type = ENotificationType.Webhook,
8
ResourceID = "0xfd820a7e9d9851537e259289269db88826a561a04e1c6982b4d860c797a625ce"
9
}
10
};
11
12
string signature = "{The value of X-REQUEST-SIGNATURE header}";
13
string webhookSecretKey = "{Your Webhook Secret}";
14
15
bool bValidated = Webhook.ValidateWebhook(
16
payLoad,
17
signature,
18
webhookSecretKey); // true if validation was successful
Copied!
Last modified 1yr ago