Set up a sidechain for the XRPL quickly and easily

Overview

Sidechain Launch Kit

Introduction

This directory contains python scripts to tests and explore side chains.

This document walks through the steps to setup a side chain running on your local machine and make your first cross chain transfers.

Get Ready

This section describes how to install the python dependencies, create the environment variables, and create the configuration files that scripts need to run correctly.

Build rippled

Checkout the sidechain branch from the rippled repository, and follow the usual process to build rippled.

Set up Python environment

To make it easy to manage your Python environment with xrpl-py, including switching between versions, install pyenv and follow these steps:

  • Install pyenv:

      brew install pyenv
    

    For other installation options, see the pyenv README.

  • Use pyenv to install the optimized version for xrpl-py (currently 3.9.1):

      pyenv install 3.9.1
    
  • Set the global version of Python with pyenv:

      pyenv global 3.9.1
    

Set up shell environment

To enable autocompletion and other functionality from your shell, add pyenv to your environment.

These steps assume that you're using a Zsh shell. For other shells, see the pyenv README.

  • Add pyenv init to your Zsh shell:

    > ~/.zshrc ">
      echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc
    
  • Source or restart your terminal:

      . ~/.zshrc
    

Manage dependencies and virtual environments

To simplify managing library dependencies and the virtual environment, xrpl-py uses poetry.

  • Install poetry:

      curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
      poetry install
    

Environment variables

The python scripts need to know the locations of two files and one directory. These can be specified either through command line arguments or by setting environment variables.

  1. The location of the rippled executable used for main chain servers. Either set the environment variable RIPPLED_MAINCHAIN_EXE or use the command line switch --exe_mainchain. Until a new RPC is integrated into the main branch (this will happen very soon), use the code built from the sidechain branch as the main chain exe.
  2. The location of the rippled executable used for side chain servers. Either set the environment variable RIPPLED_SIDECHAIN_EXE or use the command line switch --exe_sidechain. This should be the rippled executable built from the sidechain branch.
  3. The location of the directory that has the rippled configuration files. Either set the environment variable RIPPLED_SIDECHAIN_CFG_DIR or use the command line switch --cfgs_dir. The configuration files do not exist yet. There is a script to create these for you. For now, just choose a location where the files should live and make sure that directory exists.

Setting environment variables can be very convient. For example, a small script can be sourced to set these environment variables when working with side chains.

Creating configuration files

Assuming rippled is built, the three environment variables are set, and the python environment is activated, run the following script:

bin/sidechain/python/create_config_files.py --usd

There should now be many configuration files in the directory specified by the RIPPLED_SIDECHAIN_CFG_DIR environment variable. The --usd creates a sample cross chain assert for USD -> USD transfers.

Running the interactive shell

There is an interactive shell called RiplRepl that can be used to explore side chains. It will use the configuration files built above to spin up test rippled main chain running in standalone mode as well as 5 side chain federators running in regular consensus mode.

To start the shell, run the following script:

bin/sidechain/python/riplrepl.py

The shell will not start until the servers have synced. It may take a minute or two until they do sync. The script should give feedback while it is syncing.

Once the shell has started, the following message should appear:

Welcome to the sidechain test shell.   Type help or ? to list commands.

RiplRepl> 

Type the command server_info to make sure the servers are running. An example output would be:

RiplRepl> server_info
           pid                                  config  running server_state  ledger_seq complete_ledgers
main 0  136206  main.no_shards.mainchain_0/rippled.cfg     True    proposing          75             2-75
side 0  136230                 sidechain_0/rippled.cfg     True    proposing          92             1-92
     1  136231                 sidechain_1/rippled.cfg     True    proposing          92             1-92
     2  136232                 sidechain_2/rippled.cfg     True    proposing          92             1-92
     3  136233                 sidechain_3/rippled.cfg     True    proposing          92             1-92
     4  136234                 sidechain_4/rippled.cfg     True    proposing          92             1-92

