Before you go, check out these stories!

0
Hackernoon logoUsing Truffle Boxes on RSK's Network by@RSKsmart

Using Truffle Boxes on RSK's Network

Author profile picture

@RSKsmartRSK

Smart Contract Platform On Top of Bitcoin

RSK is an open source platform for Ethereum compatible smart contracts based on the Bitcoin network. 

Truffle is a popular development framework with a mission to make smart contract development easier for developers. Amongst its features includes: a smart contract lifecycle management, a scriptable deployment & migrations, and automated contract testing and simple network management.

It also makes developing on RSK easier, with the ability to configure custom networks for RSK.

Truffle Boxes are sample applications in the form of project templates. Every Truffle box comes with libraries and tools already preinstalled, code that uses those libraries and tools, external scripts (if necessary), as well as helpful README's and documentation. Also some of them have front-end views, all the way up to complete example dapps. The Truffle boxes are in a single and easily-downloadable package and directly integrated into the Truffle command line.

You can create an empty project template, but for those just getting started, you need only type truffle unbox <box name> to download and prepare your box of choice.

RSK Truffle Boxes

RSK has its own specialized Truffle Boxes:

  • rsk-starter-box
  • rsk-react-box
  • rsk-next-box
  • rsk-react-express-box
  • rsk-token-box

They come with everything you need to start using smart contracts on the RSK Network. 

It includes network configs for:

  • An RSK local node (it is called regtest)
  • Testnet
  • Mainnet

Also Truffle has a Solidity smart contract as an example for deployment.

I will introduce each one of them.

Rsk-starter-box

The rsk-starter-box is a basic RSK box. The focus here is to show the network configurations for a local node (it is called regtest in RSK), Testnet and  Mainnet. 

It also includes a smart contract to store and retrieve a number, the name for the smart contract is called SimpleStorage and it is an example for deployment.

You will know the Truffle development console and how to interact with a smart contract using Truffle.

Compile, Deploy and Tests are included too.

Rsk-plant-box

The rsk-plant-box was inspired by Truffle pet shop box. It comes with everything you need to build a complete dApp - decentralized application on RSK networks. 

It includes network configurations for Mainnet, Testnet and for a local node (it is called regtest in RSK). Deploy instructions and tests are included too.
It also has an user interface to interact with the smart contract using the library web3, it is a real dApp!

Rsk-token-box

The rsk-token-box is a box to create your own token using Open Zeppelin smart contracts library in Truffle framework, connected to an RSK network. 

OpenZeppelin Contracts helps you minimize risk by using battle-tested libraries of smart contracts for Ethereum and other blockchains. It includes the most used implementations of the ERC standard.

The smart contract is a mintable ERC20 token. This means that, in addition to the standard ERC20 specification, it has a function for issuing new tokens.

The token smart contract will have only 7 code lines! 

We are importing the ERC20Mintable from Open Zeppelin. This library itself imports several other libraries such as SafeMath.sol, the standards for this kind of token, and the capability to mint tokens.

Rsk-react-box

rsk-react-box is a box that pairs RSK and Truffle with React in an easy to understand structure, meant for a web-based Blockchain application.
It uses the create-react-app template, which is a good environment for learning React, and is the best way to start building a new single-page application in React.

Create React App doesn’t handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. Under the hood, it uses Babel and webpack, but you don’t need to know anything about them. (source: create-a-new-react-app)

Rsk-next-box

In rsk-next-box you’ll find a basic starter pack which includes Truffle and a front end to interact with the smart contract, built using React app and Next JS.

A Create-React-Next-App is generated in the app directory.

Next.js is a lightweight framework for static and server‑rendered applications built with React. It includes  out of the box styling and routing solutions, and assumes that you’re using Node.js as the server environment. To learn more check it out the create a next.js app in it’s official site.

Rsk-react-express-box

The rsk-react-express-box comes with everything you need to start using express JS to provide API endpoints to smart contracts and a react app to interact with them on RSK Blockchain. 

Express JS is a minimalist web framework for Node.js.This box has a client-server application in the app directory.

Final considerations

In this article you were introduced to RSK Truffle Boxes, which comes with everything you need to start using Truffle on RSK networks.

So, have you chosen an RSK Truffle Box yet?

In the next tutorials you will learn step-by-step how to use some of these RSK Truffle boxes.

Check out RSK Blockchain for more details about us.

Do you have questions? Ask in RSK chat

Author: Solange Gueiros

Reviewer: Owanate Amachree

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.