https://github.com/talentlessguy/eth-clang-experiments
Clang experiments with Ethereum
https://github.com/talentlessguy/eth-clang-experiments
Last synced: about 1 year ago
JSON representation
Clang experiments with Ethereum
- Host: GitHub
- URL: https://github.com/talentlessguy/eth-clang-experiments
- Owner: talentlessguy
- Created: 2024-06-03T13:01:35.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T13:32:48.000Z (almost 2 years ago)
- Last Synced: 2025-02-12T10:55:20.915Z (over 1 year ago)
- Language: C
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clang experiments with Ethereum
## Setup
GCC/clang 17+ is recommended.
## Experiments
### JSONRPC request
Requirements: `libcurl`, `json-glib`, `glib`
Makes an HTTP request to an Ethereum node to obtain chain ID.
```sh
gcc src/chain_id.c src/utils/jsonrpc.c -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -ljson-glib-1.0 -lgobject-2.0 -lglib-2.0 -lcurl
```
### Sign a message
Requirements: `libethc`
Loads an Ethereum account from env, signs a "Hello World" message and outputs an
Ethereum address.
```
$ LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib clang src/sign.c -lethc
Signature: 0xb81efa243127sda5...00
Ethereum Address: 0xce9667fa..43c6
```
### Resolve ENS
Requirements: `libethc`, `libcurl`, `json-glib`, `glib`
Resolves given ENS name to an Ethereum address.
```
$ LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib gcc src/ens-addr.c src/utils/*.c -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -ljson-glib-1.0 -lgobject-2.0 -lglib-2.0 -lcurl -lethc
ENS name: v1rtl.eth
namehash: 0x6dd56164f699a101d6063add452dfed7c6c09fe17b8e4acf3328f9387f5030b9
Encoded ABI: 0x3b3b57de6dd56164f699a101d6063add452dfed7c6c09fe17b8e4acf3328f9387f5030b9
Response: {"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000d3b282e9880cdcb1142830731cd83f7ac0e1043f"}
Address: d3b282e9880cdcb1142830731cd83f7ac0e1043f
```
### Content-Hash
Requirements: `libethc`, `libcurl`, `json-glib`, `glib`
```
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib gcc src/content-hash.c src/utils/*.c -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -ljson-glib-1.0 -lgobject-2.0 -lglib-2.0 -lcurl -lethc
ENS name: v1rtl.eth
Content-Hash: 0xe30101701220846a8475d7d2ee4178ea696d2f3a15075b1e57729abbfa72f01c5caf24668eec
IPFS Hash: bafybeieenkchlv6s5zaxr2tjnuxtufihlmpfo4u2xp5hf4a4lsxsizuo5q
```