Let’s Make An Ethereum Simulation Game — Part 4

Training and resting players

Alex Roan
Coinmonks
Published in
6 min readApr 11, 2020

--

Image by composita from Pixabay

Recap

Part three saw the introduction of the last Smart Contract jigsaw piece being put into place, and from there, the beginnings of a rudimentary interface using React and Redux.

I’ve added a few cool little features since then and got the interface to a state where users can add new players, train them to increase attributes, and rest them to increase condition.

Here’s how I did it.

The Interface

Recently, I got asked a question from one of my readers. They asked how their DApp could listen for account changes within Metamask in real-time without refreshing the page.

Message from @SolidityDev on Twitter

Metamask users can change account at any time, but the DApp won’t know about it unless it’s listening for it. It doesn’t do it by default. An error will occur if the DApp thinks the current account is sending a transaction, but it comes from another.

This prompted an article I wrote which explains listening for accounts changing and updating the in-app data accordingly.

--

--

Alex Roan
Coinmonks

CoFounder at Cyfrin. Previously: Chainlink Labs.