{"id":25949812,"url":"https://github.com/yegor256/erc20","last_synced_at":"2026-01-18T13:06:20.523Z","repository":{"id":275194249,"uuid":"925365171","full_name":"yegor256/erc20","owner":"yegor256","description":"Ruby gem for ERC20 manipulations on Etherium network: check balance, send payment, watch incoming payments","archived":false,"fork":false,"pushed_at":"2025-03-04T09:22:04.000Z","size":313,"stargazers_count":3,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T10:28:54.189Z","etag":null,"topics":["cryptocurrency","erc20","etherium","ruby","ruby-gem","usdt"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/erc20","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/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2025-01-31T18:32:42.000Z","updated_at":"2025-03-02T04:54:28.000Z","dependencies_parsed_at":"2025-02-17T08:27:59.586Z","dependency_job_id":"cf0bede8-a1d3-4640-ae37-4a66037ca55e","html_url":"https://github.com/yegor256/erc20","commit_stats":null,"previous_names":["yegor256/erc20"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ferc20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ferc20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ferc20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ferc20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/erc20/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241847489,"owners_count":20030264,"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":["cryptocurrency","erc20","etherium","ruby","ruby-gem","usdt"],"created_at":"2025-03-04T12:29:19.481Z","updated_at":"2026-01-18T13:06:20.517Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ethereum ERC20 Manipulations in Ruby\n\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/erc20)](https://www.rultor.com/p/yegor256/erc20)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/erc20/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/erc20/actions/workflows/rake.yml)\n[![PDD status](https://www.0pdd.com/svg?name=yegor256/erc20)](https://www.0pdd.com/p?name=yegor256/erc20)\n[![Gem Version](https://badge.fury.io/rb/erc20.svg)](https://badge.fury.io/rb/erc20)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/erc20.svg)](https://codecov.io/github/yegor256/erc20?branch=master)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/erc20/master/frames)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/erc20)](https://hitsofcode.com/view/github/yegor256/erc20)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/erc20/blob/master/LICENSE.txt)\n\nThis small Ruby [gem](https://rubygems.org/gems/erc20)\nmakes manipulations with [Ethereum] [ERC20] tokens\nas simple as possible, when you have a provider of\n[JSON-RPC] and [WebSockets] Ethereum APIs, such as\n[Infura], [GetBlock], or [Alchemy].\n\nInstall it like this:\n\n```bash\ngem install erc20\n```\n\nOr simply add this to your Gemfile:\n\n```ruby\ngem 'erc20'\n```\n\nThen, make an instance of the main class and use to read\nbalances, send and receive payments:\n\n```ruby\n# Create a wallet:\nrequire 'erc20'\nw = ERC20::Wallet.new(\n  contract: ERC20::Wallet.USDT, # hex of it\n  host: 'mainnet.infura.io',\n  http_path: '/v3/\u003cyour-infura-key\u003e',\n  ws_path: '/ws/v3/\u003cyour-infura-key\u003e',\n  log: $stdout\n)\n\n# Check how many ERC20 tokens are on the given address:\nusdt = w.balance(address)\n\n# Send a few ERC20 tokens to someone and get transaction hash:\nhex = w.pay(private_key, to_address, amount)\n\n# Stay waiting, and trigger the block when new ERC20 payments show up:\naddresses = ['0x...', '0x...'] # only wait for payments to these addresses\nw.accept(addresses) do |event|\n  puts event[:txn] # hash of transaction\n  puts event[:amount] # how much, in tokens (1000000 = $1 USDT)\n  puts event[:from] # who sent the payment\n  puts event[:to] # who was the receiver\nend\n```\n\nYou can also check ETH balance and send ETH transactions:\n\n```ruby\n# Check how many ETHs are on the given address:\neth = w.eth_balance(address)\n\n# Send a few ETHs to someone and get transaction hash:\nhex = w.eth_pay(private_key, to_address, amount)\n```\n\nTo check the price of a gas unit and the expected cost of a payment:\n\n```ruby\n# How many gas units required to send this payment:\nunits = w.gas_estimate(from, to, amount)\n\n# What is the price of a gas unit, in gwei:\ngwei = w.gas_price\n```\n\nTo generate a new private key, use [eth](https://rubygems.org/gems/eth):\n\n```ruby\nrequire 'eth'\nkey = Eth::Key.new.private_hex\n```\n\nTo convert a private key to a public address:\n\n```ruby\npublic_hex = Eth::Key.new(priv: key).address\n```\n\nTo connect to the server via [HTTP proxy] with [basic authentication]:\n\n```ruby\nw = ERC20::Wallet.new(\n  host: 'go.getblock.io',\n  http_path: '/\u003cyour-rpc-getblock-key\u003e',\n  ws_path: '/\u003cyour-ws-getblock-key\u003e',\n  proxy: 'http://jeffrey:swordfish@example.com:3128' # here!\n)\n```\n\nYou can use [squid-proxy] [Docker] image to set up your own [HTTP proxy] server.\n\nOf course, this library works with [Polygon], [Optimism],\nand other EVM compatible blockchains.\n\n## How to use in command line\n\nThis gem also provides a command line tool for sending ETH and ERC20 payments\nand checking balances.\n\nFirst, you install it, via [gem]:\n\n```bash\ngem install erc20\n```\n\nThen, run it:\n\n```bash\nerc20 --help\n```\n\nUsage should be straightforward. If you have questions, please submit an issue.\n\n## How to use in tests\n\nYou can use the `ERC20::FakeWallet` class that behaves exactly like\n`ERC20::Wallet`, but doesn't make any network connections to the provider.\nAdditionally, it records all requests sent to it:\n\n```ruby\nrequire 'erc20'\nw = ERC20::FakeWallet.new\nw.pay(priv, address, 42_000)\nassert w.history.include?({ method: :pay, priv:, address:, amount: 42_000 })\n```\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 3.2+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n\n[gem]: https://github.com/rubygems/rubygems\n[Ethereum]: https://en.wikipedia.org/wiki/Ethereum\n[ERC20]: https://ethereum.org/en/developers/docs/standards/tokens/erc-20/\n[JSON-RPC]: https://ethereum.org/en/developers/docs/apis/json-rpc/\n[Websockets]: https://ethereum.org/en/developers/tutorials/using-websockets/\n[Infura]: https://infura.io/\n[Alchemy]: https://alchemy.com/\n[GetBlock]: https://getblock.io/\n[basic authentication]: https://en.wikipedia.org/wiki/Basic_access_authentication\n[HTTP proxy]: https://en.wikipedia.org/wiki/Proxy_server\n[squid-proxy]: https://github.com/yegor256/squid-proxy\n[Docker]: https://www.docker.com/\n[Polygon]: https://polygon.technology/\n[Optimism]: https://www.optimism.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Ferc20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Ferc20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Ferc20/lists"}