Swap
The Swap API is used to execute a swap transaction. By invoking this API, users can initiate and process a swap between two different digital assets.
Method: POST
{{URL}}/jsonrpc
Headers
Name | Value |
---|---|
Content-Type | application/json |
Example
Payload Parameters
Parameter | Description |
---|---|
id Mandatory | String Represents the unique identifier associated with the swap transaction request. Ex: "701001" |
asset Mandatory | String Represents the source asset for the swap transaction. Ex: "XLM" |
issuer Mandatory | String Represents the issuer of the source asset. Ex: "" |
amount Mandatory | String Represents the amount of the source asset to be swapped. Ex: "10" |
destinationAsset Mandatory | Number Represents the destination wallet account for the swap transaction. Ex: "USDC" |
destinationIssuer Mandatory | String Represents the issuer of the destination asset. Ex: "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW" |
quotationId Mandatory | String Represents the unique identifier for the swap quotation. Ex: "865001" |
minDestAmount Mandatory | String Represents the minimum amount of the destination asset to be received. Ex: "9" |
slippagePercent Mandatory | String Represents the slippage percentage for the swap transaction. Ex: "2" |
exchangeRate Mandatory | String Represents the exchange rate used for the swap transaction. Ex: "1" |
fee Mandatory | String Represents the fee amount for the swap transaction. Ex: "100" |
- cURL
- C#
- Go
- NodeJs
curl --location '{{url}}/rpc/WalletService/Swap' \
--header 'DiviceID: 8020' \
--header 'Signature: keyId=8020,algorithm=ecdsa-sha256,signature=MEUCIQCNi1vjPf/HpI9R2DXnc0Zt1s6YmWyA4H1x813lJ+tuDgIgB+lrc+iCMyTUGiraG9kGKNDXYiz7RfBBtifr5wUQs54=' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic e3tFbWFpbH19Ont7UGFzc3dvcmR9fQ==' \
--data '{"id":"701001","asset":"XLM","issuer":"","amount":"10","destinationAsset":"USDC","destinationIssuer":"GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW","quotationId":"865001","minDestAmount":"9","slippagePercent":"2","exchangeRate":"1","fee":"100"}'
var options = new RestClientOptions("{{url}}")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/fednowbackend/rpc/WalletService/Swap", Method.Post);
request.AddHeader("DiviceID", "8020");
request.AddHeader("Signature", "keyId=8020,algorithm=ecdsa-sha256,signature=MEUCIQCNi1vjPf/HpI9R2DXnc0Zt1s6YmWyA4H1x813lJ+tuDgIgB+lrc+iCMyTUGiraG9kGKNDXYiz7RfBBtifr5wUQs54=");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Basic e3tFbWFpbH19Ont7UGFzc3dvcmR9fQ==");
var body = @"{
" + "\n" +
@" ""id"": ""701001"",
" + "\n" +
@" ""asset"": ""XLM"",
" + "\n" +
@" ""issuer"": """",
" + "\n" +
@" ""amount"": ""10"",
" + "\n" +
@" ""destinationAsset"": ""USDC"",
" + "\n" +
@" ""destinationIssuer"": ""GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW"",
" + "\n" +
@" ""quotationId"": ""865001"",
" + "\n" +
@" ""minDestAmount"": ""9"",
" + "\n" +
@" ""slippagePercent"": ""2"",
" + "\n" +
@" ""exchangeRate"": ""1"",
" + "\n" +
@" ""fee"": ""100""
" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "{{url}}/rpc/WalletService/Swap"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"id": "701001",`+"
"+`
"asset": "XLM",`+"
"+`
"issuer": "",`+"
"+`
"amount": "10",`+"
"+`
"destinationAsset": "USDC",`+"
"+`
"destinationIssuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",`+"
"+`
"quotationId": "865001",`+"
"+`
"minDestAmount": "9",`+"
"+`
"slippagePercent": "2",`+"
"+`
"exchangeRate": "1",`+"
"+`
"fee": "100"`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("DiviceID", "8020")
req.Header.Add("Signature", "keyId=8020,algorithm=ecdsa-sha256,signature=MEUCIQCNi1vjPf/HpI9R2DXnc0Zt1s6YmWyA4H1x813lJ+tuDgIgB+lrc+iCMyTUGiraG9kGKNDXYiz7RfBBtifr5wUQs54=")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic e3tFbWFpbH19Ont7UGFzc3dvcmR9fQ==")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': '{{url}}',
'path': '/fednowbackend/rpc/WalletService/Swap',
'headers': {
'DiviceID': '8020',
'Signature': 'keyId=8020,algorithm=ecdsa-sha256,signature=MEUCIQCNi1vjPf/HpI9R2DXnc0Zt1s6YmWyA4H1x813lJ+tuDgIgB+lrc+iCMyTUGiraG9kGKNDXYiz7RfBBtifr5wUQs54=',
'Content-Type': 'application/json',
'Authorization': 'Basic e3tFbWFpbH19Ont7UGFzc3dvcmR9fQ=='
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"id": "701001",
"asset": "XLM",
"issuer": "",
"amount": "10",
"destinationAsset": "USDC",
"destinationIssuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",
"quotationId": "865001",
"minDestAmount": "9",
"slippagePercent": "2",
"exchangeRate": "1",
"fee": "100"
});
req.write(postData);
req.end();
Body
{
"id": "701001",
"asset": "XLM",
"issuer": "",
"amount": "10",
"destinationAsset": "USDC",
"destinationIssuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",
"quotationId": "865001",
"minDestAmount": "9",
"slippagePercent": "2",
"exchangeRate": "1",
"fee": "100"
}
Response: 200
Response Parameters
Parameter | Description |
---|---|
ID | String Represents the unique identifier associated with the swap transaction request. Ex: "701001" |
asset | String Represents the source asset for the swap transaction. Ex: "XLM" |
destination | String Represents the destination wallet account for the swap transaction. Ex: "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ" |
fee | String Represents the fee amount for the swap transaction. Ex: "100" |
threshold | Number Represents the required approval threshold for the swap transaction. Ex: 5 |
xdr | String Represents the XDR (Stellar Transaction Envelope) for the swap transaction. Ex: "AAAAAgAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAMgAAgmNAAAAGQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpef/////////8AAAABAAAAABNwOr1qlr9vhu7wEduBzlD/CLsA9OSR9ULQwOhYJZV3AAAADQAAAAAAAAAABfXhAAAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpeAAAAAAVdSoAAAAABAAAAAAAAAAAAAAAA" |
amount | String Represents the amount of the source asset to be swapped. Ex: "10" |
message | String Represents the status message of the swap transaction request. Ex: "Swap Transaction Request Raised Successfully" |
ticket | Object |
id | String Unique id. Ex: "81002" |
requestID | String Unique request id. Ex: "81001" |
customerID | String epresents the unique identifier of the customer associated with the swap transaction. Ex: "100000000000001" |
applicationCode | String The application code associated with the swap transaction. Ex: "PL" |
ticketName | String The name of the swap transaction ticket. Ex: "WALLET_SWAP" |
createdTS | String The timestamp indicating the creation time of the swap transaction ticket. Ex: "2023-06-25T21:52:26.553293111+05:30" |
updatedTS | String The timestamp indicating the last update time of the swap transaction ticket. Ex: "2023-06-25T21:52:26.553293279+05:30" |
createdBy | String The email address or identifier of the user who created the swap transaction ticket. Ex: "ashutosh.m+5@netxd.com" |
payloadJSON | Object |
ID | String Represents the unique identifier associated with the swap transaction request. Ex: "701001" |
asset | String Represents the source asset for the swap transaction. Ex: "XLM" |
destination | String Represents the destination wallet account for the swap transaction. Ex: "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ" |
fee | String Represents the fee amount for the swap transaction. Ex: "100" |
threshold | Number Represents the required approval threshold for the swap transaction. Ex: 5 |
xdr | String Represents the XDR for the swap transaction. Ex: "AAAAAgAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAMgAAgmNAAAAGQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpef/////////8AAAABAAAAABNwOr1qlr9vhu7wEduBzlD/CLsA9OSR9ULQwOhYJZV3AAAADQAAAAAAAAAABfXhAAAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpeAAAAAAVdSoAAAAABAAAAAAAAAAAAAAAA" |
amount | String Represents the amount of the source asset to be swapped. Ex: "10" |
senderID | String Represents the ID of the sender wallet account. Ex: "999701002" |
senderName | String Represents the name of the sender wallet account. Ex: "Eighth Wallet" |
senderPublicKey | String Represents the public key of the sender wallet account. Ex: "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ" |
transactionType | String Represents the type of the transaction. Ex: "WALLET_SWAP" |
issuer | String Represents the issuer of the source asset. Ex: "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW" |
receiverID | String Represents the ID of the receiver wallet account. Ex: "999701002" |
receiverName | String Represents the name of the receiver wallet account. Ex: "Eighth Wallet" |
receiverType | String Represents the type of the receiver wallet account. Ex: "INTERNAL" |
receiverPublicKey | String Represents the public key of the receiver wallet account. Ex: "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ" |
ticketName | String Represents the name of the ticket associated with the swap transaction request. Ex: "WALLET_SWAP" |
actualRequiredThreshold | Number Represents the actual required approval threshold for the swap transaction. Ex: 5 |
destinationAsset | String Represents the destination asset for the swap transaction. Ex: "USDC" |
destinationIssuer | String Represents the issuer of the destination asset. Ex: "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW" |
quotationId | String Represents the unique identifier for the swap quotation. Ex: "865001" |
estimateAmount | String Represents the estimated amount of the destination asset to be received. Ex: "9.9800399" |
exchangeRate | String Represents the exchange rate used for the swap transaction. Ex: "1" |
slippagePercent | String Represents the slippage percentage for the swap transaction. Ex: "2" |
swapFlag | Boolean Represents a flag indicating whether the swap transaction is enabled or disabled. Ex: "true" |
minDestAmount | String Represents the minimum amount of the destination asset to be received. Ex: "9" |
state | String The current state or status of the swap transaction ticket. Ex: "OPEN" |
status | String The status of the swap transaction ticket. Ex: "WAITING_FOR_APPROVAL" |
noOfApproval | Number The number of approvals received for the swap transaction ticket. Ex: 1 |
ticketHistory | Array |
updatedBy | String It represents the user or entity that performed the update or modification to the swap transaction ticket. Ex: "ashutosh.m+5@netxd.com" |
updatedDate | String It denotes the timestamp indicating the date and time when the update or modification to the swap transaction ticket occurred. Ex: "2023-06-25T21:52:26.554112641+05:30" |
state | String The current state or status of the swap transaction ticket. Ex: "OPEN" |
accountId | String The ID of the account associated with the swap transaction ticket. Ex: "701001" |
senderID | String The ID of the sender or originator of the swap transaction. Ex: "999701002" |
senderName | String The name of the sender or originator of the swap transaction. Ex: "Eighth Wallet" |
senderPublicKey | String The public key associated with the sender or originator of the swap transaction. Ex: "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ" |
transactionType | String The type or category of the swap transaction. Ex: "WALLET_SWAP" |
issuer | String The issuer of the destination asset involved in the swap. Ex: "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW" |
receiverID | String The ID of the receiver or destination of the swap transaction. Ex: "999701002" |
receiverName | String The name of the receiver or destination of the swap transaction. Ex: "Eighth Wallet" |
receiverType | String The type or category of the receiver or destination of the swap transaction. Ex: "INTERNAL" |
receiverPublicKey | String The public key associated with the receiver or destination of the swap transaction. Ex: "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ" |
ticketName | String The name or identifier of the swap transaction ticket. Ex: "WALLET_SWAP" |
actualRequiredThreshold | Number The actual required threshold of signatures for the swap transaction. Ex: 5 |
destinationAsset | String The asset code of the destination asset involved in the swap. Ex: "USDC" |
destinationIssuer | String The issuer of the destination asset involved in the swap. Ex: "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW" |
quotationId | String The ID or identifier of the quotation used for the swap transaction. Ex: "865001" |
estimateAmount | String The estimated amount of the swapped asset based on the provided quotation and other parameters. Ex: "9.9800399" |
exchangeRate | String The exchange rate used for the swap transaction. Ex: "1" |
slippagePercent | String The allowed slippage percentage for the swap transaction. Ex: "2" |
swapFlag | Boolean A flag indicating whether the swap transaction is enabled or active. Ex: true |
minDestAmount | String The minimum destination amount required for the swap transaction. Ex: "9" |
{
"ID": "701001",
"asset": "XLM",
"destination": "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ",
"fee": "100",
"threshold": 5,
"xdr": "AAAAAgAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAMgAAgmNAAAAGQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpef/////////8AAAABAAAAABNwOr1qlr9vhu7wEduBzlD/CLsA9OSR9ULQwOhYJZV3AAAADQAAAAAAAAAABfXhAAAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpeAAAAAAVdSoAAAAABAAAAAAAAAAAAAAAA",
"amount": "10",
"message": "Swap Transaction Request Raised Successfully",
"ticket": {
"id": "81002",
"requestID": "81001",
"customerID": "100000000000001",
"applicationCode": "PL",
"ticketName": "WALLET_SWAP",
"createdTS": "2023-06-25T21:52:26.553293111+05:30",
"updatedTS": "2023-06-25T21:52:26.553293279+05:30",
"createdBy": "ashutosh.m+5@netxd.com",
"payloadJSON": "{
"ID": "701001",
"asset": "XLM",
"destination": "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ",
"fee": "100",
"threshold": 5,
"xdr": "AAAAAgAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAMgAAgmNAAAAGQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpef/////////8AAAABAAAAABNwOr1qlr9vhu7wEduBzlD/CLsA9OSR9ULQwOhYJZV3AAAADQAAAAAAAAAABfXhAAAAAAATcDq9apa/b4bu8BHbgc5Q/wi7APTkkfVC0MDoWCWVdwAAAAFVU0RDAAAAAMM68otPTm032EyGaq9XfDGy72rVPs8wz0p2pBvEKRpeAAAAAAVdSoAAAAABAAAAAAAAAAAAAAAA",
"amount": "10",
"senderID": "999701002",
"senderName": "Eighth Wallet",
"senderPublicKey": "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ",
"transactionType": "WALLET_SWAP",
"issuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",
"receiverID": "999701002",
"receiverName": "Eighth Wallet",
"receiverType": "INTERNAL",
"receiverPublicKey": "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ",
"ticketName": "WALLET_SWAP",
"actualRequiredThreshold": 5,
"destinationAsset": "USDC",
"destinationIssuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",
"quotationId": "865001",
"estimateAmount": "9.9800399",
"exchangeRate": "1",
"slippagePercent": "2",
"swapFlag": true,
"minDestAmount": "9"
}",
"state": "OPEN",
"status": "WAITING_FOR_APPROVAL",
"noOfApproval": 1,
"ticketHistory": [
{
"updatedBy": "ashutosh.m+5@netxd.com",
"updatedDate": "2023-06-25T21:52:26.554112641+05:30",
"state": "OPEN"
}
],
"accountId": "701001"
},
"senderID": "999701002",
"senderName": "Eighth Wallet",
"senderPublicKey": "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ",
"transactionType": "WALLET_SWAP",
"issuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",
"receiverID": "999701002",
"receiverName": "Eighth Wallet",
"receiverType": "INTERNAL",
"receiverPublicKey": "GAJXAOV5NKLL634G53YBDW4BZZIP6CF3AD2OJEPVILIMB2CYEWKXOVOQ",
"ticketName": "WALLET_SWAP",
"actualRequiredThreshold": 5,
"destinationAsset": "USDC",
"destinationIssuer": "GDBTV4ULJ5HG2N6YJSDGVL2XPQY3F33K2U7M6MGPJJ3KIG6EFENF56QW",
"quotationId": "865001",
"estimateAmount": "9.9800399",
"exchangeRate": "1",
"slippagePercent": "2",
"swapFlag": true,
"minDestAmount": "9"
}