Skip to content

Instantly share code, notes, and snippets.

View howardpen9's full-sized avatar
💭
I may be slow to respond.

Howard Peng howardpen9

💭
I may be slow to respond.
View GitHub Profile
@howardpen9
howardpen9 / check.ts
Created September 6, 2023 02:27 — forked from TrueCarry/check.ts
TON Connect V2 Proof verification
async function check(req, res) {
const walletInfo = req.body.walletInfo as Wallet
if (!walletInfo?.connectItems?.tonProof) {
return res.status(httpStatus.BAD_REQUEST).send({ ok: false })
}
const proof = walletInfo.connectItems.tonProof as TonProofItemReplySuccess
if (!proof) {
return res.status(httpStatus.BAD_REQUEST).send({ ok: false })
}
pragma solidity >=0.4.2 <0.6.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint vote;
}
mapping(address => Voter) voters;
@howardpen9
howardpen9 / README.txt
Created March 3, 2022 06:40
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.5.17+commit.d19bba13.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads for the very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
@howardpen9
howardpen9 / [Example] StudentScore.sol
Created February 17, 2022 05:29
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.7.6+commit.7338295f.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
contract StudentScore {
mapping (string => uint) scores;
string[] names;
function addScore(string memory name, uint256 score) public {
scores[name] = score; // mapping declare
@howardpen9
howardpen9 / pullJSON.js
Last active July 27, 2021 02:21
Defillama API Fetch
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("TVL_Protocol");
var url = "https://api.llama.fi/protocols"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var dataSet = dataAll;
const dt = new Date()