Skip to content

Commit

Permalink
fix: Fee Currency -> Fee Abstraction (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
therealharpaljadeja committed Jul 12, 2024
1 parent 1dcfd45 commit 7c64f89
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 33 deletions.
21 changes: 21 additions & 0 deletions docs/cel2/contract-addresses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Contract Addresses
---

## Holesky (L1)

| Contract Name | Address |
| :-------------------------------: | :----------------------------------------: |
| L1CrossDomainMessenger | 0xd51013941d49631846fe52028C8D7a6EeBf06C98 |
| L1ERC721BridgeProxy | 0x856dD9501a509D3738aE2da7B79cDA1731d8E9b3 |
| L1StandardBridgeProxy | 0x9FEBd0F16b97e0AEF9151AF07106d733E87B1be4 |
| OptimismMintableERC20FactoryProxy | 0x95E7A21b705a971BDBC999295f4a3c04CDfC52F0 |
| OptimismPortalProxy | 0xB29597c6866c6C2870348f1035335B75eEf79d07 |
| ProxyAdmin | 0x02E65F11504e328A6DabB38b0D05854297466178 |
| SystemConfigProxy | 0x43cb8878b4B62D9853452140eFB42CF30672e23a |
| DisputeGameFactoryProxy | 0x831f39053688f05698ad0fB5f4DE7e56B2949c55 |
| AnchorStateRegistryProxy | 0xedf4ed5230f9B1F54C33F381C1990129f30E9196 |
| DelayedWETHProxy | 0xb9034e29a6e5c94ae50F4eDBf8450492Bf6f636C |
| Mips | 0xcc6342CfF04DE2Ed80C812470BFF54A7A7184fF8 |

## Cel2 Dango Testnet(L2)
8 changes: 4 additions & 4 deletions docs/cel2/fee-currencies.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
title: Fee Currencies on Cel2
title: Fee Abstraction on Cel2
---

## Fee Currency Addresses
## Fee Abstraction Addresses

### Get list of whitelisted Fee Currencies

```bash
celocli network:whitelist --node https://forno.dango.celo-testnet.org
```

### Using Fee Currency
### Using Fee Abstraction

Transfer 1 USDC using USDC as Fee Currency
Transfer 1 USDC using USDC as fee currency

```bash
celocli transfer:erc20 --erc20Address 0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B --from 0x22ae7Cf4cD59773f058B685a7e6B7E0984C54966 --to 0xDF7d8B197EB130cF68809730b0D41999A830c4d7 --value 1000000 --gasCurrency 0x4822e58de6f5e485eF90df51C41CE01721331dC0 --privateKey [PRIVATE_KEY]
Expand Down
3 changes: 1 addition & 2 deletions docs/developer/build-on-minipay/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ MiniPay is available inside Opera Mini on Android phones only. To ensure that yo
alt="MiniPay dApp testing"
/>


:::info
One can also setup their project, using the MiniPay template available [here](https://github.com/celo-org/minipay-template)
:::
Expand All @@ -90,7 +89,7 @@ This will provide you with a public URL that tunnels to your localhost.
### Get your dApp ready for MiniPay

:::warning
MiniPay uses Custom Fee Currency based transactions, which is not supported by Ethers.js and web3.js.
MiniPay uses Custom Fee Abstraction based transactions, which is not supported by Ethers.js and web3.js.
:::

#### 1. Viem
Expand Down
6 changes: 3 additions & 3 deletions docs/developer/fee-currency.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Implementing Fee Currency in Wallets
title: Implementing Fee Abstraction in Wallets
description: How to allow your wallet users to pay for gas fee using alternate fee currencies
---

Expand All @@ -11,7 +11,7 @@ This works by specifying a token/adapter address as a value for the `feeCurrency

The below steps describe how wallets can implement the alternate fee currency feature in order to allow users to use alternate assets in the user's wallet to pay for gas fees.

## Enabling Transactions with ERC20 Token as Fee Currency
## Enabling Transactions with ERC20 Token as fee currency

We recommend using the [viem](https://viem.sh) library as it has support for the `feeCurrency` field in the transaction required for sending transaction where the gas fees will be paid in ERC20 tokens.

Expand Down Expand Up @@ -83,7 +83,7 @@ async function main() {
}
```

### Sending transaction using alternate fee currency
### Sending transaction using Fee Abstraction

Sending transaction with fee currency other than the native currency of the network is pretty straightforward all you need to do is set the `feeCurrency` property in the transaction object with the address of the token/adapter you want to use to pay for gas fees.

Expand Down
42 changes: 20 additions & 22 deletions docs/developer/viem/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Using Viem with Celo

## Viem

Viem is full featured lightweight javascript library for interacting with EVM chains with *first class support for Celo*.
Viem is full featured lightweight javascript library for interacting with EVM chains with _first class support for Celo_.

Viem is used by [Wagmi](https://wagmi.sh/) and [Rainbowkit](https://www.rainbowkit.com/).

Expand All @@ -19,22 +19,21 @@ The TLDR is that passing a celo chain from `viem/chains` into the config of `cre
// see viem docs for more info on setup

// Create a wallet client that will sign the transaction
const client = createWalletClient({
account,
// Passing chain is how viem knows to try serializing tx as cip42.
chain: celoAlfajores,
transport: http(),
})

client.writeContract({
abi: ANY_CONTRACT_ABI,
address: ANY_CONTRACT_ABI_ADDRESS,
functionName: "contractMethod",
args: [to, parseEther(value)],
// set the fee currency on the contract write call
feeCurrency: FEE_CURRENCIES_ALFAJORES["cusd"]
})

const client = createWalletClient({
account,
// Passing chain is how viem knows to try serializing tx as cip42.
chain: celoAlfajores,
transport: http(),
});

client.writeContract({
abi: ANY_CONTRACT_ABI,
address: ANY_CONTRACT_ABI_ADDRESS,
functionName: "contractMethod",
args: [to, parseEther(value)],
// set the fee currency on the contract write call
feeCurrency: FEE_CURRENCIES_ALFAJORES["cusd"],
});
```

## Gas Price
Expand All @@ -46,12 +45,11 @@ async function getGasPrice(client, feeCurrencyAddress?: Address) {
const priceHex = await client.request({
method: "eth_gasPrice",
params: [feeCurrencyAddress],
})
return hexToBigInt(priceHex)
});
return hexToBigInt(priceHex);
}

tx.maxFeePerGas = await getGasPrice(client, tx.feeCurrency)

tx.maxFeePerGas = await getGasPrice(client, tx.feeCurrency);
```

For an interactive example of using viem with Celo's fee currency feature [see our demo](https://rainbowkit-with-celo.vercel.app/fee-currency)
For an interactive example of using viem with Celo's Fee Abstraction feature [see our demo](https://rainbowkit-with-celo.vercel.app/fee-currency)
2 changes: 1 addition & 1 deletion docs/protocol/transaction/erc20-transaction-fees.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Adapters can also be used to query `balanceOf(address)` of an account, but it wi

N/A

### Enabling Transactions with ERC20 Token as Fee Currency in a wallet
### Enabling Transactions with ERC20 Token as fee currency in a wallet

We recommend using the [viem](https://viem.sh/) library as it has support for the `feeCurrency` field in the transaction required for sending transaction where the gas fees will be paid in ERC20 tokens.

Expand Down
7 changes: 6 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ const sidebars = {
},
{
type: "doc",
label: "Fee Currency",
label: "Fee Abstraction",
id: "developer/fee-currency",
},
{
Expand Down Expand Up @@ -1137,6 +1137,11 @@ const sidebars = {
label: "Deploy Contract",
id: "cel2/deploy-contract",
},
{
type: "doc",
label: "Contract Addresses",
id: "cel2/contract-addresses",
},
{
type: "link",
label: "Cel2 Dango Bridge",
Expand Down

0 comments on commit 7c64f89

Please sign in to comment.