Our user's story. We know that running a node can be a headache, so we help dev teams to better focus on new features and dApps — and we’ll do the rest.
I have a dream — it’s called DOGE
I am a PHP developer, and today I’m going to tell you about the steps and the issues I faced while creating the Dogecoin Crypto Wallet (hereinafter DOGE). Technically, it is necessary to develop a website where users can create wallets for themselves, receive, store, and send DOGE.
The simplest and most relevant solution, as it seems, is to buy a dedicated server, run Dogecoin nodes (node) on it, and connect to it locally via RPC. But this option initially did not work out for 2 reasons.
Firstly, due to the cost of the server, a server with the necessary parameters costs about $50 per month. This project was not originally intended to be commercial. It was designed to be free for users, so the cost of its maintenance should be minimal.
Secondly, node support requires a qualified specialist in this field, and this is also an additional cost. We tried using our own resources to raise the Dogecoin node, but it was extremely unstable — it often hung up or appeared out of sync with the main network, and this, of course, frustrated us.
How to make things with a remote node
To work with a foreign node there are three questions have to be answered:
1) How to create addresses and where to store keys?
2) How to receive new transactions?
3) How to generate new transactions?
The first question was not so simple. After reading tons of articles and checking megabytes of codes (not only in PHP), a set of libraries was compiled that made it possible to generate a key pair and an address.
The second question was the simplest. To find out which transaction is confirmed, you need to look at the new blocks. How to receive new blocks? Using the “slowness” of the blockchain, you can interrogate a node with some periodicity (even once a minute). And if a new block appears, request its contents from the node. Even if the transaction is received 2 minutes later, no one will complain, and given the need for several confirmations, this will be generally imperceptible.
The solution to the third question required a huge amount of time and effort. There was no ready-made solution. Transaction formation is described many times, but without examples. And those examples that existed- contained only the simplest options. It’s good that Dogecoin is built on the principle of Bitcoin. Most of the information was obtained from there, as it turned out, the formation of an optimal transaction is a complex process. To get a low commission, the transaction length should be as short as possible, so, we need an algorithm that selects from a dozen outputs those that will give the minimum “change”, and this change cannot be less than dust! Debugging and testing this algorithm took several months.
A short research on the available options
Now back to the issue of connecting to the blockchain.
The first implementation option is node rental. The search returned several options, but all of them are either non-Dogecoin or costing several hundred dollars a month.
The second option is to connect via the API block explorer. A search on the “Dogecoin blockexplorer API” returned the following options:
Blockchair: is a powerful resource. Cons — the difficulty of getting an API key for free and the high cost of a paid one.
Doge.tokenview.com: 500 Internal Server Error
Cryptoapis.io: Limit of 500 calls per day
Live.blockcypher.com/doge — a great resource! Original transaction signing technique. Cons: limits on the number of API calls per minute, node desync (transactions sent through them are not visible to other nodes). The initial study we did here.
Dogeblocks: Insight was originally here with its API — a great free resource! We used it for a long time. But then it “died” and did not work for several months. And now there is a Blockbook that can’t give UTXO to several addresses at once.
Dogechain.info: — also a resource from Block.io, Inc. Free, but limited API: there is no “get block transactions” and there is no “get UTXO at multiple addresses”. For a while, it was the only resource on the network through which we could “communicate” with Dogecoin. To get the block transactions, I even had to parse the HTML page.
Everything was unstable, and so, once, one of the users advised the resource NOWNodes. This resource provides rental nodes. Most of them have the Blackbook API installed. We contacted representatives and were given a key. Since then we have been working with them.
To put it shortly: in order to create a DOGE web wallet, the following APIs are minimally required:
1) Get the last (maximum) block number in the network
2) Get the content/data (not only txid) of all transactions of the block
3) Get a balance of one address and several addresses (not available in Blockbook)
4) Get a UTXO list of one address and several addresses (not available in Blockbook)
5) Send the generated and signed transaction to the network
P.S. As it turned out, just sending a transaction to the network is not enough! Even if the node returned a positive response (no error), this does NOT mean that the transaction has entered mempool. Some time after sending it is necessary to check “does the transaction exist?” Sometimes it just disappears! We still do not understand the reason behind this.
NOWNodes — Explorer & Node APIs.
Visit our website and get access to your node within 1 day.
Find the best Blockchain nodes and API providers on CoinCodeCap.
A step by step guide to creating Dogecoin wallet with NOWNodes was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.