{"id":51151311,"url":"https://github.com/humanbased-ai/gas-payment-sdk","last_synced_at":"2026-06-26T06:04:18.643Z","repository":{"id":350984471,"uuid":"1185841499","full_name":"humanbased-ai/gas-payment-sdk","owner":"humanbased-ai","description":"TypeScript SDK for gas payment: calculate fees, build ERC3009-authorized UserOperations, submit to bundler. Pay blockchain gas with any ERC20 token.","archived":false,"fork":false,"pushed_at":"2026-05-13T09:51:53.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-01T04:29:34.401Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humanbased-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-19T01:56:49.000Z","updated_at":"2026-05-13T09:51:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/humanbased-ai/gas-payment-sdk","commit_stats":null,"previous_names":["codatta/gas-payment-sdk","humanbased-ai/gas-payment-sdk"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/humanbased-ai/gas-payment-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanbased-ai%2Fgas-payment-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanbased-ai%2Fgas-payment-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanbased-ai%2Fgas-payment-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanbased-ai%2Fgas-payment-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humanbased-ai","download_url":"https://codeload.github.com/humanbased-ai/gas-payment-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanbased-ai%2Fgas-payment-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34805109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-06-26T06:04:17.759Z","updated_at":"2026-06-26T06:04:18.605Z","avatar_url":"https://github.com/humanbased-ai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @xny/gas-payment-sdk\n\nTypeScript SDK for gas payment: token/ETH price, EntryPoint handleOps, fee calculation (Amount = gas × gas_price × ETH_price / token_price), ERC3009 payment, and submit.\n\nWorks in **Node.js** and **browser**.\n\n## Install\n\n\u003e Not yet published to npm. Install directly from the Git repository, or vendor the source into your project.\n\n**Option A — install from Git** (requires SSH access to the repo):\n\n```bash\nnpm install git+ssh://git@github.com:codatta/gas-payment-sdk.git\n# pin to a commit / tag / branch:\nnpm install git+ssh://git@github.com:codatta/gas-payment-sdk.git#\u003ccommit-sha-or-tag\u003e\n```\n\nThe `prepare` lifecycle will build `dist/` automatically on install.\n\n**Option B — local path** (monorepo / sibling checkout):\n\n```bash\ngit clone git@github.com:codatta/gas-payment-sdk.git\ncd gas-payment-sdk \u0026\u0026 npm install \u0026\u0026 npm run build\n# in your app:\nnpm install /absolute/path/to/gas-payment-sdk\n```\n\n**Option C — npm link** (active SDK development):\n\n```bash\ncd /path/to/gas-payment-sdk \u0026\u0026 npm run build \u0026\u0026 npm link\ncd /path/to/your-app \u0026\u0026 npm link @xny/gas-payment-sdk\n```\n\nPeer requirement: `viem ^2`, Node `\u003e=18`.\n\n## Config\n\nEvery field is **optional**. Once `chainId` is known (or defaulted to `DEFAULT_CHAIN_ID = 84532` / Base Sepolia), the rest are filled in from the bundled per-chain defaults (`CHAIN_DEFAULTS`). Pass any field explicitly to override.\n\n| Option | Description | Default source |\n|--------|-------------|----------------|\n| `chainId` | EIP-155 chain ID | `DEFAULT_CHAIN_ID` (84532) |\n| `apiBaseUrl` | Bundler REST API base | from `CHAIN_DEFAULTS[chainId]` |\n| `rpcUrl` | Chain RPC URL | from `CHAIN_DEFAULTS[chainId]` |\n| `entryPointAddress` | EntryPoint contract (handleOps) | from `CHAIN_DEFAULTS[chainId]` |\n| `erc3009TokenAddress` | ERC3009 token used for payment | from `CHAIN_DEFAULTS[chainId]` |\n| `paymentTargetContract` | PoolPaymaster (also ERC3009 receiver) | from `CHAIN_DEFAULTS[chainId]` |\n| `apiKey` | Optional bearer token for bundler | — |\n| `timeout` | Request timeout (ms) | 30000 |\n\nCurrently bundled chains: `84532` (Base Sepolia). For chains without bundled defaults you must pass every address explicitly, otherwise the constructor throws `ValidationError` listing what's missing.\n\n## Usage\n\n```ts\nimport { GasPaymentClient } from \"@xny/gas-payment-sdk\";\n\n// Zero-config — uses Base Sepolia defaults\nconst client = new GasPaymentClient();\n\n// Or pick the chain explicitly (still uses bundled defaults)\nconst client2 = new GasPaymentClient({ chainId: 84532 });\n\n// Override individual fields (e.g. point at your own RPC)\nconst client3 = new GasPaymentClient({\n  chainId: 84532,\n  rpcUrl: \"https://base-sepolia.g.alchemy.com/v2/\u003ckey\u003e\",\n  apiKey: \"\u003cbundler-token\u003e\",\n});\n\n// Full custom (e.g. unsupported chain or local anvil)\nconst clientCustom = new GasPaymentClient({\n  apiBaseUrl: \"https://api.example.com/api/v1\",\n  rpcUrl: \"http://127.0.0.1:8545\",\n  chainId: 31337,\n  entryPointAddress: \"0x...\",\n  erc3009TokenAddress: \"0x...\",\n  paymentTargetContract: \"0x...\",\n});\n\n// 1. Token price (token smallest units per 1 ETH)\nconst tokenPrice = await client.getTokenPrice();\n\n// 2. Gas quote\nconst { quote, gasPriceWei } = await client.getQuote();\n\n// 3. Prepare payment: UserOp, handleOps tx, fee, ERC3009 payload\nconst prepared = await client.preparePayment({\n  sender: \"0xUser...\",\n  target: \"0xTarget...\",\n  callData: \"0x...\",\n});\n// Sign prepared.userOpTypedData (UserOperation, EIP-712) and prepared.erc3009Payload.typedData (ERC3009).\n\n// 4. Submit\nconst result = await client.submitPayment({\n  userOp: { ...prepared.userOp, signature: \"0x...\" },\n  signature: \"0x...\",\n});\n\n// 5. Status\nconst status = await client.getStatus(result.requestId);\n```\n\n## Fee formula\n\nPayment amount in token (smallest units):\n\n```\nAmount = gas × gas_price × ETH_price / token_price\n```\n\n- `gas`: estimated gas for the handleOps call  \n- `gas_price`: wei per gas (from quote or RPC)  \n- `ETH_price`: from backend (e.g. USD per ETH)  \n- `token_price`: from backend (e.g. USD per token)\n\n## Example\n\n```bash\ncp .env.example .env       # then fill in SENDER_PRIVATE_KEY + TARGET\nnpm install\nnpm run example            # run all steps\n```\n\nRun a single SDK interface:\n\n| Command | Interface |\n|---------|-----------|\n| `npm run example:price` | `getTokenPrice()` |\n| `npm run example:quote` | `getQuote()` |\n| `npm run example:prepare` | `preparePayment()` |\n| `npm run example:state` | on-chain ETH + ERC20 balance snapshot |\n| `npm run example:status` | `getStatus(REQUEST_ID)` |\n| `npm run example:submit` | `submitPayment()` (signs with `SENDER_PRIVATE_KEY` and submits) |\n\nSee `.env.example` for the full list of variables and which are required vs optional. Network/contract values default to the Base Sepolia preset baked into the SDK.\n\n## Tests\n\n```bash\nnpm run test\n```\n\nTests cover: token/ETH price parsing and fee formula, EntryPoint UserOperation and handleOps encoding, ERC3009 typed data, HTTP client (price, quote, submit, status), and GasPaymentClient (config validation, getTokenPrice, getEthPrice, getQuote, submitPayment, getStatus, preparePayment validation).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanbased-ai%2Fgas-payment-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanbased-ai%2Fgas-payment-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanbased-ai%2Fgas-payment-sdk/lists"}