Skip to content

Commit

Permalink
update sep-06 to reflect current doc
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Feb 23, 2024
1 parent 9df9a35 commit e10a379
Show file tree
Hide file tree
Showing 9 changed files with 2,021 additions and 469 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.7.5] - 23.Feb.2024.
- update SEP-12 financial account fields
- update SEP-06 to reflect current SEP doc version

## [1.7.4] - 01.Feb.2024.
- add SEP-38 support

Expand Down
Binary file modified documentation/sdk_api_doc.zip
Binary file not shown.
91 changes: 62 additions & 29 deletions documentation/sdk_examples/sep-0006-transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ final transferService = TransferServerService("http://api.stellar-anchor.org/tra
This endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#info)) allows an anchor to communicate basic info about what their TRANSFER_SERVER supports to wallets and clients. With the flutter sdk you can use the ```info``` method of your ```TransferServerService``` instance to get the info:

```dart
// uses the jwt token received from stellar web auth - sep-0010
InfoResponse response = await transferService.info("en", jwtToken);
InfoResponse response = await transferService.info();
print(response.feeInfo.enabled);
```

Expand All @@ -42,11 +41,11 @@ print(response.feeInfo.enabled);
This endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#deposit)) is used when a user sends an external token (BTC via Bitcoin, USD via bank transfer, etc...) to an address held by an anchor. With the flutter sdk you can use the ```deposit``` method of your ```TransferServerService``` instance to get the deposit information:

```dart
DepositRequest request = DepositRequest();
request.jwt = jwtToken; // jwt token received from stellar web auth - sep-0010
request.assetCode = "BTC";
request.account = accountId; // The stellar account ID of the user that wants to deposit.
// ...
DepositRequest request = DepositRequest(
jwt: jwtToken,
assetCode: 'USD',
account: accountId,
);
try {
DepositResponse response = await transferService.deposit(request);
Expand All @@ -59,17 +58,17 @@ try {
} // ...
```



### Withdraw

This endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#withdraw)) is used when a user redeems an asset currently on the Stellar network for it's equivalent off-chain asset via the Anchor. For instance, a user redeeming their NGNT in exchange for fiat NGN. With the flutter sdk you can use the ```withdraw``` method of your ```TransferServerService``` instance to get the withdrawal information:

```dart
WithdrawRequest request = WithdrawRequest();
request.jwt = jwtToken; // jwt token received from stellar web auth - sep-0010
request.assetCode = "NGNT";
request.amount = "129.01";
WithdrawRequest request = WithdrawRequest(
assetCode: 'NGNT',
type: 'bank_account',
jwt: jwtToken,
);
// ...
try {
Expand All @@ -83,35 +82,74 @@ try {
} // ...
```

### Deposit-Exchange

If the anchor supports SEP-38 quotes, it can provide a deposit that makes a bridge between non-equivalent tokens by receiving, for instance BRL via bank transfer and in return sending the equivalent value (minus fees) as USDC to the user's Stellar account.

The /deposit-exchange endpoint allows a wallet to get deposit information from an anchor when the user intends to make a conversion between non-equivalent tokens. With this endpoint, described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#deposit-exchange), a user has all the information needed to initiate a deposit and it also lets the anchor specify additional information (if desired) that the user must submit via SEP-12.

```dart
DepositExchangeRequest request = DepositExchangeRequest(
destinationAsset: 'USDC',
sourceAsset: 'iso4217:BRA:',
amount: '480.00',
account: accountId,
jwt: jwtToken,
);
DepositResponse response = await transferService.depositExchange(request);
var instructions = response.instructions;
//...
```

### Withdraw-Exchange

If the anchor supports SEP-38 quotes, it can provide a withdraw that makes a bridge between non-equivalent tokens by receiving, for instance USDC from the Stellar network and in return sending the equivalent value (minus fees) as NGN to the user's bank account.

The /withdraw-exchange endpoint allows a wallet to get withdraw information from an anchor when the user intends to make a conversion between non-equivalent tokens. With this endpoint, a user has all the information needed to initiate a withdraw and it also lets the anchor specify additional information (if desired) that the user must submit via SEP-12.

```dart
WithdrawExchangeRequest request = WithdrawExchangeRequest(
sourceAsset: 'USDC',
destinationAsset: 'iso4217:NGN',
amount: '700',
type: 'bank_account',
jwt: jwtToken,
);
WithdrawResponse response = await transferService.withdrawExchange(request);
print(response.accountId);
//...
```

### Fee

This endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#fee)) allows an anchor to report the fee that would be charged for a given deposit or withdraw operation. With the flutter sdk you can use the ```fee``` method of your ```TransferServerService``` instance to get the info if supported by the anchor:

```dart
FeeRequest request = FeeRequest();
request.jwt = jwtToken; // jwt token received from stellar web auth - sep-0010
request.operation = "deposit";
request.assetCode = "NGN";
request.amount = 123.09;
FeeRequest request = FeeRequest(
operation: "deposit",
assetCode: "NGN",
amount: 123.09,
);
// ...
FeeResponse response = await transferService.fee(request);
print(response.fee);
```



### Transaction History

From this endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#transaction-history)) wallets can receive the status of deposits and withdrawals while they process and a history of past transactions with the anchor. With the flutter sdk you can use the ```transactions``` method of your ```TransferServerService``` instance to get the transactions:

```dart
AnchorTransactionsRequest request = AnchorTransactionsRequest();
request.jwt = jwtToken; // jwt token received from stellar web auth - sep-0010
request.account = "GCTTGO5ABSTHABXWL2FMHPZ2XFOZDXJYJN5CKFRKXMPAAWZW3Y3JZ3JK";
request.assetCode = "XLM";
AnchorTransactionsRequest request = AnchorTransactionsRequest(
assetCode: "XLM",
account: "GCTTGO5ABSTHABXWL2FMHPZ2XFOZDXJYJN5CKFRKXMPAAWZW3Y3JZ3JK",
jwt: jwtToken,
);
AnchorTransactionsResponse response = await transferService.transactions(request);
print(response.transactions.length);
Expand All @@ -120,7 +158,6 @@ print(response.transactions.first.id);
```



### Single Historical Transaction

This endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#single-historical-transaction)) enables clients to query/validate a specific transaction at an anchor. With the flutter sdk you can use the ```transaction``` method of your ```TransferServerService``` instance to get the data:
Expand All @@ -136,8 +173,6 @@ print(response.transaction.status);
// ...
```



### Update Transaction

This endpoint (described [here](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#update)) is used when the anchor requests more info via the pending_transaction_info_update status. With the flutter sdk you can use the ```patchTransaction``` method of your ```TransferServerService``` instance to update the data:
Expand All @@ -155,9 +190,7 @@ print(response.status);
// ...
```



### Further readings

For more info, see also the class documentation of ```TransferServerService``` and the sdk's sep-0006 test cases.
For more info, see also the class documentation of ```TransferServerService``` and the sdk's [SEP-0006 test cases](https://github.com/Soneso/stellar_flutter_sdk/blob/master/test/sep0006_test.dart).

Loading

0 comments on commit e10a379

Please sign in to comment.