Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewWeb3WithProxy函数是否可以避免必须手动设置ChainID #16

Open
Leadblock opened this issue Aug 31, 2022 · 0 comments
Open

Comments

@Leadblock
Copy link

Leadblock commented Aug 31, 2022

func (e *Eth) ChainID() (*big.Int, error)
中有调用 rpc 的 eth_chainId 的方法。

但是我在通过 NewWeb3WithProxy 构建对象时,需要设置 ChainID。这个设置会导致生成的 eth 对象被设置了 chainid,逻辑上就不会调用 rpc 的 eth_chainId,而是从设置缓存读取。

很多链是可以通过 rpc 的 eth_chainId 获取 chainid 的,
我们是否可以避免在 NewWeb3WithProxy 中粗糙的通过provider判断,而是自动从链上读取。

目前我NewWeb3WithProxy构建对象后,无法通过eth获得链chainid,必须自己知道是多少,从外部设置进去。感觉步骤很多余而且多链项目容易出错。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant