Skip to content

Instantly share code, notes, and snippets.

View raineorshine's full-sized avatar

Raine Revere raineorshine

  • New York, NY
View GitHub Profile
@raineorshine
raineorshine / camelCase-solidity
Created August 9, 2016 21:26
Convert Solidity function calls to camelCase
Find: function ([A-Z])
Replace: function \l\1
Find: \.(.)([^(\n]*)\(
Replace: .\l\1\2(
@raineorshine
raineorshine / dynamic-type-error2.sol
Created August 5, 2016 15:59
VM cannot read variable-sized data from external function calls.
contract A {
bytes8[] stuff;
function get() constant returns(bytes8[]) {
return stuff;
}
}
contract B {
A a;
bytes8[] mystuff;
contract A {
A other;
function Assign(address a) {
other = A(a);
}
function Get() constant returns(bytes8[]) {
bytes8[] stuff;
return stuff;
}
function Copy() {
@raineorshine
raineorshine / solidity-resources-and-tools.md
Created July 27, 2016 14:33
Solidity Resources & Tools

Best practices and tools are a bit scattered, and of course very much a work in progress since the community is still developing. You may be disappointed to find that there is not a cohesive, centralized set of best practices and workflow. My personal opinion is that truffle offers one of the most cohesive development experiences today, although over time you will likely find yourself doing most of your work one level of abstraction down: at the web3 layer. Here are some resources and tools that I have found useful.

Resources

Frameworks

@raineorshine
raineorshine / public-mapping.sol
Created July 11, 2016 16:25
Solidity demo: Access a public mapping from a separate contract.
contract A {
mapping(uint => uint) public objects;
function B() {
objects[0] = 42;
}
}
contract B {
// insert address of deployed First here
@raineorshine
raineorshine / Bank.sol.js
Created July 6, 2016 23:21
Experimental Solidity FP contract abstraction
const merge = require('lodash.merge')
const mapObject = require('lodash.map')
const out = value => ({ type: 'RETURN', value })
const update = state => ({ type: 'UPDATE', state })
const mapEffect = effects => {
}
class Bank {
@raineorshine
raineorshine / MyContract.sol
Last active August 18, 2020 06:19
Generate an AST for an Ethereum Solidity contract with the solidity-parser module.
contract MyContract {
uint counter = 0;
function Count() {
counter++;
}
function CallCount() {
Count();
}
@raineorshine
raineorshine / testnet-faucet.url
Created June 30, 2016 23:38
Ethereum Morden testnet faucet
http://icarus.parity.io/rain/0xa27528827086ab45b9ce5994aef86cfd39e6a617
@raineorshine
raineorshine / ArrayUtil.sol
Created June 29, 2016 18:23
A Solidity library to remove elements from an array.
library ArrayUtil {
/** Finds the index of a given value in an array. */
function IndexOf(uint[] values, uint value) returns(uint) {
uint i = 0;
while (values[i] != value) {
i++;
}
return i;
}
@raineorshine
raineorshine / geth-testnet.sh
Last active June 30, 2016 00:01
Start geth with testnet
geth --networkid "2" --datadir ~/.geth --password ~/.geth/testNetPassword --unlock "0,1,2" --testnet --fast --mine --maxpeers 25 --rpc --rpccorsdomain "*" --rpcaddr "127.0.0.1" --rpcport "8545" --etherbase "2" --verbosity "3” console
geth --rpcaddr=127.0.0.1 --rpccorsdomain="*" --rpcport=8545