This file contains hidden or 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
# 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 |
This file contains hidden or 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.0; | |
/** | |
* @dev Interface of the ERC20 standard as defined in the EIP. | |
*/ | |
interface IERC20 { | |
/** | |
* @dev Returns the amount of tokens in existence. | |
*/ |
This file contains hidden or 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
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}`) | |
} |
This file contains hidden or 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
// 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(); |
This file contains hidden or 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
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'); |
This file contains hidden or 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
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 |
This file contains hidden or 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.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 { |
This file contains hidden or 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: Unlicense | |
pragma solidity ^0.8.4; | |
library SafeMath { | |
/** | |
* @dev Returns the addition of two unsigned integers, reverting on | |
* overflow. | |
* | |
* Counterpart to Solidity's `+` operator. | |
* |
This file contains hidden or 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" | |
"fmt" | |
"log" | |
"math/big" | |
"time" | |
"github.com/ethereum/go-ethereum/common" |
This file contains hidden or 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 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, |
NewerOlder