Skip to content

Instantly share code, notes, and snippets.

View gist:f99f97e625c44003ff8dd6806e066430
import axios from "axios";
import { ethers } from "ethers";
import fs from "fs";
import WawaNFT from "../lambda-fn/utility/abi/WawaNFT.json";
async function fetchMetadata() {
const provider = new ethers.providers.AlchemyProvider("homestead", "<ALCHEMY_API_KEY_ETH>");
const contractAddress = "0x2d9181b954736971bb74043d4782dfe93b55a9af";
View daily-logic
import { secretId } from "@env";
import { successResponse } from "@object-helpers/apiResponse";
import { createCoupon, generateHashBuffer, serializeCoupon } from "@object-helpers/coupons";
import { getSigKeyfromKMS } from "@utility/getSigKeyfromKMS";
import { simpleRateLimit } from "@utility/rateLimiter";
import { getSecret } from "@utility/secret";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
import axios from "axios";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
View polygon_verify_tx
import { secretId } from "@env";
import { notVerifyResponse, successResponse } from "@object-helpers/apiResponse";
import { createCoupon, generateHashBuffer, serializeCoupon } from "@object-helpers/coupons";
import { getSecret } from "@object-helpers/phiUtils";
import { getSigKeyfromKMS } from "@utility/getSigKeyfromKMS";
import { simpleRateLimit } from "@utility/rateLimiter";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
import axios from "axios";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
View quest_object_memo
// Updated 2023/5/3
// This note is a memo to share the method of verifying quest objects.
// If any correction is needed in the logic, please contact the PHI team.
-------------- PHI --------------
// Related Contract links
// PhiMap: '0xe8b6395d223C9D3D85e162f2cb2023bC9088a908',
// Polygonscan: https://polygonscan.com/address/0xe8b6395d223C9D3D85e162f2cb2023bC9088a908
// Registry: '0x6532B97295a0728880AE81D5CD7248f32E24e39a',
View curve-pool
const abi = [
{
stateMutability: "view",
type: "function",
name: "pool_count",
inputs: [],
outputs: [
{
name: "",
type: "uint256",
View cachedContractCall.ts
import { targetEnv, isLocal } from "../env";
import { getCache, putCache } from "./ddbCache";
const TABLE_NAME = "cache-" + targetEnv;
const DEFAULT_TTL = 90000;
export type CachedContractCallOptions = {
tableName?: string;
ttl?: number;
toJson?: boolean;
View subdomain.ts
import { sha3 } from "web3-utils";
import contractAbi from "./abi/ENS.json";
const namehash = require("@ensdomains/eth-ens-namehash");
// Config
/* -------------------------------------------------------------------------- */
const secretkey ="<0x123456>"
const INFURA_API_KEY ="<aaaaa>"
// Definitely long strings (ex. phiphi0320102081028) causes this problem 0x problem.
View ballot.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
View Hello World
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract HelloWorld {
uint256 number;
/**
* @dev Store value in variable