Skip to main content

Connect Wallet To Test

When you deploy your game to production, of course you can use whatever wallet system you want to interact with your application.

The steps below, however, are to make connecting a wallet to your local network as you test a breeze.

A Note on Browser Profiles​

To avoid making a mistake, it's usually best to have a special environment you use just for testing (that you never connect you main wallet to).

Chrome has a great features that allows creating multiple profiles in your browser -- each with its own totally separate browser storage and separate browser extensions. It makes it easy to create a "test" profile for setting up wallets.

Learn more here.

Rivet is a browser extension wallet optimized for developers who are testing making it perfect for developing with Paima Engine.

You can see an example of Rivet being used as the wallet to test a game running on localhost below: Alt text

Step 1: Download Rivet​

You can download it here.

If you're running a special environment other than Chrome, refer to the Rivet docs

Step 2: Run your game UI and open it in your browser​

Unlike other wallets, Rivet does nothing on regular web pages (you cannot tap it like MetaMask). See here if you need help on getting your game running

Step 3: Go through the Anvil setup​

Once you've opened the frontend for your game, you may see Rivet appear on the screen, or you may have to tap its icon in the extension bar at the top-right of your browser (it may be hidden by default until you press the extensions icon). We'll walk you through the setup steps.

1. Press the Create Anvil instance (it doesn't matter that you're not actually running Anvil. You don't need to know what it is).​

Alt text

2. Ignore the instructions and just press "Continue"​

Alt text

3. Configure the options to match your hardhat.config.ts for your game (you can find this in the template you downloaded for Paima)​

  • Chain ID 31337
  • Network Name Hardhat
  • RPC URL http://localhost:8545
  • Block Number 1
  • Block Time 2

Alt text

4. Approve the request to connect to localhost​

Alt text

5. (optional) Take it all in​

You should now get significantly more detailed views of the transactions for your game, and you can also see all the transactions, addresses and contracts deployed to your local network.

Note that Rivet uses addresses automatically generated for your local network. These addresses are for testing purposes only. You should NEVER use them on a real network (these are not your addresses magically imported from MetaMask or elsewhere. They are publicly known addresses that anybody can reuse).

Some features of Rivet will crash (just refresh the page if this happens). This is happens because Rivet was originally designed for Anvil which is a different tool for managing local networks (and we're using Hardhat instead). Fortunately these tools are compatible enough that things mostly work.

6. (optional) Setup auto-signing​

If you don't want to manually approve every transaction for your application, and don't want to setup Paima's account abstraction layer just to play around on a test network, Rivet comes with a functionality to auto-sign transactions for you.

Just open the settings icon at the top-right and check the two boxes seen below (or all three if you're following our recommendation to use browser profile just for testing ). Note: this is only safe because we're doing this on a local network. Do not do this with a real wallet on a real network.

Alt text

(Not Recommended) Using MetaMask​

MetaMask is a popular browser extension wallet. Although it works okay for mainnet, it is not optimized for developer usage on networks running locally. We'll show your the steps on how to get it working despite this, but we recommend Rivet if possible.

Key points to keep in mind:

  1. These steps are only required if running on a localhost network (not required on mainnet / testnet)
  2. You will need to reset your nonce often for this by going to Settings > Advanced > Clear activity and nonce data (more on this later)

There are two ways to connect MetaMask to your local network

Option 1:Hardhat Private Key β†’ MetaMask​

1. Open MetaMask and click on the account selector at the top of the screen​

Alt text

2. Click "Add Account" at the bottom​

Alt text

3. Select "import account"​

Alt text

4. Paste in the private key seen when running npm run chain:start​

Alt text

Option 2: MetaMask mnemonic β†’ Hardhat​

See the MetaMask guide for this here

Important MetaMask Issue​

The main issue with MetaMask is that it will not automatically detect if your locally running network got reset. This is problematic because in EVM, every transaction made by an account has an ID ("nonce") that needs to be a continuously increasing value (learn more here), and so if you restart your local network MetaMask will use the wrong nonce and your transactions will fail silently.

Alt text

To solve this issue, follow the steps below every time you restart your local network.

Alt text

Rivet does not have this issue and refreshing the page is generally sufficient.