Once you’ve learned how to deploy your contracts to a test network, you’ll be given the opportunity to submit your contract address for review by an onchain unit test. If it passes, you’ll receive an NFT pin recognizing your accomplishment.You’ll deploy and submit this contract in the next module.
Contract
Create a contract calledBasicMath. It should not inherit from any other contracts and does not need a constructor. It should have the following two functions:
Adder
A function calledadder. It must:
- Accept two
uintarguments, called_aand_b - Return a
uintsumand aboolerror - If
_a+_bdoes not overflow, it should return thesumand anerroroffalse - If
_a+_boverflows, it should return0as thesum, and anerroroftrue
Subtractor
A function calledsubtractor. It must:
- Accept two
uintarguments, called_aand_b - Return a
uintdifferenceand aboolerror - If
_a-_bdoes not underflow, it should return thedifferenceand anerroroffalse - If
_a-_bunderflows, it should return0as thedifference, and anerroroftrue