Skip to content

Instantly share code, notes, and snippets.

@Eyongkevin
Created April 24, 2019 14:36
Show Gist options
  • Save Eyongkevin/05c3f884bd22948628de80da5282812e to your computer and use it in GitHub Desktop.
Save Eyongkevin/05c3f884bd22948628de80da5282812e to your computer and use it in GitHub Desktop.
This is a solidity library with two functions and a struct.
pragma solidity ^0.4.24;
library count{
struct hold{
uint a;
}
function subUint(hold storage s, uint b) public returns(uint){
require(s.a >= b); // Make sure it doesn't return a negative value.
return s.a - b;
}
function addUint(uint a , uint b) public pure returns(uint){
uint c = a + b;
require(c >= a); // Makre sure the right computation was made
return c;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment