Skip to content

Instantly share code, notes, and snippets.

View cicorias's full-sized avatar

Shawn Cicoria cicorias

View GitHub Profile
@cicorias
cicorias / web3-solc-contract-compile-deploy.js
Created March 12, 2017 00:06 — forked from tomconte/web3-solc-contract-compile-deploy.js
Compiling and deploying an Ethereum Smart Contract, using solc and web3.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
// Connect to local Ethereum node
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// Compile the source code
const input = fs.readFileSync('Token.sol');
const output = solc.compile(input.toString(), 1);
@cicorias
cicorias / compile-deploy-sign.js
Created March 12, 2017 00:06 — forked from tomconte/compile-deploy-sign.js
Shows how to compile and deploy a Smart Contract using client-side transaction signature, i.e. does not require the account to be unlocked in the Ethereum node.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
const Tx = require('ethereumjs-tx')
// Private key to use to sign the transactions
// To decrypt your private key, use e.g. https://www.myetherwallet.com/#view-wallet-info
// You will find your private key file in e.g. .ethereum/keystore or .parity/keys
// In this example the key should correspond to the web3.eth.coinbase address
var privateKey = new Buffer('088c110b6861b6c6c57461370d661301b29a7570d59cb83c6b4f19ec4b47f642', 'hex')
@cicorias
cicorias / truffle-config.js
Created March 12, 2017 17:06 — forked from tomconte/truffle-config.js
Example Truffle 3.0 configuration file to allow deploying contracts to an Azure "Bletchley" Ethereum consortium network. Based on the Truffle docs for Infura (http://truffleframework.com/tutorials/using-infura-custom-provider).
var bip39 = require("bip39");
var ethwallet = require('ethereumjs-wallet');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
// Insert raw hex private key here, e.g. using MyEtherWallet
var wallet = ethwallet.fromPrivateKey(Buffer.from('324a58ceac32c9a5a465a57a87600c086df72aa4ae0c6beb062436a2b6c0a2a6', 'hex'));
@cicorias
cicorias / mock_notification.js
Created March 14, 2017 09:30 — forked from danfinlay/mock_notification.js
A simple metamask notification code example.
var state = {
imageifyIdenticons: false,
txData: {
"id":1467868023090690,"txParams":{"data":"0xa9059cbb0000000000000000000000008deb4d106090c3eb8f1950f727e87c4f884fb06f0000000000000000000000000000000000000000000000000000000000000064","from":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","value":"0x16345785d8a0000","to":"0xbeb0ed3034c4155f3d16a64a5c5e7c8d4ea9e9c9","origin":"MetaMask","metamaskId":1467868023090690,"metamaskNetworkId":"2"},"time":1467868023090,"status":"unconfirmed","containsDelegateCall":false
},
accounts: {
'0xfdea65c8e26263f6d9a1b5de9555d2931a33b825': {
balance: "0x15e578bd8e9c8000",
}
},
contract EternalStorage{
mapping(bytes32 => uint) UIntStorage;
function getUIntValue(bytes32 record) constant returns (uint){
return UIntStorage[record];
}
function setUIntValue(bytes32 record, uint value)
{
import "EternalStorage.sol";
library ProposalsLibrary {
function getProposalCount(address _storageContract) constant returns(uint256)
{
return EternalStorage(_storageContract).getUIntValue(sha3("ProposalCount"));
}
function addProposal(address _storageContract, bytes32 _name)
import "ProposalsLibrary.sol";
contract Organisation
{
using ProposalsLibrary for address;
address public eternalStorage;
function Organisation(address _eternalStorage) {
eternalStorage = _eternalStorage;
}
import "ITokenLedger.sol";
contract Organisation
{
ITokenLedger public tokenLedger;
function Organisation(address _tokenLedger) {
tokenLedger = ITokenLedger(_tokenLedger);
}
contract ITokenLedger {
function generateTokens(uint256 _amount) {}
}
contract TokenLedger {
uint256 total_supply;
mapping (address => uint256) balances;
function generateTokens(uint256 _amount)
import "ITokenLedger.sol";
import "ProposalsLibrary.sol";
contract Organisation
{
ITokenLedger public tokenLedger;
using ProposalsLibrary for address;
address public eternalStorage;
function Organisation(address _tokenLedger, address _eternalStorage) {