Skip to content

Instantly share code, notes, and snippets.

View MagRelo's full-sized avatar

Matt Lovan MagRelo

View GitHub Profile
@MagRelo
MagRelo / index.js
Last active July 3, 2024 11:38
local websocket connection to ganache-cli
const Web3 = require('web3')
// *WRONG*
// const localProviderUrl = 'wss://localhost:8545'
// Result:
//
// connection not open on send()
// Error in subscription wss://localhost:8545
// Error: connection not open
@MagRelo
MagRelo / client_side.js
Last active April 8, 2018 22:13
Sign a message using Web3 and send it to the server
import Web3 from 'web3'
// Setup a message with instructions for the server.
const messageData = [
{
name: ‘Contents’,
type: ‘string’,
value: 'extra! extra! read all about it!'
}
]
const sigUtil = require('eth-sig-util')
app.post('/api/message', (req, res) => {
const messageData = req.body.messageData
const signature = req.body.signature
// recover the public key
const publicKey = sigUtil.recoverTypedSignature({
data: messageData,
@MagRelo
MagRelo / gist:a037d987579867bbfa14b3aabc282142
Created June 22, 2018 16:59
server error using 'shrugs/gnarly-test:demo' image
gnarly-5f7885c68-5686g — TypeError: Cannot read property 'owner' of undefined
gnarly-5f7885c68-5686g — at Object.replace (/snapshot/gnarly/node_modules/@xlnt/fast-json-patch/lib/core.js:27:26)
gnarly-5f7885c68-5686g — at applyOperation (/snapshot/gnarly/node_modules/@xlnt/fast-json-patch/lib/core.js:231:60)
gnarly-5f7885c68-5686g — at Object.applyPatch (/snapshot/gnarly/node_modules/@xlnt/fast-json-patch/lib/core.js:268:22)
gnarly-5f7885c68-5686g — at __dirname.resumeFromTxId.txBatch.forEach (/snapshot/gnarly/node_modules/@xlnt/gnarly-core/lib/Ourbit.js:134:43)
gnarly-5f7885c68-5686g — at Array.forEach (<anonymous>)
gnarly-5f7885c68-5686g — at Ourbit.<anonymous> (/snapshot/gnarly/node_modules/@xlnt/gnarly-core/lib/Ourbit.js:130:29)
gnarly-5f7885c68-5686g — at Generator.next (<anonymous>)
gnarly-5f7885c68-5686g — at fulfilled (/snapshot/gnarly/node_modules/@xlnt/gnarly-core/lib/Ourbit.js:4:58)
gnarly-5f7885c68-5686g — at <anonymous> 'TypeError: Cannot read property \'owner\' of undefined\n at Object.replace (/
@MagRelo
MagRelo / social cards
Created October 22, 2018 17:13
a list of values to dynamically put into the HEAD section of your webpages to enable rich embeds on twitter, facebook, etc.
<!-- openGraph -->
<meta property="fb:app_id" content="381364391963677"/>
<meta property="og:site_name" content="Spoon University"/>
<meta property="og:type" content="article"/>
<meta property="og:url" content="https://spoonuniversity.com/lifestyle/i-went-pescatarian-for-a-month-and-it-wasn-t-that-hard"/>
<meta property="og:title" content="I Went Pescatarian For a Month And It Wasn&#x27;t That Hard"/>
<meta property="og:description" content="A month with no meat can seem like a terrifying restriction, but once put into practice, you may discover that it is an opportunity to be exposed to new flavors, techniques and styles of food!"/>
<meta property="og:image" content="https://s3.amazonaws.com/secretsaucefiles/photos/images/000/147/466/large/poke_bowl_by_nancy_goa.jpg?1489081470"/>
<meta property="og:image:secure_url" content="https://s3.amazonaws.com/secretsaucefiles/photos/images/000/147/466/large/poke_bowl_by_nancy_goa.jpg?1489081470"/>
const sigUtil = require('eth-sig-util');
const { checkUserMembership } = require('./pg-controller');
function recover(message, signature) {
return sigUtil.recoverPersonalSignature({
data: message,
sig: signature
});
}
async function getLeaderboard() {
try {
// get tournament ID from server
const tournamentData = await fetch('/api/data').then(async response => {
if (response.status !== 200) throw Error('API error - request');
return response.json();
});
if (!tournamentData.tournamentId) throw Error('API error - data');
console.log('Tournament Code:', tournamentData.tournamentId);
{
"tokenId": "56967430895675811679808265096816440670731486143859213145439561619809262108673",
"tokenAddress": "0xfaee4b062449a24a3d0f211d08caac43ee3a1d9b",
"name": "Beach 1",
"description": "Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1Beach 1",
"owner": {
"user": {
"username": "NullAddress"
},
"profile_img_url": "https://storage.googleapis.com/opensea-static/opensea-profile/1.png",
{
"tokenId": "4",
"tokenAddress": "0x91f16f2b28d96c3d1a3202b574fc05e749defb6c",
"name": "WizardZ",
"description": "WizardZ is a zombie wizard collectible artwork.",
"owner": {
"user": {
"username": null
},
"profile_img_url": "https://storage.googleapis.com/opensea-static/opensea-profile/8.png",
{
firstFans: [], // sorted by reverse chronological; how many?
topFans: [], // sorted by ra, how many?
uniqueBidders: [], //do we need/want this?
topBids: [], // how many?
asset: {},
nextBid: {number}
}