{"id":15932261,"url":"https://github.com/jmrossy/celo-ethers-wrapper","last_synced_at":"2025-03-24T18:32:45.651Z","repository":{"id":37164301,"uuid":"302133963","full_name":"jmrossy/celo-ethers-wrapper","owner":"jmrossy","description":"An Ethers.JS extension for Celo-specific network features","archived":false,"fork":false,"pushed_at":"2024-11-29T23:20:25.000Z","size":1243,"stargazers_count":26,"open_issues_count":7,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-12T19:02:59.275Z","etag":null,"topics":["blockchain","celo","ethersjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jmrossy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2020-10-07T19:01:49.000Z","updated_at":"2024-11-29T17:03:39.000Z","dependencies_parsed_at":"2022-08-31T19:24:39.138Z","dependency_job_id":"1846e5ea-c9df-47ef-9100-540499372f39","html_url":"https://github.com/jmrossy/celo-ethers-wrapper","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":0.1923076923076923,"last_synced_commit":"8fd14313df9ccd59b835e4db93045d44626afa7c"},"previous_names":["celo-tools/celo-ethers-wrapper"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrossy%2Fcelo-ethers-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrossy%2Fcelo-ethers-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrossy%2Fcelo-ethers-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrossy%2Fcelo-ethers-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmrossy","download_url":"https://codeload.github.com/jmrossy/celo-ethers-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245328450,"owners_count":20597424,"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":["blockchain","celo","ethersjs","typescript"],"created_at":"2024-10-07T01:42:35.609Z","updated_at":"2025-03-24T18:32:45.268Z","avatar_url":"https://github.com/jmrossy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# celo-ethers-wrapper\n\nInitially, the Celo network was not fully compatible with Ethers.JS. Since the Donut hard-fork in 2021, Ethereum tools can now be used with Celo without the need for a wrapper. However, Celo transactions have optional, additional fields that enable useful features like paying with stable tokens. This library enables the use of those extra fields.\n\n## Install\n\n`npm i @celo-tools/celo-ethers-wrapper`\n\nor\n\n`yarn add @celo-tools/celo-ethers-wrapper`\n\nNote this wrapper has Ethers as a peer dependency. **Use celo-ethers-wrapper v1 versions for Ethers V5 and v2 versions for Ethers V6.**\n\n## Basic Usage\n\nConnect to the network by creating a `CeloProvider`, which is based on [JsonRpc-Provider](https://docs.ethers.org/v6/api/providers/jsonrpc):\n\n```js\nimport { CeloProvider } from '@celo-tools/celo-ethers-wrapper'\n\n// Connecting to Alfajores testnet\nconst provider = new CeloProvider('https://alfajores-forno.celo-testnet.org')\nawait provider.ready\n```\n\nNext, Create a CeloWallet, which is based on [Wallet](https://docs.ethers.org/v6/api/wallet) :\n\n```js\nimport { CeloWallet } from '@celo-tools/celo-ethers-wrapper'\n\nconst wallet = new CeloWallet(YOUR_PK, provider)\n```\n\nUse the provider or wallet to make calls or send transactions:\n\n```js\nconst txResponse = await wallet.sendTransaction({\n    to: recipient,\n    value: amountInWei,\n  })\nconst txReceipt = await txResponse.wait()\nconsole.info(`CELO transaction hash received: ${txReceipt.transactionHash}`)\n```\n\n## Contract Interaction\n\n`CeloWallet` can be used to send transactions.\n\nHere's an example of sending cUSD with the StableToken contract. For interacting with contracts you need the ABI and address. Addresses for Celo core contracts can be found with the CLI's `network:contracts` command. The ABIs can be built from the solidity code or extracted in ContractKit's `generated` folder.\n\n```js\nimport { Contract, ethers, utils, providers } from 'ethers'\n\nconst stableToken = new ethers.Contract(address, abi, wallet)\nconsole.info(`Sending ${amountInWei} cUSD`)\nconst txResponse: providers.TransactionResponse = await stableToken.transferWithComment(recipient, amountInWei, comment)\nconst txReceipt = await txResponse.wait()\nconsole.info(`cUSD payment hash received: ${txReceipt.transactionHash}`)\n```\n\n## Alternative gas fee currencies\n\nThe Celo network supports paying for transactions with the native asset (CELO) but also with the stable token (cUSD).\n\nThis wrapper currently has partial support for specifying feeCurrency in transactions.\n\n```js\nconst gasPrice = await wallet.getGasPrice(stableTokenAddress)\nconst gasLimit = await wallet.estimateGas(tx)\n\n// Gas estimation doesn't currently work properly for non-CELO currencies\n// The gas limit must be padded to increase tx success rate\n// TODO: Investigate more efficient ways to handle this case\nconst adjustedGasLimit = gasLimit.mul(10)\n\nconst txResponse = await signer.sendTransaction({\n  ...tx,\n  gasPrice,\n  gasLimit: adjustedGasLimit,\n  feeCurrency: stableTokenAddress,\n})\n```\n\n## Getting transaction history with CeloscanProvider\n\nYou can also rely on EthersProviders functionality, such as getting an account's transaction history, using our alternative CeloscanProvider\n\n```js\nimport { CeloscanProvider } from '@celo-tools/celo-ethers-wrapper'\n\n// You can use 'celo', 'alfajores' or 'baklava'.\n// Default is 'celo' (mainnet)\nconst scanProvider = new CeloscanProvider('alfajores');\n\nconst history = await provider.getHistory(YOUR_ACCOUNT);\nconsole.info(\"History:\", history);\n```\n\n## Examples\n\nSee the tests under `/test` for more detailed examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrossy%2Fcelo-ethers-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmrossy%2Fcelo-ethers-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrossy%2Fcelo-ethers-wrapper/lists"}