Skip to content

Instantly share code, notes, and snippets.

View zoernert's full-sized avatar

Thorsten Zoerner zoernert

View GitHub Profile
@zoernert
zoernert / app.js
Created July 11, 2024 11:54
Sample Usage of Cori-Wallet (Tracking of Scope2 footprint data derived from smart meter readings)
const coriwallet = new CoriWallet("https://app.gruenstromindex.de/assets/js/deployment.json");
await coriwallet.waitInit();
console.log("Your Wallet:",coriwallet.wallet.address);
// add a Meter to account
await coriwallet.addTracker({
zip: '69256',
ownerId: coriwallet.wallet.address,
name: 'TestMeter',
reading: 1234, // Initial Meter Reading in Wh
const testJWT = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE2NDI4OTI4MDcsInNjaGVtYXMiOiJ7XCIweDc5YTVkNGNmODAzMDE2MzUyNjE0YjY0Y2FiNzRlOGViMzg2YzhjMDc1NzRiOTA2YWM0NDljNThlYWZlYmUzZmJcIjp7XCIkaWRcIjpcImh0dHBzOi8vY29ycmVudGx5LmlvL3NjaGVtYXMvdGVzdC5zY2hlbWEuYXBwbGUuanNvblwiLFwidHlwZVwiOlwib2JqZWN0XCIsXCJwcm9wZXJ0aWVzXCI6e1wiY3VsdGl2YXJcIjp7XCJ0eXBlXCI6XCJzdHJpbmdcIixcInRpdGxlXCI6XCJDdWx0aXZhclwiLFwiZGVzY3JpcHRpb25cIjpcIlR5cGUgb2YgQXBwbGVcIixcImVudW1cIjpbXCJBYnJhbVwiLFwiVGFtcGxpblwiLFwiTXV0c3VcIixcIkNvbGxpbnNcIl19fSxcInJlcXVpcmVkXCI6W1wiY3VsdGl2YXJcIl19fSIsIl91cGRhdGUiOjE2NDI4OTI4MDcwMzcsImlzcyI6ImRpZDpldGhyOm1haW5uZXQ6MHg5MWI1RDU1NjNEMzgwMEMyRjVmMjAzRjI1ODc1OTJGNjMzZGFERDJGIn0.d-4uti9HJ6tooIX1Fq6fwtHtnPNKNQxfM_Ko69IQsXphIC0g2L-6iztxrxKLt9DDR07aBI_ao86HE7ovX-c3IwA';
const testCase = async function() {
const Resolver = require('did-resolver').Resolver;
const getResolver = require('ethr-did-resolver').getResolver;
const EthrDID = require("ethr-did").EthrDID;
const keypair = EthrDID.createKey
[{"id":"f49c358b4572fd08","type":"tab","label":"Presentation Processing Service","disabled":false,"info":""},{"id":"764d580198897741","type":"inject","z":"f49c358b4572fd08","name":"Buy MegaConcert Ticket","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"presentation\":{\"event\":\"Mega_Concert\"}}","payloadType":"json","x":290,"y":100,"wires":[["21a21a1a48693112"]]},{"id":"44e447f634fac332","type":"debug","z":"f49c358b4572fd08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":100,"wires":[]},{"id":"4b4e807405b829ab","type":"http in","z":"f49c358b4572fd08","name":"eventPPS","url":"/eventPPS","method":"post","upload":false,"swaggerDoc":"","x":230,"y":260,"wires":[["d48f85ab901d192c"]]},{"id":"bed8ba713113f368","type":"debug","z":"f49c358b4572fd08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","st
@zoernert
zoernert / step2.json
Created January 5, 2022 13:03
Sample Flow
[{"id":"db85efb31b8d6c63","type":"tab","label":"Presentation Processing Service","disabled":false,"info":""},{"id":"bc8ea23eafbd50c9","type":"SmartContract","z":"db85efb31b8d6c63","name":"Alice","Connection":"709fcd56ae2bfcc5","Contract":"446e716af8a146aa","Resolver":"79856bb80496c409","AllowInject":"","RetryTX":true,"rapidAPIkey":"","pps":"","x":490,"y":100,"wires":[[],[],["902e10e94df6036e"],[]]},{"id":"55bf9f3bf037d791","type":"inject","z":"db85efb31b8d6c63","name":"Buy MegaConcert Ticket","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"presentation\":{\"event\":\"Mega Concert\"}}","payloadType":"json","x":290,"y":100,"wires":[["bc8ea23eafbd50c9"]]},{"id":"902e10e94df6036e","type":"SmartContract","z":"db85efb31b8d6c63","name":"TicketA","Connection":"d26ccfb316876b3e","Contract":"446e716af8a146aa","Resolver":"79856bb80496c409","AllowInject":"","RetryTX":true,"rapidAPIkey":"","pps":"http://localhost:1880/eventPPS","x":680,"y":1
@zoernert
zoernert / step1.json
Created January 5, 2022 12:34
Sample Flow
[{"id":"db85efb31b8d6c63","type":"tab","label":"Presentation Processing Service","disabled":false,"info":""},{"id":"bc8ea23eafbd50c9","type":"SmartContract","z":"db85efb31b8d6c63","name":"Alice","Connection":"709fcd56ae2bfcc5","Contract":"446e716af8a146aa","Resolver":"79856bb80496c409","AllowInject":"","RetryTX":true,"rapidAPIkey":"","pps":"","x":490,"y":100,"wires":[[],[],["8b80cd4520f6c3f6"],[]]},{"id":"55bf9f3bf037d791","type":"inject","z":"db85efb31b8d6c63","name":"Buy MegaConcert Ticket","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"presentation\":{\"event\":\"Mega Concert\"}}","payloadType":"json","x":290,"y":100,"wires":[["bc8ea23eafbd50c9"]]},{"id":"8b80cd4520f6c3f6","type":"debug","z":"db85efb31b8d6c63","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":100,"wires":[]},{"id":"709fcd56ae2bfcc5","type":"DLTConnection","name":"Integr
@zoernert
zoernert / contracts...espledger.sol
Created December 29, 2021 11:56
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.11+commit.d7f03943.js&optimize=true&runs=200&gist=
pragma solidity ^0.8.0;
contract espledger {
mapping (address => uint256) public balanceDebit;
mapping (address => uint256) public balanceCredit;
uint256 public totalSupply = 0;
@zoernert
zoernert / contracts...espaccounting.sol
Created December 29, 2021 11:54
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.11+commit.d7f03943.js&optimize=true&runs=200&gist=
pragma solidity ^0.8.0;
import "./espledger.sol";
contract espaccounting {
mapping (address => espledger) public ledgers;
function transfer(address from,address to, uint256 value) public returns (bool success) {
espledger ledger = ledgers[msg.sender];
@zoernert
zoernert / openapi3.yaml
Created October 5, 2021 01:53
ID-Ideal AP8 - CO2 Event - Structure Definition
openapi: 3.0.0
info:
title: ID-Ideal - AP8
description: >
Sample Requests using the [Corrently Ecosystem](https://corrently.io) as implementation. You might get an `account` using the [Create Stromkonto Endpoint](https://api.corrently.io/v2.0/stromkonto/create) or use one from an existing eWallet.
[![Run in Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/15081091-766401d6-06c2-47a3-bb3e-35aac41992d9?action=collection%2Ffork&collection-url=entityId%3D15081091-766401d6-06c2-47a3-bb3e-35aac41992d9%26entityType%3Dcollection%26workspaceId%3D9bdc41fc-ebac-4de7-96fb-4e7650494186)
contact: {}
version: '1.0'
@zoernert
zoernert / RunInPostman.md
Created October 4, 2021 14:39
CO2 Offset in Postman

Run in Postman

@zoernert
zoernert / runkit.js
Created September 16, 2021 23:06
Runkit implementation of Sendgrid CO2 Offset Script
const app = async function() {
const sendgridAPIKey = process.env.sendgridAPIKey;
const rapidAPIKey = process.env.rapidAPIKey;
const fromDate = new Date(new Date().getTime() - (7*87600000)).toISOString().split('T')[0]; // last 7 days
const axios = require("axios");
// Retrieve Statistics from Sendgrid