Polkadot JS Apps¶
With the release of the v3 upgrade for the Moonbase Alpha TestNet, we have made significant updates to the underlying account system on Moonbeam, replacing the default Substrate-style accounts and keys with Ethereum-style accounts and keys.
On the previous configuration, a user (let's say Alice) can have an Ethereum-style address (H160 format) in a Substrate based chain. This address matches a private key, which can be used to sign transactions in the Ethereum side of the chain. Furthermore, the address is mapped into a storage slot inside the Substrate Balance pallet to a Substrate-style address (H256 format). However, Alice only knows the private key of the H160 address. Therefore, she is unable to send transactions with her H256 address and is limited only to do read-only operations through Substrate's API. As a consequence, Alice needs another H256 address matching a different private key to be able to operate in the Substrate side of the chain, which include, among others, staking, balances, and governance.
With Unified Accounts, a user (let's call him Bob) will only need a single H160 address, with its corresponding private key, to do everything we mentioned above including both EVM and Substrate functions. Consequently, he does not need to move balances between 2 different accounts and is able to access all the features with a single account and private key.
The Polkadot JS Apps interface was updated as well so that it natively supports H160 addresses and ECDSA keys. So, in this tutorial lets check this new integration of Ethereum-based accounts on the Polkadot JS Apps site.
Connecting to Moonbase Alpha¶
First, we need to connect it to the Moonbase Alpha TestNet by clicking the top left corner logo and selecting Moonbase Alpha under Test Networks.
After switching, the Polkadot JS site will not only connect to Moonbase Alpha, but it will also change its styling, to make a perfect match.
Importing an H160 Account¶
Let's see how we can import an already existing MetaMask account to Polkadot JS Apps. First, navigate to the accounts section, and click in the add account button.
This will open a wizard pop-up that will guide you through the process of adding an account to the Polkadot JS Apps interface. Make sure you click on the drop-down menu and change from Mnemonic to Raw seed, this allows you to add an account through a private key.
Next, enter your private key that you can export from MetaMask, in this case we are importing the following account:
- Private key:
- Public address:
Make sure to include the prefix in the private key, that is
0x. If you entered the information correctly, the corresponding public address should appear in the upper left corner of the window.
Click next and finish the wizard by setting an account name and password. After a confirmation message, you should see in the main Accounts tab the address with the corresponding balance, in our case Bob's. Moreover, we can overlay the MetaMask extension to see that both balances are the same.
Sending a Transaction Through Substrate's API¶
Now, let's demonstrate the potential of Moonbeam's Unified Accounts scheme by making a transfer through the Substrate API using the Polkadot JS Apps. Remember that we are talking about interacting with Substrate using an Ethereum-style H160 address. To do so, we've imported another account, named Charley with 5
Next, let's click on Bob's send button, which opens another wizard that guides you through the process of sending a transaction. Set the send to address and the amount, which for our example is 5 DEV tokens. When ready click on the Make Transfer button.
After the transaction is signed using the password, Polkadot JS will display some messages on the top right corner while it's being processed. Once confirmed, you should see the balances updated for each account.
And that is it! We are super excited about being able to support H160 accounts in Polkadot JS Apps, as we believe this will greatly enhance the user experience in the Moonbeam Network and its Ethereum compatibility features.
If you have any feedback regarding the Polkadot JS Apps, the Unified Accounts integration, or any other Moonbeam related topic, feel free to reach out through our official development Discord server.