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
uint
arguments, called_a
and_b
- Return a
uint
sum
and abool
error
- If
_a
+_b
does not overflow, it should return thesum
and anerror
offalse
- If
_a
+_b
overflows, it should return0
as thesum
, and anerror
oftrue
Subtractor
A function calledsubtractor
. It must:
- Accept two
uint
arguments, called_a
and_b
- Return a
uint
difference
and abool
error
- If
_a
-_b
does not underflow, it should return thedifference
and anerror
offalse
- If
_a
-_b
underflows, it should return0
as thedifference
, and anerror
oftrue