This is a sample dApp that displays how users can submit relayed transactions to the Rootstock blockchain using the RIF Relay Sample dApp SDK. You will need to connect to the dApp with MetaMask but only for signing transactions with the account that owns the Smart Wallets.
For a detailed step-by-step guide on getting started with RIF Relay, refer to the RIF Relay Starter kit.
- NodeJS Version v16.14.2 or higher.
- RSKj Node Running.
- RIF Relay Contract deployed.
- Current Token Allowed.
- RIF Relay Server running and registered.
For details on the RIF Relay modules, see RIF Relay project.
To setup the dApp:
- Clone this repository and install dependencies:
# clone repository git clone https://github.com/rsksmart/relaying-services-sdk-dapp cd relaying-services-sdk-dapp # install dependencies npm install --force
- Create a new file named
.env
in the top directory, and add the following lines in it (with the contract addresses generated when we deployed the contracts) in the Set up RIF Relay Contracts section above:REACT_APP_CONTRACTS_RELAY_HUB=0x463F29B11503e198f6EbeC9903b4e5AaEddf6D29 REACT_APP_CONTRACTS_DEPLOY_VERIFIER=0x14f6504A7ca4e574868cf8b49e85187d3Da9FA70 REACT_APP_CONTRACTS_RELAY_VERIFIER=0xA66939ac57893C2E65425a5D66099Bc20C76D4CD REACT_APP_CONTRACTS_SMART_WALLET_FACTORY=0x79bbC6403708C6578B0896bF1d1a91D2BB2AAa1c REACT_APP_CONTRACTS_SMART_WALLET=0x987c1f13d417F7E04d852B44badc883E4E9782e1 REACT_APP_RIF_RELAY_CHAIN_ID=33 REACT_APP_RIF_RELAY_GAS_PRICE_FACTOR_PERCENT=0 REACT_APP_RIF_RELAY_LOOKUP_WINDOW_BLOCKS=1e5 REACT_APP_RIF_RELAY_PREFERRED_RELAYS=http://localhost:8090 REACT_APP_BLOCK_EXPLORER=https://explorer.testnet.rsk.co
- Run the dApp
# run app in regtest environment ENV_VALUE="regtest" npm run start
- Ensure that MetaMask is configured to use the same network where you deployed the contracts (e.g. Regtest or Testnet).
- Open a browser and navigate to http://localhost:3000
You can run the sample dApp as a Docker container. Docker and Docker compose should be installed. The steps are the same as indicated here. The difference is in the step 3. Instead of npm start, run this:
docker-compose build && docker-compose up
When using the RSK Regtest enviroment, it may happen that the transaction nonce is wrong. This is due to a MetaMask problem in which it saves the nonce locally and when you reset the chain the nonce is changed.
Solution:
- Choose the account in which you have the problem
- Enter Metamask
Advanced Settings
- Click on
Reset Account
. This will delete all data from the account saved in metamask, and it will look it up again on the chain. Please note that this procedure does not delete the account, but only the info gathered from the current connected blockchain.
Read more about this on this medium post