Ethereum and Bitcoin Rest API: Wrap and Ooo approaches
The Ethereum platform was a pioneer in the development of decentralized applications (DAPPS) and smart contracts. One of the key components that enables this application is access to external data sources, such as blockchain like bitcoin. However, the approach to Bitcoin Blockchain can be challenging software because of its nature based on permission and strict access control.
Bitcoin Rest API
Bitcoin network uses API Rest (representative state of resources) to interact with blockchain. This API provides endpoints for different operations, including retrievement data on transactions, blocks of blocks and network statistics. However, the implementation of this API from scratch can be complex, especially when it comes to safety and scalability issues.
Existing C
Wrap
Several developers have created C
wrap for Bitcoin Rest API, but these solutions are often lacking strong (object -oriented) approach. This means that they may not be as modular or sustainable as it can be expected from a dedicated library. Some notable examples include:
* Bitcoin-Wrapper.net
: .net wrap for Bitcoin Rest API that provides basic CRUD operations and some additional features, such as handling and data serialization.
* BTC-Rpc.net
: a C
wrap for bitcointalk Rpc (remote procedure of calling) API, which is the predecessor Bitcoin Rest API. Although it is not directly related to Rest API, it provides access to Bitcoin Blockchain.
Existing ooo approaches
However, there are also OOO approaches Bitcoin Rest API that can be easier to implement using C
and others .net technologies:
* Ethereum-go : Open Code Framework for the construction of Ethereum apps at the top of GO programming languages. Provides a set of libraries and interaction tools with Bitcoin blockchain, including the Rest API wrap.
* Bitcoinsharp : Lightweight Library C
for interaction with Bitcoin network. Although not specially designed as an OOO approach, it provides access to different end points and data structures.
Example uses the case
To illustrate the complexity of the implementation of bitcoin rest API from zero or the use of existing wrappers, consider a simple example:
Suppose we want to create a C
app showing information about a particular Bitcoin transaction. We could use the OOO approach by creating a custom -type “blockchainthaintractionthat incapsulates relevant data and methods for interaction with blockchain.
CSHARP
Blockchaintransation of public class
{
public down hash {Get; set; Iche
public decimal value {Get; set; Iche
Iche
public class EthereumApp
{
Private Readonly Irestclient _restClient;
Public EthereumApp (Irestclient Restclient)
{
_restclient = restclient;
Iche
Public Void Gettransacthioninfo (String Transactionhash)
{
// Send a request to Bitcoin Rest API for transaction information
VAR Response = _restclient.get (“tx/” + transactionhash);
IF (Answer.issuccessStatuscode)
{
var data = jsonConvert.lializeozeobct
Console.writeline ($ “transaction hash: {data.transationhash}, value: {Data.
Leave a Reply