Skip to content

Instantly share code, notes, and snippets.

View maurelian's full-sized avatar
💯

Maurelian maurelian

💯
View GitHub Profile
@maurelian
maurelian / -
Created February 26, 2018 16:48
======= contracts/Migrations.sol:Migrations =======
EVM assembly:
/* "contracts/Migrations.sol":26:514 contract Migrations {... */
mstore(0x40, 0x60)
/* "contracts/Migrations.sol":178:236 function Migrations() public {... */
jumpi(tag_1, iszero(callvalue))
0x0
dup1
revert
@maurelian
maurelian / -
Last active March 16, 2018 02:04
pragma solidity ^0.4.10;
contract A {
address alice = 0x14723a09acff6d2a60dcdf7aa4aff308fddc160c;
address bob = 0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db;
function foo() public {
selfdestruct(alice); // alice gets the ETH.
selfdestruct(bob);
}
<html>
<head>
<style type="text/css">
#mynetwork {
background-color: #ffffff;
}
body {
{
"extends": "default",
"rules": {
"reentrancy": false,
"avoid-sha3": false,
"avoid-suicide": false,
"avoid-throw": false,
"func-visibility": false,
"state-visibility": false,
"check-send-result": false,
layout title date
post
easily read private variables
2018-03-29 09:30

I put this together to demonstrate that complete lack of "privacy" provided by labelling a variable private in solidity.

If you want to read a private variable in a solidity contract, and you have the source code, you can do it easily. Here's how:

pragma solidity ^0.4.10;
contract A {
event LogGas(uint);
function foo() {
uint beforeGas = msg.gas;
// emit LogGas(beforeGas);
assembly {
0x5c79d3d994b54f98cedb0c5d9be4842f26e2fe10
Yup: event({_yup: bool})
max_uint_256: public(uint256)
@public
def __init__():
self.max_uint_256 = 2*(2**255-1)+1
@public
def lessThanMaxUint(a: uint256) -> (bool):
@maurelian
maurelian / raw_call_attempts.v.py
Last active June 1, 2018 13:35
Trying to make an external call with vyper
# Attempt 1
other_contract: address
@public
def __init__():
self.other_contract = 0x1111111000000000000000000000000000000000
@public
def foo():
pragma experimental SMTChecker;
// pragma solidity ^0.4.20;
contract Primes {
function prime(uint a, uint b) public pure {
require(1 < a && a < 500);
require(1 < b && b < 25000);
assert(a * b != 23447);
}