Skip to content

Instantly share code, notes, and snippets.

View ayinot's full-sized avatar

skygirl ayinot

  • Singapore
View GitHub Profile
contract KeyValueStorage {
mapping(address => mapping(bytes32 => uint256)) _uintStorage;
mapping(address => mapping(bytes32 => address)) _addressStorage;
mapping(address => mapping(bytes32 => bool)) _boolStorage;
/**** Get Methods ***********/
function getAddress(bytes32 key) public view returns (address) {
return _addressStorage[msg.sender][key];
pragma solidity ^0.4.0;
import "./KeyValueStorage.sol";
import './StorageConsumer.sol';
import './Proxy.sol';
contract StoreNumber is StorageConsumer, Proxy {
function StoreNumber(KeyValueStorage storage_)
public
StorageConsumer(storage_)
{
pragma solidity ^0.4.18;
import "./Ownable.sol";
contract Proxy is Ownable {
event Upgraded(address indexed implementation);
address internal _implementation;
pragma solidity ^0.4.18;
import "./KeyValueStorage.sol";
import "./StorageStateful.sol";
import "./KeyValueStorage.sol";
contract StorageConsumer is StorageStateful {
function StorageConsumer(KeyValueStorage storage_) public {
_storage = storage_;
}
pragma solidity ^0.4.0;
import "./StorageStateful.sol";
contract NumberLogicV1 is StorageStateful{
function setNumber(uint _number) public {
_storage.setUint("MyNumber", 20*_number);
}
pragma solidity ^0.4.0;
import "./StorageStateful.sol";
contract NumberLogicV2 is StorageStateful{
function getNumber()public returns(uint){
return _storage.getUint("MyNumber");
}
}
import _ from 'lodash' // importing extend library from javascript
import { expect } from 'chai' // importing mocha chai library for unit testing
import { web3 } from './helpers/w3' // importing w3 script from helpers to import w3 functions
import expectRevert from './helpers/expectRevert'
const accounts = web3.eth.accounts
const KeyValueStorage = artifacts.require("KeyValueStorage"); //eternal storage contract
const NumberLogicV1 = artifacts.require("NumberLogicV1"); //Implementation v1
@ayinot
ayinot / Parsing.sol
Created May 2, 2018 04:37
Parsing the TxnInput
contract Parsing {
function callNumber(uint256 number) public view returns(bytes32){
bytes32 hash = keccak256("callNumber(uint256)");
return hash;
}
function callAddress(address _addr) public view returns(bytes32){
bytes32 hash = keccak256("callAddress(address _addr)");
return hash;
pragma solidity ^0.4.23;
contract Test {
bytes public result;
function saveArgs(uint arg1,bool arg2, string arg3, address arg4) public returns(bytes4){
return this.saveArgs.selector;
}
function encodeMe(bytes4 selector, uint arg1,bool arg2, string arg3, address arg4) returns(bytes){
pragma solidity ^0.4.19;
contract Interchain {
bytes public selector;
bytes public destHash;
function withdrawal(bytes32 destHash) returns(bytes4){
return this.withdrawal.selector;