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
'use client'; | |
import { useState } from "react" | |
export default function Todo() { | |
const [todos, setTodos] = useState([ | |
{ id: 1, name: "Go to Fitness", time: 1.5 }, | |
{ id: 2, name: "Have lunch", time: 1 }, | |
{ id: 3, name: "Writing code", time: 2 }, |
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: MIT | |
// File: @openzeppelin/contracts/utils/Context.sol | |
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol) | |
pragma solidity ^0.8.0; | |
/** |
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: MIT | |
pragma solidity ^0.8.14; | |
import "@openzeppelin/contracts/utils/Create2.sol"; | |
contract Dog { | |
uint8 public age; | |
constructor(uint8 _age) { | |
age = _age; | |
} | |
} |
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 { useState, useEffect } from 'react' | |
import {ethers} from 'ethers'; | |
// import './App.css' | |
const ADDRESS = "0x95657033f1aafebd1fd539de36964ce0e1eb1cfe"; | |
const ABI = [ | |
{ | |
"inputs": [], | |
"name": "donate", | |
"outputs": [], |
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
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | |
// ./pages/api/index.js | |
// dependency: npm i -s line-notify-nodejs | |
// You can get Token URL here: | |
// https://notify-bot.line.me/my/ | |
// Generate token and copy it | |
const lineNotify = require('line-notify-nodejs')('ap...REPLACE WITH YOUR TOKEN....JY'); | |
export default async function handler(req, res) { | |
const message = "Send test 12"; |
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 { useState, useEffect } from 'react'; | |
let isStop = false; | |
export default function Home() { | |
const [price, setPrice] = useState(0); | |
useEffect(() => { | |
const ws = new WebSocket("wss://stream.binance.com:9443/ws/btcusdt@trade"); |
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
// Create2: Pre-compute contract address, we can knew deployed contract address, cannot duplicated deploy) | |
// Get bytecode of contract to be deploy | |
// creationCode => bytecode using contract deployment | |
// runtimeCode => bytecode using runtime | |
// bytes memory contract_byte = type(Dog).creationCode | |
// ต่อด้วย constructor parameter: abi.encode(_age) | |
// abi.encodePacked(type(Dog).creationCode, abi.encode(_age)) |
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-2.0-or-later | |
pragma solidity 0.7.6; | |
pragma abicoder v2; | |
import "../libraries/TransferHelper.sol"; | |
import "../interfaces/ISwapRouter.sol"; | |
contract MySwap { | |
// For the scope of these swap examples, | |
// we will detail the design considerations when using |
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 { parseEther } from "@ethersproject/units"; | |
import { constants } from "ethers"; | |
import { ethers } from "hardhat"; | |
import { ERC20__factory } from "../typechain"; | |
import { MySwap } from "../typechain"; | |
async function main() { | |
const factory = await ethers.getContractFactory("MySwap"); | |
const contract: MySwap = (await factory.deploy()) as MySwap; |
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 { constants } from "ethers"; | |
import { ethers } from "hardhat"; | |
import { ERC20__factory, SwapRouter__factory } from "../typechain"; | |
import { parseFixed } from "@ethersproject/bignumber"; | |
async function main() { | |
const SWAP_V3_ROUTER = "0xE592427A0AEce92De3Edee1F18E0157C05861564"; | |
const DAI = "0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea"; |
NewerOlder