I built a DApp Game — This is what I’ve learned

The start

Developing the smart contract

Testing

export default async function expectRevert(promise) {
try {
await promise;
} catch (error) {
const invalidJump = error.message.search("invalid JUMP") >= 0;
const revert = error.message.search("revert") >= 0;
const outOfGas = error.message.search("out of gas") >= 0;
const invalidOpcode = error.message.search("invalid opcode") >= 0;
if (revert || invalidJump || outOfGas || invalidOpcode) {
return;
}
}
assert.fail("Expected revert not received");
}
export default async function expectEvent(promise, eventName = "") {
try {
let result = await promise;
let found = false;if (Array.isArray(result.logs)) {
found = result.logs.find(log => log.event === eventName);
}
if (found) {
return;
}
assert.fail("Expected event, got '" + result.logs + "' instead");
} catch (e) {
console.log(e);
}
assert.fail();
}

Developing the user interface

Conclusion

Written by

React Native Mobile Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store