Of course, you'll see slightly different output on your machine. The important thing to notice is there are two categories, one called main for the main chain and one called side for the side chain. There should be a single server for the main chain and five servers for the side chain.

Next, type the balance command, to see the balances of the accounts in the address book:

RiplRepl> balance
                           balance currency peer limit
     account                                          
main root    99,999,989,999.999985      XRP           
     door             9,999.999940      XRP           
side door    99,999,999,999.999954      XRP           

There are two accounts on the main chain: root and door; and one account on the side chain: door. These are not user accounts. Let's add two user accounts, one on the main chain called alice and one on the side chain called bob. The new_account command does this for us.

RiplRepl> new_account mainchain alice
RiplRepl> new_account sidechain bob

This just added the accounts to the address book, but they don't exist on the ledger yet. To do that, we need to fund the accounts with a payment. For now, let's just fund the alice account and check the balances. The pay command makes a payment on one of the chains:

RiplRepl> pay mainchain root alice 5000
RiplRepl> balance
                           balance currency peer limit
     account                                          
main root    99,999,984,999.999969      XRP           
     door             9,999.999940      XRP           
     alice            5,000.000000      XRP           
side door    99,999,999,999.999954      XRP           
     bob                  0.000000      XRP      

Finally, let's do something specific to side chains: make a cross chain payment. The xchain command makes a payment between chains:

RiplRepl> xchain mainchain alice bob 4000
RiplRepl> balance
                           balance currency peer limit
     account                                          
main root    99,999,984,999.999969      XRP           
     door            13,999.999940      XRP           
     alice              999.999990      XRP           
side door    99,999,995,999.999863      XRP           
     bob              4,000.000000      XRP           

Note: the account reserve on the side chain is 100 XRP. The cross chain amount must be greater than 100 XRP or the payment will fail.

Making a cross chain transaction from the side chain to the main chain is similar:

RiplRepl> xchain sidechain bob alice 2000
RiplRepl> balance
                           balance currency peer limit
     account                                          
main root    99,999,984,999.999969      XRP           
     door            11,999.999840      XRP           
     alice            2,999.999990      XRP           
side door    99,999,997,999.999863      XRP           
     bob              1,999.999990      XRP    

If you typed balance very quickly, you may catch a cross chain payment in progress and the XRP may be deducted from bob's account before it is added to alice's. If this happens just wait a couple seconds and retry the command. Also note that accounts pay a ten drop fee when submitting transactions.

Finally, exit the program with the quit command:

RiplRepl> quit
Thank you for using RiplRepl. Goodbye.


WARNING: Server 0 is being stopped. RPC commands cannot be sent until this is restarted.

Ignore the warning about the server being stopped.

Conclusion

Those two cross chain payments are a "hello world" for side chains. It makes sure you're environment is set up correctly.

Owner
Xpring Engineering
Xpring (pronounced "spring") is Ripple's ecosystem initiative to help build the Internet of Value. (We're hiring!)
Xpring Engineering
Open source stenotype engine

Plover Bringing stenography to everyone. Homepage Releases Wiki Blog Google Group Discord Chat About Installation Getting help Contributing Donations

Open Steno Project 2k Jan 09, 2023
【教程】莉沫酱教你学继承!?

【教程】莉沫酱教你学继承! 众所周知,类的继承就是说当一个类死亡的时候,它的子类会获得它拥有的资源。 根据类的继承法不同,各个子类能获得的资源也不同。 继承法的类型 在解释继承法之前,我们先定义三个类,一个父类A,和它的子类B、C。 它们都拥有x、y、z三个属性。

黄巍 17 Dec 05, 2022
An open-source Python project series where beginners can contribute and practice coding.

Python Mini Projects A collection of easy Python small projects to help you improve your programming skills. Table Of Contents Aim Of The Project Cont

Leah Nguyen 491 Jan 04, 2023
The bidirectional mapping library for Python.

bidict The bidirectional mapping library for Python. Status bidict: has been used for many years by several teams at Google, Venmo, CERN, Bank of Amer

