Articles Chinese Community / 中国社区 English

RChain Powerbox Summary

August 11, 2020 – Originally posted in Chinese here by Dimworm.

The Powerbox is the RChain system-level channel through which Rholang smart contract developers can invoke system resources. the Powerbox layer sits between the system’s physical resources and the Rholang code, and is used to handle requests such as disk IO and network, and access requests to RSpace via the The Powerbox layer.

The Powerbox model is borrowed from the Object Capability (“OCaps”) Security Model, where the Powerbox acts as an arbiter of privilege transfer and combines multiple privilege management in one place. When a subsystem needs a new permission, the Powerbox decides whether to grant it or not.

There are 29 Powerboxes in this article for developers to use.

First category, screen IO related
Includes the following five.


The other three are similar. stdout outputs to the screen, and stdoutAck generates an acknowledgement signal to trigger other events.

new myAckChannel,
stdoutAck(rho:io:stdoutAck) in {
stdoutAck!(“Print some words.”, *myAckChannel)|
for (ackledgement <- myAckChannel) {
stdout!(“Received an acknowledgement.”)

Category 2, Deploy related

Includes the following five.


Smart Contracts can get information from the system during the deployment of Smart Contracts and out of blocks.

rho:rchain:deployId returns the current deployable smart contract’s deployId.

new deployId(rho:rchain:deployId),
in {

rho:rchain:deployerId can return the deployerId of the current smart contract deployer.

new deployerId(rho:rchain:deployerId),
in {

rho:rchain:deployerId:ops Receives a deployerId, which returns the public key of the deployer. The following example returns the address of the REV wallet corresponding to the current smart contract deployer.

new RevAddress(rho:rev:address), DeployerIdOps(rho:rchain:deployerId:ops),
deployerId(rho:rchain:deployerId), stdout(rho:io:stdout),
revAddrCh, deployerPubKeyBytesCh
in {
DeployerIdOps!(“pubKeyBytes”, *deployerId, *deployerPubKeyBytesCh) | | DeployerIdOps!
for (@deployerPubKeyBytes <- deployerPubKeyBytesCh) {
RevAddress!(“fromPublicKey”, deployerPubKeyBytes, *revAddrCh) | | RevAddress!
for (@deployerRevAddress <- revAddrCh) {

rho:block:data can return the BlockNumber, timestamp, and deployerId of the block that the smart contract is currently deployed.

new retCh, getBlockData(rho:block:data), stdout(rho:io:stdout) in {
getBlockData!(*retCh) | getBlockData!
for (@blockNumber, @timestamp, @sender <- retCh) {
stdout!((blockNumber, timestamp, sender))

rho:deploy:params This parameter was used in some version of PoS.rhox and has been removed in anticipation of discovering related information.

The third type, currency related
Including the following four.


REV differs from ETH in that ETH is a native coin on ethereum and there is no coin on RChain, REV is generated by way of a smart contract and should be called a token. The advantage of REV is that it has the same business logic as other tokens on the RChain mainnet and can be interoperated through smart contracts, whereas ETH is There is no such capability. That’s why tokens like WETH exist on ethereum.

rho:rchain:makeMint This smart contract can cast the token for you, and REV is cast by this smart contract.

new MakeMintCh, stdout(rho:io:stdout),
in {
rl!(rho:rchain:makeMint, MakeMintCh) | `rho:rchain:makeMintCh’) for (@(_, MakeMint) <- MakeMintCh){ new mintCh in { @MakeMint!(mintCh)
for (mint <- mintCh) {
new purseCh in {
mint!(“makePurse”, 999999999999999, purseCh) | for (purse <- purseCh) { stdout!(purse)

To understand the basic concepts of Vault and Purse you can see here: terms+such+that+wallet+is+not+used+for+on-chain+components

Note: REV can be accurate to 8 decimal places. REV can only be expressed as an integer on the chain, and the REV balance should be divided by 10^8.

rho:rchain:revVault interacts with REV’s smart contract to initiate activities such as creating new wallets, transferring funds, etc.
The following code is used to query the wallet address balance.

rl(rho:registry:lookup), RevVaultCh,
vaultCh, balanceCh,
in {

rl!(rho:rchain:revVault, *RevVaultCh) | rho:rchain:revVault, *RevVaultCh)
for (@(_, RevVault) <- RevVaultCh) { match “%REV_ADDR” { revAddress => {
stdout!((“Accessing vault at RevAddress”, revAddress)) | stdout!
@RevVault!(“findOrCreate”, revAddress, *vaultCh) | @RevVault!
for (@(true, vault) <- vaultCh) {
@vault!(“balance”, *balanceCh) | @vault!
for (@balance <- balanceCh) {
stdout!((“Balance is”, balance)))



Other operations, such as transfers, can be found at .rho

rho:rev:address can generate REV addresses from both the public key and Unforgeable name.

new a, RevAddress(rho:rev:address), revAddr1Ch, revAddr2Ch,
stdout(rho:io:stdout) in {
RevAddress!(“fromUnforgeable”, *a, *revAddr1Ch) | (*a, *revAddr1Ch)
RevAddress!(“fromPublicKey”, “xxx”, *revAddr2Ch) | | RevAddress!
for (@unforgeableRevAddress <- revAddr1Ch) {
stdout!((“Rev address from Unforgeable name: “, unforgeableRevAddress))
for (@deployerRevAddress <- revAddr2Ch) {
stdout!((“Rev address from pub key: “, deployerRevAddress))

rho:rchain:multiSigRevVault Used to generate multi-signature wallets, we will write an article specifically about this code, multi-signature wallet smart contract code.

Category IV, Competence-related
Including the following three.


rho:rchain:authKey AuthKey is used to create an authorized token, AuthKey provides make and check methods. make method formulates the unforgeable name as “shape” to ensure no leakage. unforgeable name.
We will write an article about AuthKey.
AuthKey’s code:

sys:authToken:ops This application is found in the PoS.rhox code and should be used to check if the call is from the system. See also.

sysAuthTokenOps!(“check”, sysAuthToken, *isValidTokenCh) | sysAuthTokenOps!
for (@isValid <- isValidTokenCh) {
if (isValid) {


rho:rchain:pos makes a call to the PoS smart contract.
The following example is from successfully completed once Validator’s Binding.

new retCh, PoSCh, rl(rho:registry:lookup), stdout(rho:io:stdout) in {
stdout!(“About to lookup pos contract…”) |
rl!(rho:rchain:pos, *PoSCh) | rho:rchain:pos', *PoSCh) for(@(_, PoS) <- PoSCh) { stdout!("About to bond...") | new deployerId(rho:rchain:deployerId`) in {
@PoS!(“bond”, *deployerId, 100, *retCh) | @PoS!
for ( @(true, message) <- retCh) {
stdout!(“Successfully bonded!”)

Category V, Data Structures
Including the following four.





Either Either is a data type borrowed from scala, and is used in scenarios where there are two possible outcomes. Eitehr is also more complex, and we are preparing an article to explain it.

rho:lang:listOps for arrays of operations on chains

Add and multiply non-negative numbers to prevent overflow.

rho:lang:treeHashMap TreeHashMap TreeHashMap is also a data type borrowed from scala, used to improve the speed of data insertion or query on the chain. We specialize in preparing an article about TreeHashMap. TreeHashMapr related code: src/main/resources/TreeHashMap.rho

Category VI, registration-related
Including the following four.


rho:registry:insertArbitrary The following example registers a newContract on the chain:

new newContract, uriChan,
in {
contract newContract(@a) = {

insertArbitrary!(bundle+{*newContract} , *uriChan) | insertArbitrary!
for(@uri <- uriChan) {

rho:registry:lookup The following example finds the contract for newContract from the chain and triggers.

new newContractCh,
in {
rl!(rho:id:xxx, *newContractCh) | rho:id:xxx, *newContractCh)
for (newContract <- newContractCh) {

rho:registry:ops The following example uses a string to generate rho:id.

new registryOps(rho:registry:ops), retCh,
in {
registryOps!(“buildUri”, “foo”.toByteArray(), *retCh) | registryOps!
for (@ret <- retCh){

Category VII, test-related
Including the following four.


We don’t usually use test classes, we’ll introduce them when we get a chance.

Welcome to “Rholang Chinese Community” public website.

Developers are welcome to join “RChain Developers” WeChat group. Please add lowbird WeChat to join the group. Non-developers please do not join, there will be a round of testing, and only those who pass will be admitted.