The objective of this article is to guide any developer in the integration of Six Clovers to their financial solutions from the use of Python as a programming language. To do this, we will rely on three fundamental operations: adding a new currency to our wallet, making withdrawals and transferring funds between Six-Clovers organizations.
We are IEKO and here we are going to share with you the experience obtained by integrating one of our clients with Six Clovers.
Let´s do it!
The tools provided by those who bet on decentralization have grown exponentially in recent years thanks to the use of different blockchains that offer their own characteristics and variety of options. That is why at IEKO we are committed to developing solutions that respond to these needs in joint work with different organizations in the technology and financial sector. One of these companies is Bithan, which offers a payment infrastructure and financial solutions that allows its users to use both FIAT currencies and cryptocurrencies. These tools provided by Bithan give the user the possibility to generate investments, make payments in different instances, check balances, among other possibilities.
The surprising evolution of the different blockchains and the emergence of powerful and reliable currencies in them, confronts us with the challenge of integrating as many alternatives as possible into this solution. One of them responds to the use of a stable currency with strong circulation in the market such as USDC in the Algorand blockchain. Launched in late 2020, Algorand USDC serves as the foundation for simple, fast, and low-cost movement of funds through traditional banks, card networks, and digital dollars on the Algorand blockchain. Its growth is explained by the more than 200 million Algorand USDC in circulation as of September 2021. With partners like crypto broker Floating Point Group already supporting Algorand USDC, the network is strong and growing.
Bithan understands this reality and decides to offer its users the possibility of using its functionalities through USDC Algorand. To do this, the organization makes use of one of the most powerful tools today called .
The Six Clovers decentralized payment solution enables businesses to fully integrate and transact in digital currencies around the world. Due to the use that Six Clovers makes of peer-to-peer technology and the management of stable currencies, it is the best alternative for Bithan to offer its users the use of USDC in the Algorand network.
To understand the architecture of the solution proposed in this project, we will take the withdrawal of funds as an example operation. When we send a request to withdraw funds to the Six Clovers API, it will return a response and the «signature payloads», that is, the body of the response contains the information of the set of transactions that represents the withdrawal of funds. The body of the response is made up of a string or a set of simple strings which represent encrypted transactions and the information associated with them.
Taking these definitions into account, our architecture should respond to the following flow:
🔶 Decode the response body and get the transactions.
🔶 Create multi-signature transactions.
🔶 Sign multi-signature transactions.
🔶 Encrypt the transactions again.
🔶 Send the result to Six Clovers.
(The associate repository is here)
The first step is to copy the ‘.env_example’ file and rename it as ‘.env’ to work as an environment file. The goal is to fill it with the needed data properly described there. Then, ensure you have installed Python (version 3.9) and pipenv. After that, run the following command:
This will create a new environment to use the script with the needed libraries. To run a file, you have to use:
pipenv run python <script_name>
Where <script_name> could be new_currency, transfer or withdrawal.
Things to consider
- In the case of adding a new currency (for example adding USDC) you have to get some funds in your wallet. In testnet, we used this Algorand faucet. To use it, simply paste there your multi signature address created in Six Clovers and once you click “Dispense”, you will obtain 10 ALGOs.
- In the case of transfer, this means internal, so you will need to have another organization in Six Clovers.
- In the case of withdrawals, you may have to add the address you want to withdraw to “Withdrawal Addresses” (in Six Clovers, inside your organization configuration).
Let´s code it
Currently it is possible to find solutions to this problem developed in Java or another language different from the one we want for our project. In these solutions, a particular Software Development Kit or SDK is used to be able to interact with the Algorand network.
provides this set of tools by using «py-algorand-sdk«, which we import into our project. Prior to this, we must install the package by console by executing:
pip3 install py-algorand-sdk
In our repository you will find three complete examples of how to add a new currency to a wallet, withdraw funds and transfer between two Six Clovers organizations. In the “algorand_sdk.py” file, you will find some functions that use the py-algorand-sdk library. Let’s explain the steps to sign the payloads given by Six Clovers:
The first step is to decode each signature payload. To do this, we will use the function encoding.msgpack decode(payload) from the library:
This step will give us Transaction objects that contain amount, sender, receiver, among other attributes.
We must sign all the transactions that make up these objects. First, we have to create a transaction.Multisig object with three parameters:
- Version of signature: version 1 in this case, for multi-signature.
- Threshold (how many signatures are necessary): 2 in our case, that’s what Six Clovers allows.
- An array of addresses: one of them given by Six Clovers and the others provided by you.
In our case, we created a Multi-Signature (2 out of 3) wallet.
With this object created (we called it msig) and for each decoded payload, we have to create a transaction.MultisigTransaction object. To create the object, it receives as parameters the transaction object (obtained from decoding in the previous step) and the multi-signature object recently created (our msig). In the case of a transfer, you will obtain 2 payloads (one belongs to the transaction and the other for algorand fees). On withdrawals and adding currencies, you will obtain only one payload each. For security reasons, we have to check if the transaction sender is the same address of our msig object.
With the MultisigTransaction object created, you have to sign it with a private key of one of your provided addresses.
We have to encode again the signed object with the encoding.msgpack_encode (multisigTx) function.
Lastly, this will give us new payloads (string type also) signed and ready to commit our transaction to Six Clovers.
Six Clovers represents a reliable solution when it comes to integrating multiple currencies on different platforms. In addition, the facilities provided by Python and its libraries allow us to integrate solutions of this type into our projects with the greatest transparency.
And here we share our development on Python scripts using Six Clovers’ decentralized payments network.
Thanks to the authors:
Thanks for the incredible tech collaboration from Six Clover Team:
We are IEKO
We provide software solutions for Fintech business such as Blockchain, Consulting, Custom Developments, Algorithmic Trading, Digital Onboarding, APIfication and integration of data sources.
Our goal is to build software being responsible with the technological ecosystem in which we exist, contributing to financial inclusion, making a concrete contribution to economic and social development.
From Rosario, Argentina, to the world