vyperlang / titanoboa

a vyper interpreter
https://titanoboa.readthedocs.io
Other
247 stars 49 forks source link

Set chain_id via BrowserRPC #125

Closed bout3fiddy closed 7 months ago

bout3fiddy commented 7 months ago

allow notebook author to set chainID on browsersigner:

currently we do:

import boa
from boa.integrations.jupyter import BrowserEnv
boa.set_env(BrowserEnv())

what i propose:

import boa
from boa.integrations.jupyter import BrowserEnv

browser_env_ethereum = BrowserEnv(chain_id=1)

boa.set_env(browser_env_ethereum)
DanielSchiavini commented 7 months ago

This doesn't seem to be part of the standard but it does seem to work for metamask: https://eips.ethereum.org/EIPS/eip-3326

@bout3fiddy chain_id instead of chainId pls

Tested this:

boa.env._rpc.fetch("eth_chainId", []) # returns current chain
boa.env._rpc.fetch("wallet_switchEthereumChain", [{"chainId":"0xaa36a7"}])  # sets chain to sepolia