Posted By : Hotam
A stellar anchor is a trusted entity on the Stellar network that can hold a user's deposits and issue credit for the deposits a user has requested to the anchor. Anchors act as a bridge between actual currencies and the Stellar network. Anchor issues credits to users equivalent to actual currency value in the form of assets.
Established currency may be of any currency i.e. Fiat or Crypto. Users can then use this credit to initiate transactions on stellar networks. Anchors tend to be organizations such as financial institutions, remittance companies, and central banks.
Before continuing with the setup guide, you should be familiar with the following:
Account Structure
As an anchor, you need to maintain at least two accounts:
Issuing account - An issuing account is used for issuing or destroying assets. If a new user wants to trade an asset under the control of an anchor, the anchor will simply credit the user's account, thus issuing a new asset. Similarly, if the user wants to withdraw that credit, the issued asset will subsequently be destroyed as well.
Base account - The base account is the account an anchor uses to transact with other Stellar accounts on the network. When a user wants to make a deposit with an anchor, once a deposit is received by anchor authorities in the form of Fiat or Crypto, an equivalent amount of that deposit is then credited to the user's account from the anchor's base account.
However, before an anchor issues an asset to a user, a trustline must be issued. The user must first create a trustline with the anchor. Once a user creates a trustline, the user is available to use that asset and transactions. A trustline signifies that a user trusts the asset being issued and believes it to be redeemable at a later date.
Note: For testing purposes, you can create these accounts on the test network using the laboratory or the steps from the "this" guide.
For this demonstration purpose, we'll use the following accounts:
Issuing Account ID GBK54TBCUNCHJX7PIGAEEEBB35H2TUCM6MZWNHOA4ZANNWKWXLGRRCFA
Issuing Seed
SBI54OUXGKVI3YXOXY5EL3HCMBQQQVV4JHWPHPGRD6EXT4DYGQTGIBBT
Base Account ID
GAQK3WYDV35F6P6S4JXJE5B2RQGCWLZT5OMM7TGL5KKAXYQ4CJGTN2KE
Base Seed
SCOXFQ7GHNTFFKR7V4OD3N7YQM5Z4AJNOJ43N5EJIWOY3CUJP4JGIRAT
Customer Accounts
Stellar anchor manages users' accounts at its level. There are many ways that a Stellar anchor can manage customer accounts, two of those ways are as follows:
Maintain a Stellar account for each customer - By maintaining a Stellar account for each customer, deposits and withdrawals can be credited and retracted from a user's account depending on action. For example, if a user wants to make a deposit, the appropriate amount would simply be credited to their account by the anchor and vice versa if the user wants to make a withdrawal.
Use the federation protocol to conduct transactions - By using the federation protocol, a Stellar anchor can send and receive payments on behalf of their users. In this case, the anchor's base account needs to be maintained for all the transactions going through the anchor.
Note: You can follow any of the above approaches to maintain customer accounts on anchor.
Architecture
The stellar architecture comprises the following five servers:
Making Payments
When using the above services, a payment using bridge, federation, and compliance works as follows:
Receiving Payments:
When someone is sending a payment to you, the flow is different slightly:
In the above payments, most of the work is handled by the steller's compliance, federation, and bridge servers. You need to implement callbacks correctly. We will guide you through when setting up those servers.
Set up Servers
Now, we will see to set up the individual servers and once setup is done, we will go through the action part by interacting with each other to send a payment through.
Set Up Bridge Server
Stellar maintains its own bridge server which makes us easier to use the federation server and compliance server to send and receive payments. If you wish to use steller's bridge server, you only need to write the services that receive payment notifications and provide responses to regulatory checks.
When you process the payments via the bridge server, we need to make an HTTP request to the bridge server rather than sending requests to the horizon server directly.
Create a Database
Create a database for manipulating the bridge server data. For this guide, we are using the bridge_test database and creating a user to manage this database. The bridge server requires a postgresQL database to manage data and compliance information. Run the below commands to create a database.
Note: You must have postgresQL installed before creating a database.
|
Download and configure database
Download the bridge server here and set it up for your platform. Download and install the executables. To set up the bridge server, create a file bridge.cfg inside the downloaded bridge server. Your bridge server will be configured based on this file. For example:
|
Start the Bridge Server
If you are running the bridge server for the very first time, run below command:
|
Otherwise run below command:
|
Note: --migrate-db command sets up bridge server for use.
Set Up Compliance Server
Stellar maintains its own compliance server which makes it easier to use bridge server and federation server to send and receive payments. If you wish to use steller's compliance server, you only need to write the callbacks that are required for the compliance checks.
Create a Database
Create a database for manipulating the compliance server data. For this guide, we are using a compliance_test database and creating a user to manage this database. Compliance server requires a postgresQL database to manage data and compliance information. Run below commands to create a database.
Note: You must have postgresQL installed before creating a database.
|
Download and configure database
Download the compliance server here and set up for your platform. Download and install the executables. To set up the compliance server, create a a file compliance.cfg inside the downloaded compliance server. Your compliance server will be configured based on this file. For example:
|
Start the Compliance Server
If you are running the bridge server for the very first time, run the below command:
|
Otherwise, run the below command:
|
Note: --migrate-db command sets up bridge server for use.
Set Up Federation Server
Stellar maintains its own federation server which makes it easier to set up and run very quickly. But you can write your own if you wish to. The stellar federation address allows us to convert the human-readable format to the stellar account ID. For example, hotam_sing*api.domain.com will return my stellar account ID.
Create a Database
Create a database for manipulating user data. The federation server is designed in such a way that it can be configured with any SQL database. For this guide, we are using a federation_test database and creating a user to manage this database.
Note: You must have postgresQL/SQLite3 installed before creating a database.
|
Download and configure database
Download the federation server here and set it up for your platform. Download and install the executables. To set up the federation server, create a file federation.cfg inside the downloaded federation server. Your federation server will be configured based on this file. For example:
|
Start the Bridge Serve
|
Steps to follow
Please follow below documentation for the steps in setting up the anchor:
Conclusion
To conclude, Stellar anchors are one of the main components of the Stellar network and facilitate the user to trade on the stellar network on behalf of the user's actual currency i.e Fiat or Crypto by issuance of related assets. We need to take care of a certain level of infrastructure that is necessary before an anchor is successfully set up. Infrastructure such as: compliance protocols, payment processing capabilities and AML must also be in place in order to become an anchor on the Stellar network.
References
https://www.stellar.org/developers/guides/anchor/
December 17, 2024 at 04:36 pm
Your comment is awaiting moderation.