Skip to content

Instantly share code, notes, and snippets.

View ethereumdegen's full-sized avatar

Ethereumdegen ethereumdegen

View GitHub Profile
@ethereumdegen
ethereumdegen / gist:6f39177d9d4d35cbbe89
Created March 11, 2016 21:34
Call Logger New Call Form with JS Autocompleting
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">New Call</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<div class="row">
<div class="col-lg-12">
@ethereumdegen
ethereumdegen / gist:79daee3b41e47596e36286464b1d98dd
Created July 31, 2017 14:46
Web3 Function Call for Cryptopunks Smart Contract
//Load Cryptopunks contract and print the owner for each one - takes a long long time and freezes!
var PunkContract = web3.eth.contract(contract_abi);
var contractInstance = PunkContract.at('0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB');
var punk_id = 0;
for(punk_id=0;punk_id<10000;punk_id++)
{
$(".new-goods-submit-button").on('click',function(){
console.log('submitting goood');
//get hash of the good
var file_unique_hash = $("#good_file_input").data('uniquehash');
var file_name = "canoe";
var file_description = "a wooden boat";
pragma solidity ^0.4.18;
library ECRecovery {
/**
* @dev Recover signer address from a message by using their signature
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
* @param sig bytes signature, the signature is generated using web3.eth.sign()
*/
function recover(bytes32 hash, bytes sig) public pure returns (address) {
pragma solidity ^0.4.18;
// File: contracts/ECRecovery.sol
library ECRecovery {
/**
* @dev Recover signer address from a message by using their signature
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
* @param sig bytes signature, the signature is generated using web3.eth.sign()
@ethereumdegen
ethereumdegen / Bitcoinereum source
Last active October 29, 2018 19:12
Bitcoinereum Source Code Critique
contract Bitcoinereum {
string public symbol = "BTCM";
string public name = "Bitcoinereum";
uint8 public constant decimals = 8;
uint256 _totalSupply = 0;
uint256 _maxTotalSupply = 2100000000000000;
uint256 _miningReward = 100000000; //1 BTCM - To be halved every 4 years
uint256 _maxMiningReward = 5000000000; //50 BTCM - To be halved every 4 years
uint256 _rewardHalvingTimePeriod = 126227704; //4 years
uint256 _nextRewardHalving = now + _rewardHalvingTimePeriod;
@ethereumdegen
ethereumdegen / Metamask Permission Request Async Code
Last active November 10, 2018 19:50
Metamask Permission Request Async Code
static async detectInjectedWeb3( )
{
return new Promise(async function(resolve, reject) {
// window.addEventListener('load', async () => {
// Modern dapp browsers...
@ethereumdegen
ethereumdegen / DeployedContractInfo.json
Last active June 14, 2019 15:52
A series of methods for querying the 0xBTC token using Web3
{
"networks": {
"mainnet": {
"contracts": {
"_0xbitcointoken": {"name":"0xBitcoinToken", "blockchain_address":"0xb6ed7644c69416d67b522e20bc294a9a9b405b31"},
"batchedpayments": {"name":"BatchedPayments", "blockchain_address":"0xebf6245689194a6e43096551567827c6726ede0b"},
"mintforwarder":{"name":"MintHelper", "blockchain_address":"0xf118fde3f634e5c47638030ab0514debf39465d1"}
}
},
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
@ethereumdegen
ethereumdegen / Solidity To Lower
Created November 15, 2018 21:46
ottodevs/StringToLower.sol
function _toLower(string str) internal returns (string) {
bytes memory bStr = bytes(str);
bytes memory bLower = new bytes(bStr.length);
for (uint i = 0; i < bStr.length; i++) {
// Uppercase character...
if ((bStr[i] >= 65) && (bStr[i] <= 90)) {
// So we add 32 to make it lowercase
bLower[i] = bytes1(int(bStr[i]) + 32);
} else {
bLower[i] = bStr[i];