Skip to content

Instantly share code, notes, and snippets.

View ayinot's full-sized avatar

skygirl ayinot

  • Singapore
View GitHub Profile
pragma solidity ^0.4.2;
contract MyFile {
uint public govtrail = 100000;
uint public agenttrail = 100000;
uint public migtrail = 100000;
mapping(address => Government) govdetails;
address[] public governmentaccounts;
@ayinot
ayinot / MappedStructsWithIndex.sol
Created February 14, 2018 09:09 — forked from anonymous/MappedStructsWithIndex.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
contract MappedStructsWithIndex {
struct EntityStruct {
uint entityData;
bool isEntity;
}
mapping(address => EntityStruct) public entityStructs;
address[] public entityList;
@ayinot
ayinot / retail.sol
Last active February 15, 2018 00:05
E-commerce Payment
pragma solidity ^0.4.2;
contract retail {
address public admin;
uint public count=0;
// a constructor to set the admin i.e the person who deploys the contract
function retail() {
admin= msg.sender;
}
@ayinot
ayinot / retail.js
Created February 15, 2018 12:14
E-commerce Payment
const express=require('express'); // importing express js framework
const Web3=require('web3'); //initiating web3
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); // connect to blockchain using web3
const bodyParser=require('body-parser'); // pasrsing the encoded format
const app=express(); //loading the express object
//loading the abi for the contract
var retailContract = web3.eth.contract([{"constant":true,"inputs":[{"name":"itemId","type":"uint256"}],"name":"isSold","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getItemList","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"count","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"itemId","type":"uint256"}],"name":"getItem","outputs":[{"name":"","type":"uint256"
@ayinot
ayinot / FunctionModifiers.sol
Created March 11, 2018 10:27
A contract to understand Function Modifers
pragma solidity ^0.4.15;
//@Title to understand FunctionModifiers
//@Author Toniya <toniya.sundaram@gmail.com>
// It changes the behaviour of the function
//Eg Contract kill function should only be called by the admin
contract FunctionModifiers {
pragma solidity ^0.4.15;
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
contract MultiSigWallet {
/*
* Events
*/
pragma solidity ^0.4.18;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
@ayinot
ayinot / Proxy.sol
Created April 4, 2018 14:52
Related to Contract Upgradation
pragma solidity ^0.4.18;
import "./Ownable.sol";
contract Proxy is Ownable {
event Upgraded(address indexed implementation);
address internal _implementation;
@ayinot
ayinot / ShrimpCoin.sol
Created April 4, 2018 14:53
Related to contract upgradation
pragma solidity ^0.4.18;
import "./Proxy.sol";
import "./SafeMath.sol";
contract KeyValueStorage {
mapping(address => mapping(bytes32 => uint256)) _uintStorage;
mapping(address => mapping(bytes32 => address)) _addressStorage;
mapping(address => mapping(bytes32 => bool)) _boolStorage;
@ayinot
ayinot / MintableTokenDelegate.sol
Created April 4, 2018 14:54
related to contract upgradation
pragma solidity ^0.4.18;
import "./ShrimpCoin.sol";
contract MintableTokenDelegate is TokenDelegate {
modifier onlyOwner {
require(msg.sender == _storage.getAddress("owner"));
_;
}