Python and Java SDKs Development for Celo Blockchain
Celo framework is a mobile-first blockchain platform. Celo blockchain is hosted by the Celo Foundation whose main aim is to make blockchain-based payments worldwide accessible and ease usage of cryptocurrencies.
Blaize team was honored to be a part of Celo grant program and is very grateful for Celo Foundation’s trust in the process of developing Python and Java SDK its native blockchain.
The main task
As the main task to fulfill this development Blaize team established implementation of two SDKs in Python and Java to work with Celo blockchain and set of main smart contracts. This may contribute to the extension of Celo developers community and wider application of blockchain technology.
Blaize establish further subtasks for Celo project development:
- Investigate Celo JS SDKs with smart contracts and Celo blockchain
- Design Python and Java SDKs
- Write all the necessary functionality
- Cover it with tests (project has a 100% unit test coverage)
- Write documentations
We used Python and Java languages with modified Web3py and Web3j libraries for signature creation such as Celo blockchain has additional rows in the transaction body. We used the Web3py library due to its high compatibility with Celo blockchain.
The system needs to be integrated with a variety of contracts at the same time. Abstract factory helps to optimize the work of contracts and ease its usage for users. The user communicates with the KIT to create a contract object, instead of querying each contract directly. This makes the SDK interaction considerably comfortable (convenient)
The architecture of each SDK looks as follows.
We have built the main object which the SDK users will utilize. This base kit allows to set the parameters of the wallet such as cost and amount of gas per transaction, create new keys, or use existing ones and create contract objects.
Wrappers represent a separate class where all the main requests for the contract are already registered. Therefore, the user does not need to re-write requests, he will simply use our class (wrapper), which will greatly speed up and simplify the whole work.
Challenges during SDK development for Celo
After a thorough analysis we discover some unique exceptions in Celo blockchain framework which are not presented on any other platform. It creates some difficulties while configuring it with other applications.
The Eth Account library was chosen as the most suitable for transaction formation. Yet, due to the uniqueness of the transaction body in Celo blockchain, we had to modify the Eth-sign library to create a valid signature for Celo blockchain. We have made wrappers for numerous contracts within the system. For example, this is how the user can interact with the GoldToken or cUSD token.
Another difficulty was to write utils of various kinds. Utils are methods that hash data or help to convert one data type to another and therefore represent one of the main functionality of the whole kit. That is why we needed to spend a great amount of time to study the existing SDK precisely and only then implement our utils in the Python SDK.
As a result, we get two finest SDKs on Python and Java programming languages interacting with Celo smart contracts. You can see the whole project documentation for Python and Java available on Blaize public Github. Build your easily operated SDK toolkit with Blaize!