Skip to content

Instantly share code, notes, and snippets.

View korrio's full-sized avatar
👽

kOrriO korrio

👽
  • Hal Finney Co.,Ltd.
  • mempool
  • X @korrio
View GitHub Profile
@korrio
korrio / main.py
Created April 18, 2025 04:56
main.py
# LangChain Blockchain Analysis MVP with Claude in Python
# This application analyzes blockchain transactions and provides natural language insights using LangChain with Claude
# Required dependencies
from langchain_anthropic import ChatAnthropic
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.tools import Tool
from langchain.agents import initialize_agent, AgentType
from web3 import Web3
@korrio
korrio / CounterService.sol
Created April 4, 2025 17:16
CounterService.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
@korrio
korrio / fetchFileByURL.tsx
Created March 27, 2025 06:49
fetchFileByURL.tsx
async function fetchFileByURL(url: string): Promise<File> {
const res = await fetch(url, {
credentials: 'include',
method: 'GET',
})
if (!res.ok) {
throw new Error(`Failed to fetch file from ${url}, status: ${res.status}`)
}
@korrio
korrio / claude.js
Created March 19, 2025 04:53
MCP Server/Client integration with Claude Sonnet 3.7 model
// MCP Server with Claude Integration
const express = require('express');
const http = require('http');
const WebSocket = require('ws');
const { Anthropic } = require('@anthropic/sdk');
const dotenv = require('dotenv');
// Load environment variables from .env file
dotenv.config();
const { Connection, PublicKey, Keypair } = require('@solana/web3.js');
const { Liquidity, Percent, Token } = require('@raydium-io/raydium-sdk');
async function swap() {
// Setup connection
const connection = new Connection('https://api.mainnet-beta.solana.com');
const wallet = Keypair.generate(); // ในการใช้งานจริงใช้ wallet จริง
// Setup pool และ tokens
const SOL_USDC_POOL_ID = new PublicKey('58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2');
@korrio
korrio / swap_on_uniswap_v3.py
Created October 22, 2024 06:25
swap_on_uniswap_v3.py
async def swap_on_uniswap_v3(w3, router_contract, token_in, token_out, amount, wallet_address, private_key, deadline):
try:
account = w3.eth.account.from_key(private_key)
# ใช้ quoteExactInputSingle เพื่อประมาณการ amounts_out
quoter_v3 = w3.eth.contract(address=QUOTER_ADDRESS, abi=quoter_abi)
quote = quoter_v3.functions.quoteExactInputSingle(
token_in,
token_out,
3000, # 0.3% fee tier
@korrio
korrio / V3.sol
Created October 22, 2024 06:21
V3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol";
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
contract CrossDexAtomicSwap is Ownable {
@korrio
korrio / SweepNSwap.sol
Last active October 22, 2024 04:15
SweepNSwap.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
@korrio
korrio / arb.go
Created October 2, 2024 08:13
arb.go
package main
import (
"context"
"fmt"
"log"
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
@korrio
korrio / arb.rs
Created October 2, 2024 06:52
arb.rs
use web3::types::{H160, U256};
use web3::contract::{Contract, Options};
use std::str::FromStr;
use std::time::Duration;
use tokio::time;
// Define DEX struct
struct DEX {
name: String,
router_address: H160,