{"id":15064651,"url":"https://github.com/wbnns/web3eth","last_synced_at":"2025-04-10T12:41:16.338Z","repository":{"id":53077003,"uuid":"355271996","full_name":"wbnns/web3eth","owner":"wbnns","description":"Connect with a local or remote node to interact with the Ethereum network and call RPC methods in your Ruby or Rails apps.","archived":false,"fork":false,"pushed_at":"2023-05-23T02:17:26.000Z","size":37,"stargazers_count":17,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T09:03:37.582Z","etag":null,"topics":["ethereum","rpc","ruby","ruby-gem","ruby-on-rails","web3"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/wbnns.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-04-06T17:17:03.000Z","updated_at":"2025-02-23T08:15:42.000Z","dependencies_parsed_at":"2024-09-25T00:23:41.451Z","dependency_job_id":"5262fc99-c167-4128-adae-e1422a58a899","html_url":"https://github.com/wbnns/web3eth","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"747a9726a959358870a28f207ed060fe78e1598e"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbnns%2Fweb3eth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbnns%2Fweb3eth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbnns%2Fweb3eth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbnns%2Fweb3eth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wbnns","download_url":"https://codeload.github.com/wbnns/web3eth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217156,"owners_count":21066634,"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":["ethereum","rpc","ruby","ruby-gem","ruby-on-rails","web3"],"created_at":"2024-09-25T00:23:33.452Z","updated_at":"2025-04-10T12:41:16.316Z","avatar_url":"https://github.com/wbnns.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web3ethereum\n\nConnect with a local or remote node to interact with the Ethereum network and\ncall RPC methods in your Ruby or Rails apps.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'web3ethereum'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install web3ethereum\n\n## Usage\n\n### Connect\n\nConnecting to local node ( or by SSH Tunnel )\n\n```ruby\nweb3 = Web3::Eth::Rpc.new\n```\n\nTo connect to remote Ethereum node, follow instructions: https://github.com/paritytech/parity/wiki/Wallet-Remote-Access\n\nIf you need to connect to remote host, you can specify host, port and HTTP connection options:\n\n```ruby\nweb3 = Web3::Eth::Rpc.new host: 'node.host.com', \n                          port: 8545,  \n                          connect_options: { use_ssl: true, read_timeout: 120 } \n```\n\nHTTP connection options are from  [Ruby HTTP](https://ruby-doc.org/stdlib-2.4.2/libdoc/net/http/rdoc/Net/HTTP.html)  plus additional optional property\n**rpc_path** - path to RPC interface.\n\nFor example, to connect to Infura node, you need the following configuration:\n\n```ruby\nweb3 = Web3::Eth::Rpc.new host: 'mainnet.infura.io',\n                          port: 443,\n                          connect_options: {\n                            open_timeout: 20,\n                            read_timeout: 140,\n                            use_ssl: true,\n                            rpc_path: '/v3/\u003cYOUR INFURA PERSONAL KEY\u003e'\n                          }\n```\n\nor to connect to Ropsten:\n\n\n```ruby\nweb3 = Web3::Eth::Rpc.new host: 'ropsten.infura.io', \n                          port: 443,  \n                          connect_options: {\n                            open_timeout: 20,\n                            read_timeout: 140,\n                            use_ssl: true\n                          }\n```\n\n### Calling eth interface\n\n```\n\u003e\u003e web3.eth.blockNumber\n4376369\n\n\u003e\u003e web3.eth.getBalance '0x829BD824B016326A401d083B33D092293333A830'\n3916.6597314456685\n\n\u003e\u003e block = web3.eth.getBlockByNumber 4376369\n#\u003cWeb3::Eth::Block:0x007f844d6f1138 @block_data={\"author\"=\u003e\"0x829bd824b016326a401d083b33d092293333a830\", ...\n\n\u003e\u003e block.timestamp_time\n2017-10-17 12:51:36 +0300\n\n\u003e\u003e block.transactions.count\n129\n\n\u003e\u003e block.transactions[0].from\n\"0xb2930b35844a230f00e51431acae96fe543a0347\"\n\n\u003e\u003e block.transactions[0].value_eth\n0.51896811\n\n```\n\n### Calling Etherscan API:\n\n```\napi = Web3::Eth::Etherscan.new 'Your API Key'\nabi = api.contract_getabi address: '0xe3fedaecd47aa8eab6b23227b0ee56f092c967a9'\n```\n\nMethod name for Etherscan must be constructed as \u003cmodule\u003e_\u003caction\u003e, for example contract_getabi \ncalls method getabi in module contract\n\nIf method accepts only one parameter address, the call can be simplified to:\n\n```\nabi = api.contract_getabi '0xe3fedaecd47aa8eab6b23227b0ee56f092c967a9'\n```\n\n### Accesing contract methods\n\n```\n# creation of contract object\nmyContract = web3.eth.contract(abi);\n\n# initiate contract for an address\nmyContractInstance = myContract.at('0x2ad180cbaffbc97237f572148fc1b283b68d8861');\n\n# call constant function\nresult = myContractInstance.balanceOf('0x...'); # any constant method works\nputs result \n```\n\nor using Etherscan API ( requires contract ABI be published in Etherescan ):\n\n```\napi = Web3::Eth::Etherscan.new 'Your API Key'\nmyContractInstance = web3.eth.load_contract(api, '0x2ad180cbaffbc97237f572148fc1b283b68d8861')\n\n// call constant function\nresult = myContractInstance.balanceOf('0x....'); # any constant method works\nputs result // '0x25434534534'\n```\n\n\n### Parsing transaction call arguments\n\nMethod parse_call_args parses call arguments according to ABI.\nCode example is:\n\n```\napi = Web3::Eth::Etherscan.new 'Your API Key'\nabi = api.contract_getabi address: '0x2ad180cbaffbc97237f572148fc1b283b68d8861'\n\nmyContract = web3.eth.contract(abi);\ntx = web3.eth.getTransactionByHash '0x83da408b05061a2512fe1abf065b37a6aad9ae96d604b288a3da34bf9f1af9e6'\nmyContract.parse_call_args tx\n```\n\n### Parsing smart contract constructor arguments\n\nMethod parse_constructor_args parses smart contract creation arguments according to ABI.\nCode example is:\n\n```\napi = Web3::Eth::Etherscan.new 'Your API Key'\nabi = api.contract_getabi address: '0xf4702b0918a8a89dfc38459ce42198834818f26b'\n\nmyContract = web3.eth.contract(abi);\ntx = web3.eth.getTransactionByHash '0x35f0cf1d1c7ec14dd40fe3949d1c535ec3f3953f118cb9dc1394370f966cf957'\nmyContract.parse_constructor_args tx\n```\n\n### Parsing transaction logs\n\nMethod parse_log_args parses indexed and not-indexed log event arguments according to ABI.\nCode example is:\n\n```\napi = Web3::Eth::Etherscan.new 'Your API Key'\nabi = api.contract_getabi address: '0x2ad180cbaffbc97237f572148fc1b283b68d8861'\n\nmyContract = web3.eth.contract(abi);\ntx_receipt = web3.eth.getTransactionReceipt '0x83da408b05061a2512fe1abf065b37a6aad9ae96d604b288a3da34bf9f1af9e6'\nmyContract.parse_log_args tx_receipt.logs.first\n```\n\n### Listing internal transactions\n\nTo use this feature, you should run parity node with the option \n--tracing on, refer to [https://github.com/paritytech/parity/wiki/Configuring-Parity#cli-options].\n\n```\ncalls = web3.trace.internalCallsByHash '0x7ac18a1640e443cd069ff51da382b92b585e42dae8f38db0932380bfe86908a6'\nputs calls.first.from\nputs calls.first.to\nputs calls.first.value_eth\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wbnns/web3eth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/wbnns/web3eth/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Web3eth project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wbnns/web3eth/blob/master/CODE_OF_CONDUCT.md).\n\n## Acknowledgements\n\nThis gem would not be possible without the work of **Izetex**. It is entirely\nbased on code from his [web3-eth library](https://github.com/izetex/web3-eth),\nwhich appears to no longer be maintained.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbnns%2Fweb3eth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwbnns%2Fweb3eth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbnns%2Fweb3eth/lists"}