-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(USDC): add token and adapter addresses * chore(USDC): fix token and adapter addresses Previously mistakenly only changed variable names, but not addresses. * nit(constants): adds comments for better readability * nit(constants): fix typo * docs(README): remove STBLTEST disclaimer and other - Adds usage examples for each demo - Adds a little more context in places for better readability
- Loading branch information
1 parent
ad0a4db
commit af0e594
Showing
5 changed files
with
75 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
> [!WARNING] | ||
> Currently this demo only works with the `STBLTEST` adapter and token, for which there is no | ||
> public faucet. If and when USDC deploys the adapter and the Celo community votes to make USDC an | ||
> accepted fee currency, we'll have to update the addresses in [`constants.ts`](./constants.ts). | ||
# Fee Currencies on Celo | ||
|
||
> [!TIP] | ||
> Code examples for | ||
> [docs.celo.org > Paying for Gas in Tokens](https://docs.celo.org/protocol/transaction/erc20-transaction-fees#alfajores-testnet). | ||
> Code examples for [docs.celo.org > Paying for Gas in Tokens](https://docs.celo.org/protocol/transaction/erc20-transaction-fees#alfajores-testnet). | ||
> Visit that page for more information. | ||
Fee currency transactions are unique to Celo. Fee currency transactions are made using a custom | ||
|
@@ -22,28 +16,55 @@ JS/TS client libraries. | |
|
||
### `viem` (Recommended ✅) | ||
|
||
We recommend you build with `viem`, if you are starting from scratch. See demo in | ||
[`viem.ts`](/viem.ts). | ||
We recommend you build with `viem`, if you are starting from scratch. For a demo, see | ||
[`viem.ts`](/viem.ts). You can run the demo as follows: | ||
|
||
```sh | ||
$ yarn ts-node viem.ts | ||
|
||
Initiating fee currency transaction... | ||
USDC balance of 0x303C22e6ef01CbA9d03259248863836CB91336D5: 10 | ||
Done! Transaction hash: 0x5242bb5340baa534f14285feac24fd8eac57cdd779b9a5cb2e88bbb5c3e6bb3d | ||
✨ Done in 4.66s. | ||
``` | ||
|
||
### `web3js` + `@celo/connect` (Discouraged ❌) | ||
|
||
We don't recommend you build with `web3js` and `@celo/connect`, if you are starting from scratch. | ||
To make fee currency transactions with `web3js` you need to use it in conjunction with | ||
`@celo/connect`. Bu, we don't recommend you build with `web3js` and `@celo/connect`, if you are | ||
starting from scratch. That's because `@celo/connect` only supports `[email protected]`, and not the | ||
latest version `[email protected]`. Instead, we recommend you build with `viem`. | ||
|
||
That's because `@celo/connect` only supports `[email protected]`, and not the latest version | ||
`[email protected]`. | ||
But, for completeness, we included a demo in | ||
[`web3.ts`](/web3.ts) so you can see usage patterns. You can run the demo as follows: | ||
|
||
Instead, we recommend you build with `viem`. But, for completeness, we included a demo in | ||
[`web3.ts`](/web3.ts) so you can see usage patterns. | ||
```sh | ||
$ yarn ts-node web3.ts | ||
|
||
Initiating fee currency transaction... | ||
USDC balance of 0x303c22e6ef01cba9d03259248863836cb91336d5: 9.989236 | ||
Done! Transaction hash: 0x49fa99caa6c2a4aade1d3a979fedea5037542a7a7a39c70eeec14b7661a9b030 | ||
✨ Done in 4.78s. | ||
``` | ||
|
||
### `@celo/contractkit` (Discouraged ❌) | ||
|
||
We don't recommend you build with `@celo/contractkit`, if you are starting from scratch. | ||
|
||
That's because `@celo/contractkit` is a library for developers who want to interact with | ||
[core contracts](https://docs.celo.org/contract-addresses) like `Governance.sol` or `Election.sol`. | ||
Instead, we recommend you build with `viem`. | ||
|
||
But, for completeness, we included a demo in [`contractkit.ts`](/contractkit.ts) so you can see | ||
usage patterns. You can run the demo as follows: | ||
|
||
```sh | ||
$ yarn ts-node contractkit.ts | ||
|
||
Instead, we recommend you build with `viem`. But, for completeness, we included a demo in | ||
[`contractkit.ts`](/contractkit.ts) so you can see usage patterns. | ||
Initiating fee currency transaction... | ||
USDC balance of 0x303C22e6ef01CbA9d03259248863836CB91336D5: 9.957260999999999 | ||
Done! Transaction hash: 0x6a2c32283971ca90463fb58b00d4fe4c4d75b340bc3f646667a4bdc368f31a65 | ||
✨ Done in 5.85s. | ||
``` | ||
|
||
### Raw transaction (Experts-only 🟠) | ||
|
||
|
@@ -57,22 +78,20 @@ envelopes. | |
But, if you would really like to construct fee currency transactions this way, you can learn more | ||
about the transaction arguments and format here: `celo-org/txtypes`. | ||
|
||
## Demo usage | ||
## Demos | ||
|
||
### Requirements | ||
|
||
- The private key of a Celo wallet with at least 1 USDC on the Alfajores testnet (you can get free | ||
USDC testnet tokens from [faucet.circle.com](https://faucet.circle.com/)) | ||
|
||
### Installing Node.js | ||
|
||
We use [Node.js](https://nodejs.org/en/) to run the project locally. You need to install the | ||
**Node.js version** specified in [.nvmrc](./.nvmrc). To do so, run: | ||
- We use [Node.js](https://nodejs.org/en/) to run the project locally. You need to install the | ||
**Node.js version** specified in [.nvmrc](./.nvmrc). To do so, run: | ||
|
||
```sh | ||
$ nvm install | ||
$ nvm use | ||
``` | ||
```sh | ||
$ nvm install | ||
$ nvm use | ||
``` | ||
|
||
### Installing dependencies | ||
|
||
|
@@ -109,7 +128,7 @@ When you execute a script, you will see something akin to this output: | |
$ yarn ts-node viem.ts | ||
Initiating fee currency transaction... | ||
STBLTEST balance of 0x303C22e6ef01CbA9d03259248863836CB91336D5: 59.946671 | ||
Done! Transaction hash: 0x8646968a8fe025fc7fd47a4e754953ddb4fe2936b43c06d82313463cb7851071 | ||
✨ Done in 8.23s. | ||
USDC balance of 0x303C22e6ef01CbA9d03259248863836CB91336D5: 10 | ||
Done! Transaction hash: 0x5242bb5340baa534f14285feac24fd8eac57cdd779b9a5cb2e88bbb5c3e6bb3d | ||
✨ Done in 4.66s. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters