Papercrypto: Tips & Tricks

If you are here and are considering using this brilliant tool to make your life easier and beautiful, you may want to know some tips & tricks to save time and preserve your vital energy. Thinking about it, I decided to write a little about my experiences developing with the Zabo API.
The application in question is an amazing and free paper game we developed some time ago. I would recommend you look at https://papercrypto.io and connect your crypto accounts to witness this feat of modern science and engineering.

Here is your guide on this little article:

Get a fresh coffee and RTFM

To get started: Read The Fucking Formidable Manual! This is definitely something to consider. There is a lot in between those lines, even for a crypto-elderly. We, Papercrypto developers, are also flesh and blood people. We have fam, cats, and dogs. And we need to confess that we don’t always read the docs. However, if I can give you sound advice to save a lifetime, it would be, drink water and spend some time even for a quick read. The sections below will be more readily understood if you check the Zabo website and docs.

Know the sides of the Zabo

Sandbox vs Live

The Zabo API has two environments: sandbox and live. This is very important information. When you first create your Zabo account, you will find a sandbox team and can access the keys you will need to integrate your application. On Papercrypto (PC), we use the sandbox team on our local environments, development servers, and testing. The sandbox API provides the exact same data format you can get in the live environment, BUT saving you some user connections (which means money), since the returned data isn’t necessarily real and up to date.

Even so, don’t be afraid of applying to the live environment! As soon as you are ready to test some real data, go to Zabo’s dashboard, and apply for a live team. A credit card is not required, and you will have a generous tier to have fun. From here, make sure you are handling the keys separately. Sandbox keys are different from Live keys.

In short:

  • Sandbox: Free access, same format, dummy responses, good for testing and for your pocket
  • Live: Real world, free tier up to 100 live connections and, after that, start thinking about $.

Client vs Server

Be aware of the different “sides”, either your app or Zabo is another really important point. Mainly due to security, a considerable chunk of the API is available only server-side. On PC, we have a client application (React) and a server application (Node.js), both instantiating the Zabo JS SDK independently. 99% of the data we return to the end-user comes from Zabo server-side SDK, leaving the Zabo client-side SDK responsible for, basically, connecting the user.

Another piece of good advice: Even being a single piece, there is a slight difference in instantiating the SDK client and server. When calling Zabo.init({ ... }) from a front-end application, the required params are: clientId and env. When initiating the back-end, the required params are: apiKey, secretKey and env. All of this can be obtained in the Developer Settings.

Singleton yourself

After reading the docs (I believe you did) and understood the basics, you should start coding a little bit. I don’t think you will find barriers to use the SDK, but some times, abstracting the methods to something you can easily understand could help a lot. On PC, we create our own utils on both sides: client and server. Both React and Node.js have their own Zabo files exposing the methods we use the most via a pre-instantiated singleton class. Then, when you import the package, your application won’t mess things up, it is always accessing the same instance and calling only the exposed methods.

init once, connect forever

At this point, you are frenetically writing a tasty spaghetti of code, calling all the methods you just discovered like a beautiful monolith. No problems! We also like “solid” code. But, when going to production, make sure you are properly calling the main methods. I highly recommend you make a proper distinction on calling initand connect. On PC, we are calling the Zabo.init method (to initialize the SDK) right after the application starts, either front or back-end. This will save some time and make things look faster. Once initiated, you don’t have to worry anymore. From now on, on the front-end side, you just have to worry about the zabo.connect method, basically. Calling it as much as you want and only taking care of the responses: onConnection and onError.

Keeping the User Aware

Latency is always a pain, and we definitely don’t want to let the end-user wait for too long when initing, connecting, or getting some data. This is more like a UX advice: always ensure the user has as much information as you can offer at that time. This can mean some data you can pre-populate during the loading or, if something is happening in the background, let them know by showing a hypnotic loader or providing a gentle massage message. PC does this by introducing some loaders or presenting some cache data, what is another good point, btw.

This is Cache, our best friend

Sometimes, we talk about hundreds or even thousands of balances, transactions, and different rates when working with crypto. We are also dealing with the blockchain and the magic behind Satoshi’s kingdom. Zabo will take care of most of the work here (which is great!), but no one can compete with hundreds of users with nervous fingers pressing an exhausted F5. If you know this guy or IS this guy, thank you! You make our nights shorter and more fun, and it’s for you all those full databases, parallel processing, and unstoppable cron jobs. For you, developer, I would suggest taking part of this pain and try to save some API requests. Btw, this also means money.

The support guys are super cool

There is nothing in the whole world better than finding a Stack Overflow answer. I would bet I can code almost anything by searching and copying from Stack Overflow. Unfortunately, not all questions in the world have been answered. Sad! Fortunately, we have the community to help us with finding the answers. It would be impossible to integrate PC without directly chatting with the Zabo gang. If there is only one thing that you must do after reading this, joining the Zabo chat. You will find some good support there to keep your heart warmy.

1 Like

Great read! Thanks for doing this Davi :smiley:

1 Like