This is is something that was changed.
Prepare the environment by following the instructions in basic requirements
Clone the project. Then run the following from the Enveloping project's root directory
yarn install && yarn prepare
.
We use truffle
for deploying contracts.
npx truffle migrate --network rsk
(disclaimer: rsk network is for Regtest network).
In order to run an instance of Enveloping in Regtest:
- From the jsrelay directory
npx webpack
. - Configure the server, to do it just edit the config file located at
jsrelay/config/relay-config.json
. You need to specify some parameters there like this:{ url: 'localhost', // the interface where the relay server will be exposed port: 8090, // the port where it will be running relayHubAddress: '0x3bA95e1cccd397b5124BcdCC5bf0952114E6A701', // the relay hub contract address (can be retrieved from the summary of the deployment). relayVerifierAddress: '0x74Dc4471FA8C8fBE09c7a0C400a0852b0A9d04b2', // the relay verifier contract address (can be retrieved from the summary of the deployment). deployVerifierAddress: '0x1938517B0762103d52590Ca21d459968c25c9E67', // the deploy verifier contract address (can be retrieved from the summary of the deployment). gasPriceFactor: 1, // a gas price factor to use on gas price calculation, the price will be multiplied by this factor rskNodeUrl: 'http://localhost:4444', // endpoint where the RSK node is running devMode: true, // a flag to set development mode customReplenish: false, // set if the server uses a custom replenish function or not logLevel: 1, // the log level workdir: '/some/absolute/path' // an absolute path to the working directory of the server, the server will store all the information there }
- From the root directory run
node dist/src/cli/commands/enveloping.js relayer-run --config jsrelay/config/relay-config.json
. - To check if it is working, run
curl http://localhost:8090/getaddr
.
We use truffle
for deploying contracts.
npx truffle migrate --network rsktestnet
(disclaimer: to use testnet, you should have an unlocked account with funds or configure it in truffle.js
).
We have already deployed these contracts on Testnet.
Each relayed transaction is signed by a Relay Worker account. The worker accounts are controlled by the Relay Manager. When a relay worker signs and relays a transaction, the cost for that transaction is paid using the funds in that worker's account. If the transaction is not subsidized, then the worker is compensated with tokens. Worker accounts must always have some minimum balance to pay gas for the transaction. These balances can be managed by implementing a replenishment strategy. The Relay Manager can use the strategy to top off a relay worker's account when the balance gets too low. We provide a default implementation for a replenishment strategy. Enveloping solution integrators can implement their own replenish strategy.
To implement and use your own replenish strategy:
- In the folder
src/relayserver
, openReplenishFunction.ts
with a text editor. - On the function
replenishStrategy
write your replenish strategy on the then branch. - Re build the project
yarn && yarn prepare
- Add the command
--customReplenish
when running a Relay Server or change the config json file to setcustomReplenish
on true.
In order to run an Enveloping instance in Testnet, clone the project then run the following from the project's root directory:
- Create the project home folder, in this folder the jsrelay databases will be placed:
mkdir enveloping_relay
- In a terminal run
node dist/src/cli/commands/enveloping.js relayer-run --rskNodeUrl "http://localhost:4444" --relayHubAddress=<RELAY_HUB_CONTRACT_ADDRESS> --deployVerifierAddress=<DEPLOY_VERIFIER_CONTRACT_ADDRESS> --relayVerifierAddress=<RELAY_VERIFIER_CONTRACT_ADDRESS> --versionRegistryAddress=<VERSION_REGISTRY_CONTRACT_ADDRESS> --url <RELAY_URL> --port 8090 --workdir enveloping_relay --checkInterval 30000
where<RELAY_HUB_CONTRACT_ADDRESS>
is the address for the relayHub you are using in the current network,<RELAY_URL>
in most cases will behttp://localhost
, and the server will be reachable in<RELAY_URL>:port
unless<RELAY_URL>
already defines a port (e.g, if<RELAY_URL>
ishttp://localhost:8090/jsrelay
) - In another terminal run
curl http://localhost:8090/getaddr
which will return some JSON with information of the running jsRelay Server, for example:
{
"relayWorkerAddress": "0xe722143177fe9c7c58057dc3d98d87f6c414dc95",
"relayManagerAddress": "0xe0820002dfaa69cbf8add6a738171e8eb0a5ee54",
"relayHubAddress": "0x38bebd507aBC3D76B10d61f5C95668e1240D087F",
"minGasPrice": "6000000000",
"chainId": "31",
"networkId": "31",
"ready": false,
"version": "2.0.1"
}
- Send to relayManagerAddress at least 0.001 tRBTC to set it up
- Send to relayWorkerAddress at least 0.001 tRBTC to set it up
- Once both addresses have been funded, run
node dist/src/cli/commands/enveloping.js relayer-register --network <RSKJ_NODE_URL> --hub <RELAY_HUB_CONTRACT_ADDRESS> -m secret_mnemonic --from <ADDRESS> --funds <FUNDS> --stake <STAKE> --relayUrl <RELAY_URL>
wheresecret_mnemonic
contains the path to a file with the mnemonic of the account to use during the relay server registration,<ADDRESS>
is the account address associated to that mnemonic - Wait until the relay server prints a message saying
RELAY: READY
.
The relay server running in the background. Run the bash file scripts/kill-relay-server.sh