# 1st
anvil --fork-url $AVALANCHE_RPC
# 2nd using anvil's default account at index 0
cast send 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7 "deposit()" --value $(cast to-wei 1 ether) --unlocked \
--from 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://localhost:8545
# 3rd chceck balance
cast balance --erc20 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
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
def wallet_with_native_token(web3_fork: Web3, test_address: HexAddress) -> None: | |
# Directly set test_address’s balance to 100 ETH | |
amount_wei = 100 * 10**18 | |
web3_fork.provider.make_request( | |
"anvil_setBalance", | |
[test_address, hex(amount_wei)] | |
) | |
assert web3_fork.eth.get_balance(test_address) == amount_wei |
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 alloy::primitives::U256; | |
fn integer_sqrt(n: U256) -> U256 { | |
// https://en.wikipedia.org/wiki/Integer_square_root | |
if n < U256::from(2) { | |
return n; | |
} | |
let small_candidate = integer_sqrt(n >> 2) << 1; |
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 alloy::primitives::U256; | |
fn main() { | |
let reserve_ratio: f64 = pool.reserve0.to::<f64>() / pool.reserve1.to::<f64>(); | |
} |
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::transports::WebSocket; | |
use web3::Web3; | |
def main() { | |
let rpc_url: String = "http://localhost:8545" //"Your RPC URL" | |
// Initialize WebSocket transport | |
let ws = WebSocket::new(&rpc_url).await?; | |
let w3 = Web3::new(ws); | |
info!("Successfully connected to WebSocket RPC."); |
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
## Using hatch but should be similar for other tools | |
# https://hatch.pypa.io/latest/config/build/#pyprojecttoml_5 | |
# Build configs | |
[tool.hatch.build.targets.sdist] | |
include = [ | |
"src/**/*.py", | |
".configs/*" | |
] |
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
from solders.pubkey import Pubkey | |
from solana.rpc.api import Client | |
from solders.pubkey import Pubkey | |
from solders.keypair import Keypair | |
from solana.rpc.types import TokenAccountOpts | |
from rich.pretty import pprint | |
# You can use async client as well | |
http_client = Client("https://api.mainnet-beta.solana.com") | |
private_key = Keypair.from_bytes(bytes(key)) |
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
from spl.token._layouts import MINT_LAYOUT | |
from solana.rpc.api import Client, Pubkey | |
http_client = Client("https://api.mainnet-beta.solana.com") | |
# USDC token address | |
addr = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") | |
info = http_client.get_account_info(addr) | |
decimals = MINT_LAYOUT.parse(info.value.data).decimals |
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
pipx list --short | cut -d ' ' -f1 | while read line; do pipx upgrade $line; done |
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
[Desktop Entry] | |
Name=Filecoin Station | |
Comment=Filecoin Station | |
Exec=/home/avik/tools/filecoin-station-linux-x86_64.AppImage | |
Icon=/home/avik/tools/icons-for-appImage/file-coin-station.jpg | |
Terminal=false | |
Type=Application | |
Categories=Development; |
NewerOlder