The Layer 2 (L2) scaling solution was introduced in early 2022 as an alternative way to manage Urbit IDs, to aleviate the problem of high transaction costs on Ethereum. Before L2, each Urbit ID transaction had to be executed on the Ethereum blockchain, with costs per transaction ranging from $20-$100.
The offcial Urbit roller (running here: https://roller.urbit.org/v1/roller) has quite a low quota of transaction per ship. If you want to, say, spawn 100 planets, you need to run your own roller.
Before you can start, you need a few Ethereum accounts. We will assume you have a star that wants to spawn and manage planets, but the setup would work similarly in other scenarios too.
Use something like MetaMask to manage your accounts. The nice thing is, once your star is migrated to L2, most of the accounts listed here do not need any ETH to work. The roller will pay for the transactions.
To indicate what address and private key is referd to later, we'll give each an alias here, e.g., 0xOwner, 0xOwnerKey. Of course, they should be substituted by the actual Ethereum address and private key.
To get the private key in MetaMask, click on an account, select "Account Details" and then "Export Private Key".
Assuming you own a star, log in to Bridge and migrate your star or the spawn capability of your star to L2 (I recommend that you only move the ability to spwan). This is an L1 transaction and the account needs ETH.
0xOwner
, 0xOwnerKey
Create a new account that will act as the L2 spawn proxy for your planets. In Bridge, once the migration to L2 has completed, set the spawn proxy to this address.
0xSpawnProxy
, 0xSpawnProxyKey
This is only needed if you plan to host the planets, because you'll want to be able to transfer ownership while remaining management proxy of the planets, which is needed to set and reset the network keys.
Create a new account that will act as the L2 management proxy for your planets.
0xManagementProxy
The roller needs access to ETH. Create an account to which you can transfer some ETH. I recommend to transfer first $100 or so while testing. This should allow to spawn at least 50 planets.
0xRoller
, 0xRollerKey
This is based on this tutorial: https://pastebin.com/wQDw7nHv
Make sure you have Urbit v1.8 or later installed.
Create an account with Infura and make sure to copy the infura URL, something like: https://mainnet.infura.io/v3/YOURSPECIALKEY
. Alternatively you can also use your own Ethereum node, but we will assume you are using Infura.
- Boot a fakezod:
./urbit -F zod
- Once booted, set the Ethereum node:
:azimuth|watch 'https://mainnet.infura.io/v3/YOURSPECIALKEY' %default
- Make sure the subscription works:
:azimuth %resub
- Start roller agents:
|rein %base [& %roller] [& %roller-rpc] [& %azimuth-rpc]
- Set roller Ethereum node:
:roller|endpoint 'https://mainnet.infura.io/v3/YOURSPECIALKEY' %mainnet
- Give the roller access to your "Roller Account" (see above):
:roller|setkey '0xRollerKey'
- Increase the quota, so you can do larger batches:
:roller|quota 100
- If you want to also connect via a local Brige instance, also set this:
|cors-approve 'http://localhost:3000'
To test, you can now do requests via command line:
curl --location --request POST 'http://localhost:8080/v1/roller' --header 'Content-Type: application/json' --data-raw '{
"jsonrpc": "2.0",
"method": "getPoint",
"params": {
"ship": "~sampel"
},
"id": "1234"
}'
Replace ~sampel
with your star name. It should show dominion as l2
or spawn
.
For a more cURL examples, see here.
- Send the current batch to the blockchain (by default, the batch is sent on the hour, every hour):
:roller|commit
- Check if there is any Ethereum state pending (it should return 0):
:eth-watcher +dbug [%state '(lent pending-logs:(~(got by dogs) /azimuth))']
- See how many azimuth logs there are:
:azimuth +dbug [%state '(lent logs)']
When you use modify-l1
commands, make sure you include the following option: --roller-provider=local
. Otherwise, the CLI will use the official Urbit roller.