How to Integrate VIP-191 (III) — Sponsor’s Side

This is the last part of the tutorial.

It mainly explains the sponsor’s initiative to inspect the transaction and sign his signature on it. We will use the express.js library to build a framework to receive transmission and return the result.

Before that, I have a hefty wallet on test-net to be a sponsor:

Sponsor’s address: 0x126cdb344f476f25b9fb2050513f425a82f71046

Private key: 5df5e7f22a71dfd3d032ff5eb9dfc7dbe9c950e0671745826639a0423cd45d7f

Balance: [LINK] ← Contains >4000 VTHO to be spent.

The above code is quite simple, with some details to pay attention to:

  • The server is listening on localhost:3000.
  • The tx is re-constructed from the request, it’s a good time inspecting it.
  • The sponsor is using his own private key to sign.
  • The sponsor_signature is returned to the user.

Finally, on the user’s side, it can assemble the final compound signature and post the transaction to the VeChain network!

Let’s continue where we left off from the 2nd tutorial:

The process is quite straightforward, concatenate of user’s signature originSignature and the sponsor’s signature sponsorSignature . Then finally call the POST method to send to our VeChain test-net.

As of writing, I have successfully posted several transactions and all show details of VIP-191 fee delegation feature, for example, the transaction with below ID:

Tx: 0xd8b94a68764f6f49eb33bb7a6e895e0f2565c8c8e1731f1258b188561b581e87 [Web Link]

Example of VIP-191 Result

As we can see from the above picture, the 26.64 VTHO is paid not by the user, but by the sponsor. Hence, the fee delegation is complete.

Conclusion

Due to the length of the article, this VIP-191 tutorial doesn’t show the full source code from the user’s side and the sponsor’s side. I have included a workable sample of user.js and sponsor.js on the Github for you to run.

I hope you like this trilogy of tutorials on VIP-191 of VeChain. As always, may the force be with you!

Continue Reading:

--

--

Passion in computer science.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store