This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/base64" | |
"fmt" | |
"io" | |
"net/http" | |
"runtime/debug" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Address, beginCell } from "@ton/ton"; | |
import { mnemonicToPrivateKey, sign, sha256, signVerify } from "@ton/crypto"; | |
import assert from "assert"; | |
// Type | |
type LessThan<N extends number, A extends any[] = []> = N extends A['length'] ? A[number] : LessThan<N, [...A, A['length']]>; | |
type RangeOf<F extends number, T extends number> = Exclude<T | LessThan<T>, LessThan<F>> | |
type AtomicType = `int${RangeOf<0, 257>}` | `uint${RangeOf<0, 256>}` | "slice" | "cell"; | |
type TypeDefinition = Record<string, Array<{ name: string, type: string | AtomicType }>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; Example verifying signature smart contract in FunC | |
;; | |
;; | |
;; Storage layout | |
;; | |
;; uint256 public key: Signer's public key | |
;; uint32 nonce: A monotonic increasing uint counter starting from zero | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity 0.8.17; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
contract MyToken is ERC20 { | |
constructor() ERC20("MyToken", "MTK") {} | |
function mint(address to, uint256 amount) public { | |
_mint(to, amount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity 0.8.17; | |
/** | |
* Generate UUID strings from `block.difficulty`, i.e., `block.prevrandao` | |
* | |
* UUID follows RFC4122 Version-4 Variant-1 (DCE 1.1, ISO/IEC 11578:1996) | |
* | |
* See more at https://datatracker.ietf.org/doc/html/rfc4122.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.17; | |
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; | |
contract C { | |
struct MerkleRoot { | |
bytes32 data; | |
bytes32 signatures; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.1; | |
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
/** | |
* @dev | |
* Purpose: Retrieve an `uint256` random number secured by Chainlink VRF v1 | |
* Usage example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import string | |
##### Helper function ##### | |
ssz_byteorder = "little" # https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md | |
# https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#aliases | |
def isBytesN(input_): | |
# BytesN := Vector[uint8, N] | |
assert isinstance(input_, list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import | |
const Web3 = require("web3"); | |
// Constants | |
const USDC_mainnet = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; | |
const Provider_URL = "wss://eth-mainnet.alchemyapi.io/v2/"; | |
async function eventSubscribe() { | |
const web3 = new Web3(Provider_URL); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from web3 import Web3 # Use version 5.29.2 | |
from web3.middleware import geth_poa_middleware | |
import json | |
class CONST: | |
def ABI(): | |
with open("./WrappedEther.json") as f: | |
return json.load(f) | |
NodeProvider = lambda : "https://" | |
WrappedEther = lambda : "" |
NewerOlder