or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Beginner's Guide to Getting Started with RSK Blockchain Node
How to get started on RSKj for your dApp project
RSK is a secured smart contract platform, thanks to merged mining with the Bitcoin network, merged mining allows Bitcoin miners to mine RSK’s sidechain using the same work for both. This is the basis for RSK’s extremely high hash rate, which is approximately 63% of the Bitcoin network’s hashrate currently; and therefore the reason that RSK is the most secure smart contract platform.
RSKj is the software used to run nodes on the RSK network. You can find it on Github: rsksmart/rskj.
Interact with the RSK network
You can interact with the RSK network in various ways without running your own node.
Connect to RSKj
You can run RSKj locally to connect to the public RSK networks -
Furthermore, you can run RSKj in a localhost-only environment, without connecting to any public network using the RSK Regtest
Interacting with a dApp
To interact with a dApp, you can use a Web3 enabled wallet software, for wallets that support RBTC and RIF tokens.
Configure MetaMask to connect to RSK
To configure Metamask to connect to RSK, see the step by step guide demonstrating how to interact with a DApp on RSK using Remix and MetaMask. Both Remix and MetaMask are tools that were originally built for Ethereum, and thanks to RSK's comaptibility (both in its Virtual Machine executing smart contracts, and in its communications protocol using JSON-RPC), these tools work on RSK too!
We'll use them to create and deploy a simple smart contract on RSK’s Testnet.
Check the status of the RSK network
To check the status of the RSK Network in real-time, use:
You can also check the status of a particular transaction and deployed smart contracts, using:
See the RIF Smart Contract address and this address:
0xc218fc2b765ab321a907d6125fe7763e2eaec8e16dd4a72e1a4829a9baa2451a
is a transaction hash. You will notice that this type of transaction is perfmormed by neither an externally owned account or a smart contract. In fact it is a REMASC transaction.From: [REMASC architecture] (https://developers.rsk.co/rsk/architecture/mining/remasc/)
This type of transaction is found in neither Bitcoin nor Ethereum, but is a key component of how the RSK network is able to achieve block times that are frequent enough to enable smart contract based decentralised applications, and while being merge-mined with Bitcoin. See fast payments for further details.
Send JSON-RPC requests
To send JSON-RPC requests, see list of JSON-RPC Methods that RSK currently supports.
Obtain test tokens
You can use the faucet to get test tokens (tRBTC) for use in RSK test network.
Getting Started
If none of the above fits the bill for you, you will need to run your own RSK node.
Especially if you are developing smart contracts, developing DApps, or participating in a hackathon, you are likely to want to iterate fast, and therefore need quicker feedback loops.
Running RSKj in Regtest mode is the best fit for these needs.
System Requirements
The following are the minimum requirements needed to install an RSKj node.
Install Java
The RSKj executable is a Java Archive file (JAR file), and requires Java to run. See guide on how to install the Java 8 JDK.
Download RSKj JAR
Navigate to RSKj's releases page.
From the latest release, download a file whose name looks like
rskj-core-*.jar
, where*
is replaced by the release tag name, for example2.2.0-PAPYRUS
.Run RSKj
To run RSKj, copy the following commands below, and paste in terminal where
rskj-core-*.jar
is located.The above command runs RSKj connected to Regtest, which is a
localhost
-only network, clears the database each time the node is started, and enables both CORS. These are the most useful and commonly used flags and options for when you are developing or testing smart contracts and DApps.If you see no output - that is a good thing: Its output is directed to a log file.
Developer Tools
Truffle
Here is how you would configure Truffle to connect to the RSK Testnet.
See below code for how to implement this in a Truffle project.
In your
truffle-config.js
file:(1) Set a variable
testnetSeedPhrase
to contain a valid BIP-39 mnemonic phrase(2) Set a variable
gasPriceTestnet
to contain the gas price you wish to use denominated in Wei.(3) In the exported
config
object, set the value ofconfig.networks.testnet
to be the following.This enables you to understand Truffle’s default configuration values (based on Ethereum), in particular surrounding polling intervals. Using these two relatively new configuration options allows you to configure Truffle to better connect to an RSK node.
For more details, see Configuring Truffle to RSK.
Debugging
Need to debug transactions in RSK?
See an example of how to debug transactions in an RSK Network on Stackoverflow
If your contract emits messages in the reversions, then you can find them out by using
debug_traceTransaction
.Note that the debug RPC module is enabled by default in RSK config, but this is disabled on public nodes.
Furthermore, the RSK public nodes do not expose this feature, and you must run your own node in order to do so.
The following assumes that you have a local node running with RPC exposed on port
4444
.First, you need to enable
debug
module in your config file:Then, you can execute the RPC method passing the transaction ID as a parameter, like in this example:
You will get the following response (truncated for brevity):
Finally, convert
result
from hexadecimal to ASCII, to obtain a readable message:RPC
Remote Procedure Calls (JSON-RPC) are the primary interface through which RSK nodes communicate over the network. RSK's JSON-RPC has a high level of compatibility with Ethereum's JSON-RPC.
JSON-RPC is available over two network transport protocols: HTTP and WebSockets
Wrap up
In this article, we interacted and connected with the different public RSK Networks, Configured Metamask to connect to RSK, Downloaded and ran an RSK Node in
regtest
network.Thanks for reading!
Kudos
Thanks to Brendan Graetz and Diego Masini for their help in reviewing this guide!