notes icon indicating copy to clipboard operation
notes copied to clipboard

web3常用工具备忘

Open lanlin opened this issue 10 months ago • 2 comments

开发工具集

管理依赖、编译项目、运行测试、部署智能合约,并从命令行或通过 Solidity 脚本与链进行交互.

1. forge: 用于编译、测试和部署智能合约 doc

2. cast: 用于通过 RPC 与区块链交互,可以进行智能合约调用、发送交易或检索任何类型的链上数据 doc

3. chisel: Solidity REPL,可以直接编写 Solidity 代码 doc

4. anvil: 本地区块链节点,用于测试和开发 doc

5. abigen: 可以用来将 Solidity 合约的 ABI 转换为 Go 代码, 方便在 Go 程序中与智能合约进行交互 doc

快速安装

curl -L https://foundry.paradigm.xyz | bash
go install github.com/ethereum/go-ethereum/cmd/abigen@latest
foundryup
cast --version
solc --version
forge --version
abigen --version

简单应用

# 项目编译
forge soldeer install && forge build

# 生成合约 ABI
forge inspect Foo abi
forge inspect Foo abi > Foo.abi
forge inspect Foo abi > Foo.json

# 生成合约 bytecode
forge inspect FloCoin bytecode
forge inspect FloCoin bytecode > foo_file

# 生成合约的 go binding
abigen --abi Foo.abi --pkg main --type Foo --out Foo.go

lanlin avatar Feb 10 '25 08:02 lanlin

在线帮助函数

https://web3-tools.netlify.app/

lanlin avatar Apr 18 '25 10:04 lanlin

在线交易debug

https://dashboard.tenderly.co/

lanlin avatar Apr 18 '25 10:04 lanlin