Skip to content

Instantly share code, notes, and snippets.

View ilovelili's full-sized avatar
🏠
Working from home

min ju ilovelili

🏠
Working from home
View GitHub Profile

Credential creation flows using the MONiD Library

Introduction

At MONiD we model verifiable credentials using W3C Verifiable credential specification, aside from some very recent spec modifications. Below you can see an example of a credential, serialized as JSON-LD, stating that the did did:monid:ffcc8f84fae1b6ad253561d7b78167a661d72f58e86e60dbd04cd9b81096cdbe is associated with the email address min@monid.io. You might notice that the subject, issuer, and signer of the credential, are the same identity. This can be effectively referred to as a self signed, or self issued, credential.

{
  "@context": [
@ilovelili
ilovelili / auth.go
Last active June 13, 2021 07:52
Z様 OAuth1 integration
package handler
import (
"fmt"
"net/http"
"github.com/labstack/echo"
"github.com/woodstock-tokyo/woodstock-zaim/server/util"
)
@ilovelili
ilovelili / chia-farming.sh
Last active May 5, 2021 10:55
chia farming
# first, install
sudo apt-get update
sudo apt-get upgrade -y
git clone https://github.com/Chia-Network/chia-blockchain.git -b latest
cd chia-blockchain
sh install.sh
. ./activate
msg := &messaging.Message{
Data: map[string]string{
"type": "mention",
"commentId": "1",
"picture": "https://cdn.woodstock.club/logo.png",
"name": "min",
"comment": "you are cool",
},
Notification: &messaging.Notification{
Title: category,
@ilovelili
ilovelili / fcm
Last active April 24, 2021 12:19
fcm send message
msg := &messaging.Message{
APNS: &messaging.APNSConfig{
Headers: map[string]string{
"apns-priority": "10",
},
Payload: &messaging.APNSPayload{
Aps: &messaging.Aps{
Alert: &messaging.ApsAlert{
Title: category,
Body: body,
options = {
closable: true,
autoclose: true,
auth: {
redirectUrl: 'http://localhost:3000',
responseType: 'id_token',
params: {
scope: 'openid profile email', // could you check here?
language: 'en',
},
curl "https://api.woodstock.club/reaction" -X POST -d "{\"comment_id\":"3",\"emoji\":\"U+1F604\"}" -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Im05Rk5kTEdQTGsxb05XbkF6Q0x6diJ9.eyJuaWNrbmFtZSI6InZsYWRpbWlyIiwibmFtZSI6InZsYWRpbWlyQGVnby1jbXMuY29tIiwicGljdHVyZSI6Imh0dHBzOi8vcy5ncmF2YXRhci5jb20vYXZhdGFyL2M3ZWY2MTNkNWRjZGFmMzE5MDIzNzg2ZmY2NWFjNDVhP3M9NDgwJnI9cGcmZD1odHRwcyUzQSUyRiUyRmNkbi5hdXRoMC5jb20lMkZhdmF0YXJzJTJGdmwucG5nIiwidXBkYXRlZF9hdCI6IjIwMjEtMDItMjJUMTM6NTc6MzkuMzk5WiIsImlzcyI6Imh0dHBzOi8vd29vZHN0b2NrLmpwLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw2MDJjZmU5YjgzNTFkNzAwNjkxNzg2YzEiLCJhdWQiOiJnSTZRMU9xVHRBU3BYaEl0N1NHNURIVkFlOFJ5SmdmUCIsImlhdCI6MTYxNDE4MTIyOCwiZXhwIjoxNjE1NjIxMjI4LCJub25jZSI6ImhhZXdISU96YkFNOXgzRzJRLTUwQnlIMXJhcWkzeDBOVGk0QWtxSEtYeG8ifQ.05wiZpYEGE5Tl2c1c1_lHx5QopNiSd72Bzf7H0QsjdUtsZIHXcSyos0fT2eoycQ_g-C-f-hJt9qCK73wAiPK28rJardTiuTQZ8q6wASCTY4YfbhWHw6PdmWB-6CPqLr6WxYhmZOX-EM5GEQ6_Pqcd3ib1Jrt6D88XejtoxBh2ODrKQ5VCPsPUQDCcvT8WFbZtmfRH4Is5J1
-- delete by tweet id
curl -X DELETE "https://api.woodstock.club/reaction?tweetId=1366154339757137922" -H "accept: */*" -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Im05Rk5kTEdQTGsxb05XbkF6Q0x6diJ9.eyJnaXZlbl9uYW1lIjoiV29vZHN0b2NrIiwiZmFtaWx5X25hbWUiOiJDb250YWN0Iiwibmlja25hbWUiOiJjb250YWN0IiwibmFtZSI6Ildvb2RzdG9jayBDb250YWN0IiwicGljdHVyZSI6Imh0dHBzOi8vbGg0Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tSlFSSVY0el9lcDQvQUFBQUFBQUFBQUkvQUFBQUFBQUFBQUEvQU1adXVjbWFuSDA2RjNxcFZiUWVVQzJsSDN0RDNsYkdfQS9zOTYtYy9waG90by5qcGciLCJsb2NhbGUiOiJlbiIsInVwZGF0ZWRfYXQiOiIyMDIxLTAzLTA5VDA4OjM3OjAyLjI3N1oiLCJlbWFpbCI6ImNvbnRhY3RAd29vZHN0b2NrLmNsdWIiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6Ly93b29kc3RvY2suanAuYXV0aDAuY29tLyIsInN1YiI6Imdvb2dsZS1vYXV0aDJ8MTAyNTE4MTAzMjE5NDE2MzIzMzM3IiwiYXVkIjoiZ0k2UTFPcVR0QVNwWGhJdDdTRzVESFZBZThSeUpnZlAiLCJpYXQiOjE2MTUyNzkwMjIsImV4cCI6MTYxNjcxOTAyMn0.vthP5EOUJcnpIYEPh2RkDelNUoIn3e_Pqxnyihuc_QFCUTHzL0KAOk0BJWC7oY8c8S3J4bkPe5ATPMR7LdCcAFfhDNqn_2czxdgqzUo72Xw4WK2aBj5DyKDAn43rCCqfOK
curl "https://api.woodstock.club/user" \
-X PUT \
-d "{\"name\":\"min ju\",\"handler\":\"mj_cool\",\"description\":\"mj is a very cool guy\"}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Im05Rk5kTEdQTGsxb05XbkF6Q0x6diJ9.eyJuaWNrbmFtZSI6ImNvbnRhY3QiLCJuYW1lIjoiY29udGFjdEB3b29kc3RvY2suY2x1YiIsInBpY3R1cmUiOiJodHRwczovL3MuZ3JhdmF0YXIuY29tL2F2YXRhci83ZDk2N2RlZWYzZGNjN2FjMTQ4MzZlYzg0ZmUzYjdkMD9zPTQ4MCZyPXBnJmQ9aHR0cHMlM0ElMkYlMkZjZG4uYXV0aDAuY29tJTJGYXZhdGFycyUyRmNvLnBuZyIsInVwZGF0ZWRfYXQiOiIyMDIxLTAyLTI4VDE0OjM2OjExLjgxM1oiLCJlbWFpbCI6ImNvbnRhY3RAd29vZHN0b2NrLmNsdWIiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6Ly93b29kc3RvY2suanAuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDYwMWU0MTNhNGZhNjAxMDA2YWQwODhiNyIsImF1ZCI6ImdJNlExT3FUdEFTcFhoSXQ3U0c1REhWQWU4UnlKZ2ZQIiwiaWF0IjoxNjE0NTkxNzMyLCJleHAiOjE2MTYwMzE3MzJ9.x5QMf-AK9t1RiWzvDTj5-A6_5sIneLmAEO2TRl4iV9bwbXkV36maNxcdFGgk4dJtPLzKkCxCNXK_pMnARgXJ6mAR-bVlaaIB6A7P8VVXTOdiPVHdjY_8lJW6CncSwkp9IbD3s9Te2WwRVK0c78Ba1
const { ethers } = require("ethers");
const provider = new ethers.providers.JsonRpcProvider("http://0.0.0.0:8545");
// https://info.uniswap.org/pair/0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc
const uniswapUsdtWethExchange = "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc";
// this ABI object works for both Uniswap and SushiSwap
const uniswapAbi = [
"event Swap(address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to)",
];