{"id":25158415,"url":"https://github.com/zt-9/geth-smart-contract","last_synced_at":"2025-04-03T12:42:18.796Z","repository":{"id":245173181,"uuid":"817474276","full_name":"zt-9/geth-smart-contract","owner":"zt-9","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-05T23:03:30.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T01:51:34.697Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zt-9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-19T19:41:14.000Z","updated_at":"2024-09-05T23:03:33.000Z","dependencies_parsed_at":"2024-06-20T09:00:57.763Z","dependency_job_id":"e31ef3a1-1c61-46f2-8078-754253fd00b2","html_url":"https://github.com/zt-9/geth-smart-contract","commit_stats":null,"previous_names":["zoey-t/geth-smart-contract","zt-9/geth-smart-contract"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zt-9%2Fgeth-smart-contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zt-9%2Fgeth-smart-contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zt-9%2Fgeth-smart-contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zt-9%2Fgeth-smart-contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zt-9","download_url":"https://codeload.github.com/zt-9/geth-smart-contract/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247005377,"owners_count":20868019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T01:51:42.473Z","updated_at":"2025-04-03T12:42:18.768Z","avatar_url":"https://github.com/zt-9.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Geth Smart Contract\nThis guide provides tutorials for using Geth to deploy and interact with smart contracts.\n\n## Prerequisite\n- [Golang](https://go.dev/doc/install)\n- [Docker](https://www.docker.com/)\n\n## 1. Generate the ABI and BIN\nWe can use `solc` or tools like Hardhat or Foundry to generate the ABI and BIN files for our contracts.\n\n### Using `solc`\n1. Download `solc` using [solc-select](https://github.com/crytic/solc-select.git):\n   ```bash\n   git clone https://github.com/crytic/solc-select.git\n   cd solc-select\n   ./solc-select install\n   ```\n2. Install the desired Solidity version:\n   ```bash\n   solc-select use 0.8.26 --always-install\n   ```\n3. Navigate to the `contract` folder and run the command to generate the ABI and BIN files:\n   ```bash\n   solc --abi --bin -o build Storage.sol\n   ```\n\n## 2. Generate Go Files for Contract Deployment and Interaction\n1. Install the `go-ethereum` package, which is required for the `abigen` tool:\n   ```bash\n   go get github.com/ethereum/go-ethereum\n   ```\n2. Install the `abigen` tool:\n   ```bash\n    go install github.com/ethereum/go-ethereum/cmd/abigen@latest\n   ```\n3. Create a folder named `storage` for our Go package:\n   ```bash\n   mkdir storage\n   cd storage\n   ```\n4. Run the `abigen` command in the `storage` folder to generate the Go files for the `storage` package:\n   ```bash\n   abigen --abi=../contract/build/Storage.abi --bin=../contract/build/Storage.bin --pkg=storage --out=storage.go\n   ```\n\n## 3. Contract Deployment and Interaction\nThe generated `storage.go` file provides the `DeployStorage()` function to deploy the contract, as well as functions to interact with it.\n\nTo call the `store()` function in the `Storage` contract, use the generated `Store()` function in the `storage.go` file.\n\nRefer to the example in `storage/storage_test.go` for contract deployment and interaction. \nIn this test, we use Anvil to start a local ethereum testnet node. Ensure you have [Foundry](https://book.getfoundry.sh/getting-started/installation) installed before running the test:\n```bash\nmake test\n```\n\n## Notes\n- [Testcontainers](https://golang.testcontainers.org/) is used for the tests. so we need to start docker before running the tests.\n-  The Testcontainers fetches the the foundry docker image from `ghcr.io/foundry-rs/foundry`. The fetch may fail with error `no matching manifest for linux/arm64/v8 in the manifest list entries` on Apple Silicon chips. You may need to manully pull the image with `docker pull ghcr.io/foundry-rs/foundry --platform linux/x86_64` first if you are on a Apple Silicon Chip and encountered the error.\n- Run `make clean` if you encounter any Go module or package load errors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzt-9%2Fgeth-smart-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzt-9%2Fgeth-smart-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzt-9%2Fgeth-smart-contract/lists"}