This is a fork of the rippled codebase incorporating the work-in-progress "Hooks" amendment. This amendment will allow web assembly smart contracts to run directly on the XRP ledger when completed and adopted.
Building rippled
can be non-trivial, especially in this case since modified libraries are used. We have provided a testnet docker container for your convenience. This container contains an instance of rippled
configured as a "Hooks stock node" running on the Public Testnet. You can interact with it using the steps below:
If you already have the docker image and need to update then use this instruction to pull and run the new version
docker rmi -f xrpllabsofficial/xrpld-hooks-testnet
- Download and install docker: https://docs.docker.com/get-docker/
- Then to run the container interactively use:
docker run -d --name xrpld-hooks xrpllabsofficial/xrpld-hooks-testnet
docker exec -it xrpld-hooks bash
- Set up a second terminal to view the log:
Open a new terminal window on your system and run.
docker exec -it xrpld-hooks tail -f log
This will show you the trace log of xrpld as it runs, which will be important for knowing if your transactions fail or succeed and what actions the hooks take.
Since there is rather a lot of log output you might find it useful to run this with grep -a <your account>
after you obtain an account you are interested in.
E.g. docker exec -it xrpld-hooks tail -f log | grep -a rEy6oGFEeKNiMUTTEzTDnMVfe7SvcBsHZK
Alternatively, if you just want the Hooks Testnet debug log output, you can skip running the docker container at all, and setup a WebSocket conection to the live Hooks Testnet debug stream:
wss://hooks-testnet-debugstream.xrpl-labs.com/{some-r-address}
- If you need to kill and destroy the container and restart it (if you are still attached to the container, type
exit
there to quit the container terminal):
docker rm -f xrpld-hooks
Then repeat step 2. If you need to fetch a newly published image, check the Update an existing container
step above.
After following the above steps you will be inside a shell inside the container. Rippled will already be running with the correct settings. Read the README.md in the container for further instructions on installing and interacting with the example hooks.
- A
rippled
instance connected to the Hooks Public Testnet. - A compiler toolchain for building hooks (wasmcc, wasm2wat, etc...)
- Example hooks and support scripts to install them on your account.
The Faucet is on the main page. Make a note of your secret (family seed) because you will need it for all the examples.
Use the Testnet Explorer to view transactions, accounts and hook state objects as you go.
- The example hooks are written in C. Any file ending in
.c
is a hook. Any file ending in.h
is a header file used by all hooks. - Hooks compile to
.wasm
files. These are hook binaries ready to be installed onto an account on the ledger using theSetHook
transaction. - Javascript files
.js
are runnable with nodejs and provide a way to installing hooks and interacting with the ledger through ripple-lib.
To build you can run make
from any hook's directory. The example makefile
in each directory shows you how to build a hook.
To interact with the example hooks change (cd
) into one of these directories:
- liteacc
- firewall
- carbon
- accept
- notary
- peggy
All example hooks are installed by running node <hook name>.js
. The usage information will be provided at the commandline.
You can check a reported SetHook
transaction ID with the Hooks Testnet Explorer.
Finally run the additional .js
files to interact with the Hook or write your own interaction.
- Documentation for the Hook API can be found at the Hooks Testnet Site.
- For further details check:
hook-api-examples/hookapi.h
src/ripple/app/tx/applyHook.h
src/ripple/app/tx/impl/applyHook.cpp
You can view the current Hook State for your Hook by locating the account it is installed on with the Hooks Testnet Explorer.
You can also run ./rippled account_objects <account on which the hook is installed on>
to inspect the Hook's State Data.
Please have a look at the accept hook in ./accept/
Output is written to a file in the current working directory called log
.
Rippled produces a large amount of output in trace
mode (which is the default mode used in this example). You may
find that you need to scroll back considerably after running a hook or interacting with a hook to find out what
precisely happened.
Greping for the relevant account will help, as all Hooks prepend the otxn account and hook account to the trace line.
Set a Hook on an activated account using a SetHook Transaction (ttHOOK_SET = 22). This must contain the following fields:
- sfAccount
- sfCreateCode: Containing the binary of the web assembly
- sfHookOn: An unsigned 64bit integer (explained bellow)
Each bit in this unsigned int64 indicates whether the Hook should execute on a particular transaction type. All bits are active low except bit 22 which is active high. Since 22 is ttHOOK_SET this means the default value of all 0's will not fire on a SetHook transaction but will fire on every other transaction type. This is a deliberate design choice to help people avoid bricking their XRPL account with a misbehaving hook.
Bits are numbered from right to left from 0 to 63).
Examples:
- If we want to completely disable the hook:
~(1ULL << 22) /* every bit is 1 except bit 22 which is 0 */
- If we want to disable the hook on everything except ttPAYMENT:
~(1ULL << 22) & ~(1ULL)
- If we want to enable the hook on everything except ttHOOK_SET
0
- If we want to enable hook firing on ttHOOK_SET (dangerous) and every other transaction type:
(1ULL << 22)
The XRP Ledger is a decentralized cryptographic ledger powered by a network of peer-to-peer servers. The XRP Ledger uses a novel Byzantine Fault Tolerant consensus algorithm to settle and record transactions in a secure distributed database without a central operator.
XRP is a public, counterparty-free asset native to the XRP Ledger, and is designed to bridge the many different currencies in use worldwide. XRP is traded on the open-market and is available for anyone to access. The XRP Ledger was created in 2012 with a finite supply of 100 billion units of XRP. Its creators gifted 80 billion XRP to a company, now called Ripple, to develop the XRP Ledger and its ecosystem. Ripple uses XRP to help build the Internet of Value, ushering in a world in which money moves as fast and efficiently as information does today.
The server software that powers the XRP Ledger is called rippled
and is available in this repository under the permissive ISC open-source license. The rippled
server is written primarily in C++ and runs on a variety of platforms.
- Censorship-Resistant Transaction Processing: No single party decides which transactions succeed or fail, and no one can "roll back" a transaction after it completes. As long as those who choose to participate in the network keep it healthy, they can settle transactions in seconds.
- Fast, Efficient Consensus Algorithm: The XRP Ledger's consensus algorithm settles transactions in 4 to 5 seconds, processing at a throughput of up to 1500 transactions per second. These properties put XRP at least an order of magnitude ahead of other top digital assets.
- Finite XRP Supply: When the XRP Ledger began, 100 billion XRP were created, and no more XRP will ever be created. The available supply of XRP decreases slowly over time as small amounts are destroyed to pay transaction costs.
- Responsible Software Governance: A team of full-time, world-class developers at Ripple maintain and continually improve the XRP Ledger's underlying software with contributions from the open-source community. Ripple acts as a steward for the technology and an advocate for its interests, and builds constructive relationships with governments and financial institutions worldwide.
- Secure, Adaptable Cryptography: The XRP Ledger relies on industry standard digital signature systems like ECDSA (the same scheme used by Bitcoin) but also supports modern, efficient algorithms like Ed25519. The extensible nature of the XRP Ledger's software makes it possible to add and disable algorithms as the state of the art in cryptography advances.
- Modern Features for Smart Contracts: Features like Escrow, Checks, and Payment Channels support cutting-edge financial applications including the Interledger Protocol. This toolbox of advanced features comes with safety features like a process for amending the network and separate checks against invariant constraints.
- On-Ledger Decentralized Exchange: In addition to all the features that make XRP useful on its own, the XRP Ledger also has a fully-functional accounting system for tracking and trading obligations denominated in any way users want, and an exchange built into the protocol. The XRP Ledger can settle long, cross-currency payment paths and exchanges of multiple currencies in atomic transactions, bridging gaps of trust with XRP.
Folder | Contents |
---|---|
./bin |
Scripts and data files for Ripple integrators. |
./Builds |
Platform-specific guides for building rippled . |
./docs |
Source documentation files and doxygen config. |
./cfg |
Example configuration files. |
./src |
Source code. |
Some of the directories under src
are external repositories included using
git-subtree. See those directories' README files for more details.
To learn about how Ripple is transforming global payments, visit https://ripple.com/contact/.