Skip to content

Instantly share code, notes, and snippets.

@makoto
Created May 1, 2018 21:29
Show Gist options
  • Select an option

  • Save makoto/66470557b712ae6d341bba81afaff574 to your computer and use it in GitHub Desktop.

Select an option

Save makoto/66470557b712ae6d341bba81afaff574 to your computer and use it in GitHub Desktop.
Last login: Tue May 1 22:15:04 on ttys002
makoto@Makotos-Air: [~/work/blockparty - (master)] $ git diff
diff --git a/contracts/Conference.sol b/contracts/Conference.sol
index 9dc9f08..193ec6d 100644
--- a/contracts/Conference.sol
+++ b/contracts/Conference.sol
@@ -98,7 +98,7 @@ contract Conference is Destructible, GroupAdmin {
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
- registered++;
+ // registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
makoto@Makotos-Air: [~/work/blockparty - (master)] $ myth -x -minteger contracts/Conference.sol
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: _function_0x05f203d9
PC address: 9014
A possible integer overflow exists in the function `_function_0x05f203d9`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: contracts/Conference.sol:6
contract Conference is Destructible, GroupAdmin {
string public name;
uint256 public deposit;
uint public limitOfParticipants;
uint public registered;
uint public attended;
bool public ended;
bool public cancelled;
uint public endedAt;
uint public coolingPeriod;
uint256 public payoutAmount;
string public encryption;
mapping (address => Participant) public participants;
mapping (uint => address) public participantsIndex;
bool paid;
struct Participant {
string participantName;
address addr;
bool attended;
bool paid;
}
event RegisterEvent(address addr, string participantName, string _encryption);
event AttendEvent(address addr);
event PaybackEvent(uint256 _payout);
event WithdrawEvent(address addr, uint256 _payout);
event CancelEvent();
event ClearEvent(address addr, uint256 leftOver);
/* Modifiers */
modifier onlyActive {
require(!ended);
_;
}
modifier onlyEnded {
require(ended);
_;
}
/* Public functions */
constructor (
string _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod,
string _encryption
) public {
if(bytes(_name).length != 0){
name = _name;
}else{
name = 'Test';
}
if(_deposit != 0){
deposit = _deposit;
}else{
deposit = 0.02 ether;
}
if(_limitOfParticipants !=0){
limitOfParticipants = _limitOfParticipants;
}else{
limitOfParticipants = 20;
}
if (_coolingPeriod != 0) {
coolingPeriod = _coolingPeriod;
} else {
coolingPeriod = 1 weeks;
}
if (bytes(_encryption).length != 0) {
encryption = _encryption;
}
}
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, _encrypted);
}
function register(string _participant) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, '');
}
function registerInternal(string _participant) internal {
require(msg.value == deposit);
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
// registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
function withdraw() external onlyEnded{
require(payoutAmount > 0);
Participant participant = participants[msg.sender];
require(participant.addr == msg.sender);
require(cancelled || participant.attended);
require(participant.paid == false);
participant.paid = true;
participant.addr.transfer(payoutAmount);
emit WithdrawEvent(msg.sender, payoutAmount);
}
/* Constants */
function totalBalance() constant public returns (uint256){
return address(this).balance;
}
function isRegistered(address _addr) constant public returns (bool){
return participants[_addr].addr != address(0);
}
function isAttended(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].attended;
}
function isPaid(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].paid;
}
function payout() constant public returns(uint256){
if (attended == 0) return 0;
return uint(totalBalance()) / uint(attended);
}
/* Admin only functions */
function payback() external onlyOwner onlyActive{
payoutAmount = payout();
ended = true;
endedAt = now;
emit PaybackEvent(payoutAmount);
}
function cancel() external onlyOwner onlyActive{
payoutAmount = deposit;
cancelled = true;
ended = true;
endedAt = now;
emit CancelEvent();
}
/* return the remaining of balance if there are any unclaimed after cooling period */
function clear() external onlyOwner onlyEnded{
require(now > endedAt + coolingPeriod);
uint leftOver = totalBalance();
owner.transfer(leftOver);
emit ClearEvent(owner, leftOver);
}
function setLimitOfParticipants(uint _limitOfParticipants) external onlyOwner onlyActive{
limitOfParticipants = _limitOfParticipants;
}
function attend(address[] _addresses) external onlyAdmin onlyActive{
for(uint i=0;i<_addresses.length;i++){
address _addr = _addresses[i];
require(isRegistered(_addr));
require(!isAttended(_addr));
emit AttendEvent(_addr);
participants[_addr].attended = true;
attended++;
}
}
}
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: clear()
PC address: 5463
A possible integer overflow exists in the function `clear()`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: contracts/Conference.sol:159
endedAt + coolingPeriod
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: register(string)
PC address: 9131
A possible integer overflow exists in the function `register(string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: contracts/Conference.sol:6
contract Conference is Destructible, GroupAdmin {
string public name;
uint256 public deposit;
uint public limitOfParticipants;
uint public registered;
uint public attended;
bool public ended;
bool public cancelled;
uint public endedAt;
uint public coolingPeriod;
uint256 public payoutAmount;
string public encryption;
mapping (address => Participant) public participants;
mapping (uint => address) public participantsIndex;
bool paid;
struct Participant {
string participantName;
address addr;
bool attended;
bool paid;
}
event RegisterEvent(address addr, string participantName, string _encryption);
event AttendEvent(address addr);
event PaybackEvent(uint256 _payout);
event WithdrawEvent(address addr, uint256 _payout);
event CancelEvent();
event ClearEvent(address addr, uint256 leftOver);
/* Modifiers */
modifier onlyActive {
require(!ended);
_;
}
modifier onlyEnded {
require(ended);
_;
}
/* Public functions */
constructor (
string _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod,
string _encryption
) public {
if(bytes(_name).length != 0){
name = _name;
}else{
name = 'Test';
}
if(_deposit != 0){
deposit = _deposit;
}else{
deposit = 0.02 ether;
}
if(_limitOfParticipants !=0){
limitOfParticipants = _limitOfParticipants;
}else{
limitOfParticipants = 20;
}
if (_coolingPeriod != 0) {
coolingPeriod = _coolingPeriod;
} else {
coolingPeriod = 1 weeks;
}
if (bytes(_encryption).length != 0) {
encryption = _encryption;
}
}
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, _encrypted);
}
function register(string _participant) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, '');
}
function registerInternal(string _participant) internal {
require(msg.value == deposit);
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
// registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
function withdraw() external onlyEnded{
require(payoutAmount > 0);
Participant participant = participants[msg.sender];
require(participant.addr == msg.sender);
require(cancelled || participant.attended);
require(participant.paid == false);
participant.paid = true;
participant.addr.transfer(payoutAmount);
emit WithdrawEvent(msg.sender, payoutAmount);
}
/* Constants */
function totalBalance() constant public returns (uint256){
return address(this).balance;
}
function isRegistered(address _addr) constant public returns (bool){
return participants[_addr].addr != address(0);
}
function isAttended(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].attended;
}
function isPaid(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].paid;
}
function payout() constant public returns(uint256){
if (attended == 0) return 0;
return uint(totalBalance()) / uint(attended);
}
/* Admin only functions */
function payback() external onlyOwner onlyActive{
payoutAmount = payout();
ended = true;
endedAt = now;
emit PaybackEvent(payoutAmount);
}
function cancel() external onlyOwner onlyActive{
payoutAmount = deposit;
cancelled = true;
ended = true;
endedAt = now;
emit CancelEvent();
}
/* return the remaining of balance if there are any unclaimed after cooling period */
function clear() external onlyOwner onlyEnded{
require(now > endedAt + coolingPeriod);
uint leftOver = totalBalance();
owner.transfer(leftOver);
emit ClearEvent(owner, leftOver);
}
function setLimitOfParticipants(uint _limitOfParticipants) external onlyOwner onlyActive{
limitOfParticipants = _limitOfParticipants;
}
function attend(address[] _addresses) external onlyAdmin onlyActive{
for(uint i=0;i<_addresses.length;i++){
address _addr = _addresses[i];
require(isRegistered(_addr));
require(!isAttended(_addr));
emit AttendEvent(_addr);
participants[_addr].attended = true;
attended++;
}
}
}
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: register(string)
PC address: 9089
A possible integer overflow exists in the function `register(string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: contracts/Conference.sol:6
contract Conference is Destructible, GroupAdmin {
string public name;
uint256 public deposit;
uint public limitOfParticipants;
uint public registered;
uint public attended;
bool public ended;
bool public cancelled;
uint public endedAt;
uint public coolingPeriod;
uint256 public payoutAmount;
string public encryption;
mapping (address => Participant) public participants;
mapping (uint => address) public participantsIndex;
bool paid;
struct Participant {
string participantName;
address addr;
bool attended;
bool paid;
}
event RegisterEvent(address addr, string participantName, string _encryption);
event AttendEvent(address addr);
event PaybackEvent(uint256 _payout);
event WithdrawEvent(address addr, uint256 _payout);
event CancelEvent();
event ClearEvent(address addr, uint256 leftOver);
/* Modifiers */
modifier onlyActive {
require(!ended);
_;
}
modifier onlyEnded {
require(ended);
_;
}
/* Public functions */
constructor (
string _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod,
string _encryption
) public {
if(bytes(_name).length != 0){
name = _name;
}else{
name = 'Test';
}
if(_deposit != 0){
deposit = _deposit;
}else{
deposit = 0.02 ether;
}
if(_limitOfParticipants !=0){
limitOfParticipants = _limitOfParticipants;
}else{
limitOfParticipants = 20;
}
if (_coolingPeriod != 0) {
coolingPeriod = _coolingPeriod;
} else {
coolingPeriod = 1 weeks;
}
if (bytes(_encryption).length != 0) {
encryption = _encryption;
}
}
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, _encrypted);
}
function register(string _participant) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, '');
}
function registerInternal(string _participant) internal {
require(msg.value == deposit);
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
// registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
function withdraw() external onlyEnded{
require(payoutAmount > 0);
Participant participant = participants[msg.sender];
require(participant.addr == msg.sender);
require(cancelled || participant.attended);
require(participant.paid == false);
participant.paid = true;
participant.addr.transfer(payoutAmount);
emit WithdrawEvent(msg.sender, payoutAmount);
}
/* Constants */
function totalBalance() constant public returns (uint256){
return address(this).balance;
}
function isRegistered(address _addr) constant public returns (bool){
return participants[_addr].addr != address(0);
}
function isAttended(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].attended;
}
function isPaid(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].paid;
}
function payout() constant public returns(uint256){
if (attended == 0) return 0;
return uint(totalBalance()) / uint(attended);
}
/* Admin only functions */
function payback() external onlyOwner onlyActive{
payoutAmount = payout();
ended = true;
endedAt = now;
emit PaybackEvent(payoutAmount);
}
function cancel() external onlyOwner onlyActive{
payoutAmount = deposit;
cancelled = true;
ended = true;
endedAt = now;
emit CancelEvent();
}
/* return the remaining of balance if there are any unclaimed after cooling period */
function clear() external onlyOwner onlyEnded{
require(now > endedAt + coolingPeriod);
uint leftOver = totalBalance();
owner.transfer(leftOver);
emit ClearEvent(owner, leftOver);
}
function setLimitOfParticipants(uint _limitOfParticipants) external onlyOwner onlyActive{
limitOfParticipants = _limitOfParticipants;
}
function attend(address[] _addresses) external onlyAdmin onlyActive{
for(uint i=0;i<_addresses.length;i++){
address _addr = _addresses[i];
require(isRegistered(_addr));
require(!isAttended(_addr));
emit AttendEvent(_addr);
participants[_addr].attended = true;
attended++;
}
}
}
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: registerWithEncryption(string,string)
PC address: 5771
A possible integer overflow exists in the function `registerWithEncryption(string,string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: contracts/Conference.sol:87
registerInternal(_participant)
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: register(string)
PC address: 7891
A possible integer overflow exists in the function `register(string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: contracts/Conference.sol:92
registerInternal(_participant)
--------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment