Skip to content

Instantly share code, notes, and snippets.

View Shashank-In's full-sized avatar
🏠
Working from home

Shashank Shashank-In

🏠
Working from home
View GitHub Profile
function splitDAO(uint _proposalID, address _newCurator) noEther onlyTokenholders returns (bool _success) {
...
uint fundsToBeMoved = (balances[msg.sender] * p.splitData[0].splitBalance) / p.splitData[0].totalSupply;
//Since the balance is never updated the attacker can pass this modifier several times
if (p.splitData[0].newDAO.createTokenProxy.value(fundsToBeMoved)(msg.sender) == false) throw;
...
// Burn DAO Tokens
pragma solidity 0.5.17;
contract adminChecker {
address admin = msg.sender;
function roleCheck() internal view returns (bool) {
return msg.sender == admin;
}
}
fallback() external payable {
fallbackVulnerability.withdrawAllMoney(msg.value);
}
contract fallbackVulnerability {
mapping (address => uint) private balances;
function addAllMoney (address Useraccount) public payable {
balances [Useraccount] = msg.value;
}
function withdrawAllMoney (uint Totalamount) public {
if (balances [msg.sender]>= Totalamount) {
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;
contract Test {
address public owner;
constructor() {
owner = msg.sender;
function _update(
uint128 baseBalance,
uint128 fyBalance,
uint112 _baseCached,
uint112 _fyTokenCached
) private {
....
cumulativeBalancesRatio +=
(scaledFYTokenCached / _baseCached) *
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Fee {
function caculateLowFee() public pure returns(uint){
uint coins = 2;
uint Total_coins = 10;
uint fee = 15;
return((coins/Total_coins) * fee);
}
// bad
someAddress.send(123);
someAddress.call{msg.value: 12, gas: 1233}() // this is dangerous, as it will forward all remaining gas and doesn't check for the result
someAddress.call{msg.value: 100}(bytes4(sha3("deposit()"))); // if deposit fails, the call() will return false and the tx will not be reverted
// good, require() can also be used
if(!someAddress.send(123)) {
// error handling
}
function SendCash(uint roundIndex, uint subpotIndex){
var subpotsCount = getSubpotsCount(roundIndex);
if(subpotIndex>=subpotsCount) {
return;
}
var decisionBlocksNumber = getDecisionBlocksNumber(roundIndex,subpotIndex);
if(decisionBlocksNumber>block.number) {
return;
}
if(rounds[roundIndex].isCashed[subpotIndex]) {
pragma solidity 0.4.1;
contract ReturnValueCall {
function callchecked(address callee) public {
require(callee.call());
}
function callnotchecked(address callee) public {
callee.call();
}
}