Skip to content

Instantly share code, notes, and snippets.

View lucashenning's full-sized avatar
🌴
Miami

Lucas H. lucashenning

🌴
Miami
View GitHub Profile
@lucashenning
lucashenning / signSendTx.ts
Created November 3, 2020 11:38
Signing and sending a Tx using AWS KMS
const web3 = new Web3(new Web3.providers.HttpProvider("https://kovan.infura.io/v3/<your key>"));
let pubKey = await getPublicKey(keyId);
let ethAddr = getEthereumAddress((pubKey.PublicKey as Buffer));
let ethAddrHash = ethutil.keccak(Buffer.from(ethAddr));
// signing the 1st time
// we're signing the hash of our ethereum address
let sig = await findEthereumSig(ethAddrHash);
let recoveredPubAddr = findRightKey(ethAddrHash, sig.r, sig.s, ethAddr);
@lucashenning
lucashenning / 01_install_libs.sh
Created September 6, 2022 23:06
Postdeploy platform hook for puppeteer on Amazon Linux 2 (Elastic Beanstalk)
#!/bin/bash
# Put this in your Amazon Elastic Beanstalk repo
# Tested on Amazon Linux 2, Node.JS v16, puppeteer v15.3.0
# File path: .platform/hooks/postdeploy/01_install_libs.sh
sudo amazon-linux-extras install epel -y
cd node_modules/puppeteer/
cd .local-chromium/linux-*/chrome-linux
@lucashenning
lucashenning / SocialLock_withdraw.sol
Created March 31, 2023 16:28
withdraw function in socialLock.sol
function withdraw(string memory headerJson, string memory payloadJson, bytes memory signature, uint amount) public {
// validate JWT
string memory email = validateJwt(headerJson, payloadJson, signature);
bytes32 emailHash = keccak256(abi.encodePacked(email));
// balance check
// this uses the email address from the Google JWT to check if there is a balance for this email
require(balances[emailHash] > 0, "No balance for this email");
require(balances[emailHash] >= amount, "Not enough balance for this email");