Joshua Bronson 1.2k Dec 31, 2022
RISE allows you to instantly turn your Jupyter Notebooks into a slideshow

RISE RISE allows you to instantly turn your Jupyter Notebooks into a slideshow. No out-of-band conversion is needed, switch from jupyter notebook to a

Damian Avila 3.4k Jan 04, 2023
A platform for developers 👩‍💻 who wants to share their programs and projects.

Fest-Practice-2021 This project is excluded from Hacktoberfest 2021. Please use this as a testing repo/project. A platform for developers 👩‍💻 who wa

Mayank Choudhary 40 Nov 07, 2022
GitHub Actions Version Updater Updates All GitHub Action Versions in a Repository and Creates a Pull Request with the Changes.

GitHub Actions Version Updater GitHub Actions Version Updater is GitHub Action that is used to update other GitHub Actions in a Repository and create

Maksudul Haque 42 Dec 22, 2022
Petuhlang is a joke-like language, based on Python.

Petuhlang is a joke-like language, based on Python. It updates builtins to make a new syntax based on operators rewrite.

DenyS 9 Jun 19, 2022
DOP-Tuning(Domain-Oriented Prefix-tuning model)

DOP-Tuning DOP-Tuning(Domain-Oriented Prefix-tuning model)代码基于Prefix-Tuning改进. Files ├── seq2seq # Code for encoder-decoder arch

Andrew Zeng 5 Nov 02, 2022
PIP Manager written in python Tkinter

PIP Manager About PIP Manager is designed to make Python Package handling easier by just a click of a button!! Available Features Installing packages

Will Payne 9 Dec 09, 2022
Repositorio com arquivos processados da CPI da COVID para facilitar analise

cpi4all Repositorio com arquivos processados da CPI da COVID para facilitar analise Organização No site do senado é possivel encontrar a lista de todo

Breno Rodrigues Guimarães 12 Aug 16, 2021
Automatically find solutions when your Python code encounters an issue.

What The Python?! Helping you find answers to the errors Python spits out. Installation You can find the source code on GitHub at: https://github.com/

What The Python?! 139 Dec 14, 2022
适用于HoshinoBot下的人生重来模拟器插件

LifeRestart for HoshinoBot 原作地址 python版原地址 本项目地址 安装方法 这是一个HoshinoBot的人生重来模拟器插件 这个项目使用的HoshinoBot的消息触发器,如果你了解其他机器人框架的api(比如nonebot)可以只修改消息触发器就将本项目移植到其他

黛笙笙 16 Sep 03, 2022
Python script for changing the SSH banner content with other content

Banner-changer-py Python script for changing the SSH banner content with other content. The Script will take the content of a specified file range and

2 Nov 23, 2021
A python server markup language

PSML - Python server markup language How to install: python install.py

LMFS 6 May 18, 2022
RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.

RDFLib RDFLib is a pure Python package for working with RDF. RDFLib contains most things you need to work with RDF, including: parsers and serializers

RDFLib 1.8k Jan 02, 2023
Stori QA Automation Challenge

Stori-QA-Automation-Challenge This is the repository is created for the Stori QA Intern Automation Engineer Challenge! In this you can find the Requir

Daniel Castañeda 0 Feb 20, 2022
Validate UC alumni identifier numbers with Python 3.

UC number validator Validate UC alumni identifier numbers with Python 3. Getting started Install the library with: pip install -U ucnumber Usage from

Open Source eUC 1 Jul 07, 2021
Your E-Canteen that is convenient and accessible wherever you are in the campus

Food Web E-Canteen System Your E-Canteen that is convenient and accessible wherever you are in the campus. Table of Contents About The Project Contrib

Pudding 5 Jan 07, 2023
With Christmas and New Year ahead, it is time for some festive coding. Here is a Christmas Card for you all!

Christmas Card With Christmas and New Year ahead, it is time for some festive coding! Here is a Christmas Card for you all! NOTE: I have not made this

CodeMaster7000 1 Dec 25, 2021