
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
https://github.com/otherview/solgen/workflows/Test/badge.svg](https://github.com/otherview/solgen/actions/workflows/test.yml) https://github.com/otherview/solgen/workflows/Release/badge.svg](https://github.com/otherview/solgen/actions/workflows/release.yml) https://github.com/otherview/solgen/workflows/Edge%20Build/badge.svg](https://github.com/otherview/solgen/actions/workflows/edge.yml)
Lightning-fast Go ***dings generator for Solidity contracts. Zero dependencies, maximum simplicity.
Generate clean, type-safe Go code from Solidity contracts in seconds. No external dependencies in generated ***dings - just pure Go ready for production.
solc output, writes clean Go codeClean, type-safe ***dings that work with any *** client:
goimport "yourproject/generated/simpletoken" // Pack method calls for transactions transferData := simpletoken.Methods().TransferMethod().Pack(recipient, amount) approveData := simpletoken.Methods().ApproveMethod().MustPack(spender, amount) // Decode return values from eth_call balance := simpletoken.Methods().BalanceOfMethod().MustDecode(returnData) success := simpletoken.Methods().TransferMethod().MustDecode(returnData) tokenName := simpletoken.Methods().NameMethod().MustDecode(returnData)
go// Decode event logs transferEvent := simpletoken.Events().TransferEvent().MustDecode(logData) fmt.Printf("Transfer: %s to %s, amount: %s ETH\n", transferEvent.From, transferEvent.To, weiToEth(transferEvent.Value)) // Handle custom errors from reverted transactions if revertData != nil { error := simpletoken.Errors().InsufficientBalanceError().MustDecode(revertData) fmt.Printf("Error: insufficient balance - requested %s, available %s\n", weiToEth(error.Requested), weiToEth(error.Available)) }
goimport "github.com/ethereum/go-ethereum/ethclient" // Works seamlessly with ethclient or any Ethereum library client, _ := ethclient.Dial("https://mainnet.infura.io/v3/YOUR_PROJECT_ID") contractAddr := common.HexToAddress("0x...") // Read contract state callData := simpletoken.Methods().BalanceOfMethod().MustPack(userAddress) result, _ := client.CallContract(ctx, ethereum.CallMsg{ To: &contractAddr, Data: callData.Bytes(), }, nil) balance := simpletoken.Methods().BalanceOfMethod().MustDecode(result) // Send transactions tx := types.NewTransaction(nonce, contractAddr, big.NewInt(0), gasLimit, gasPrice, simpletoken.Methods().TransferMethod().MustPack(recipient, amount).Bytes())
Generated ***dings are completely self-contained:
go// No external imports needed in generated code! type Address [20]byte // Custom address type type Hash [32]byte // Custom hash type type HexData string // Convenient hex handling // Built-in ABI encoding/decoding // Type-safe method calls // Clean error handling
🚀 Complete Example - See the full working example with detailed comments showing all features in action!
bash# Docker (recommended) docker pull otherview/solgen # Or install locally go install github.com/otherview/solgen/cmd/solgen@latest
⚠️ Docker Image Update: The official Solidity compiler Docker image has moved from
ethereum/solc(deprecated) toghcr.io/argotorg/solc. All examples below use the new official image.
bash# Standard: Contract info + bytecode (recommended) solc --combined-json abi,bin,bin-runtime,hashes contracts/*.sol | \ solgen --out generated # Minimum: Just contract info (no bytecode functions) solc --combined-json abi,hashes contracts/*.sol | \ solgen --out generated
bash# Latest stable version (recommended for development) sh -c "docker run --rm -v $(pwd):/src ghcr.io/argotorg/solc:stable \ --combined-json abi,bin,bin-runtime,hashes \ --optimize /src/contracts/*.sol | \ docker run --rm -i -v $(pwd):/src otherview/solgen --out /src/generated" # Pinned version (recommended for production) sh -c "docker run --rm -v $(pwd):/src ghcr.io/argotorg/solc:0.8.20 \ --combined-json abi,bin,bin-runtime,hashes \ --optimize /src/contracts/*.sol | \ docker run --rm -i -v $(pwd):/src otherview/solgen --out /src/generated"
go// Using stable version //go:generate sh -c "docker run --rm -v $(pwd):/src ghcr.io/argotorg/solc:stable --combined-json abi,bin,bin-runtime,hashes /src/contracts/*.sol | docker run --rm -i -v $(pwd):/src otherview/solgen --out /src/generated" // Or with local solc installation //go:generate sh -c "solc --combined-json abi,bin,bin-runtime,hashes contracts/*.sol | solgen --out generated"
📚 More examples: See EXAMPLES.md for advanced usage, CI/CD integration, and platform-specific examples
solgen
--out (required): Output directory--verbose: Detailed outputsolc (required fields)
--combined-json abi,hashes (contract info only)--combined-json abi,bin,bin-runtime,hashes (+ bytecode functions)--optimize, --optimize-runs 200Docker Images
ghcr.io/argotorg/solc:stable (latest) or ghcr.io/argotorg/solc:0.8.20 (pinned)ethereum/solc:0.8.20 (still works but not recommended)Each contract gets a clean Go package:
generated/ mycontract/ mycontract.go # Clean, dependency-free bindings
| Solidity | Go | Example |
|---|---|---|
bool | bool | true |
string | string | "hello" |
address | common.Address | 0x742d... |
bytes | []byte | []byte{0x12, 0x34} |
bytes32 | [32]byte | [32]byte{...} |
uint256 | *big.Int | big.NewInt(123) |
uint64 | uint64 | uint64(123) |
int256 | *big.Int | big.NewInt(-123) |
T[] | []T | []Address{...} |
T[N] | [N]T | [3]uint256{...} |
ghcr.io/argotorg/solc + otherview/solgen containerssolc ***aryIf you're currently using the deprecated ethereum/solc image:
bash# Old (deprecated) docker run --rm ethereum/solc:0.8.20 --combined-json abi,bin,bin-runtime,hashes # New (recommended) docker run --rm ghcr.io/argotorg/solc:0.8.20 --combined-json abi,bin,bin-runtime,hashes # or docker run --rm ghcr.io/argotorg/solc:stable --combined-json abi,bin,bin-runtime,hashes
The functionality is identical - just replace the image name.
bash# Run tests go test ./... # Build from source go build ./cmd/solgen
MIT License - see LICENSE file.
Pipeline fails? Test solc and solgen separately with --verbose
Docker permissions? Use --user $(id -u):$(id -g) or chown after generation
Package conflicts? Rename contracts - package names are derived from contract names (lowercase, alphanumeric only)
🔍 Detailed troubleshooting: See EXAMPLES.md for step-by-step debugging, platform-specific issues, and advanced solutions
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务