MetaMask Programmatic Setup on Celo | Celo Documentation (2024)

How dApp developers can use MetaMask to interact with the Celo network.

To add a Celo Network to your dApp, you can use MetaMask's RPC API's wallet_addEthereumChain method. (See documentation).

Here is a JavaScript snippet you can use:

await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [<INSERT_NETWORK_PARAMS_HERE>],
});

Where it says INSERT_NETWORK_PARAMS_HERE, please replace with any of the following constants, depending on which network you'd like to connect to.

Mainnet

const CELO_PARAMS = {
chainId: "0xa4ec",
chainName: "Celo",
nativeCurrency: { name: "Celo", symbol: "CELO", decimals: 18 },
rpcUrls: ["https://forno.celo.org"],
blockExplorerUrls: ["https://explorer.celo.org/"],
iconUrls: ["future"],
};

Alfajores

const ALFAJORES_PARAMS = {
chainId: "0xaef3",
chainName: "Alfajores Testnet",
nativeCurrency: { name: "Alfajores Celo", symbol: "A-CELO", decimals: 18 },
rpcUrls: ["https://alfajores-forno.celo-testnet.org"],
blockExplorerUrls: ["https://alfajores-blockscout.celo-testnet.org/"],
iconUrls: ["future"],
};

Adding Tokens (e.g. cUSD, cEUR)

To watch an asset on a Celo network (e.g. cUSD, cEUR) in your dApp, you can use MetaMask's RPC API's wallet_watchAsset method. (See documentation).

Here is a JavaScript snippet you can use:

await window.ethereum.request({
method: "wallet_watchAsset",
params: {
type: "ERC20",
options: {
address: "<INSERT_ADDRESS_HERE>",
symbol: "<INSERT_SYMBOL_HERE>",
decimals: 18,
},
iconUrls: ["future"],
},
});
  • Where it says INSERT_ADDRESS_HERE, please replace with any of the following constants, depending on which network and which asset you'd like to connect to.
  • Where it says INSERT_SYMBOL_HERE, please replace with the correct symbol for the asset you'd like to watch. For Celo Dollars, it's cUSD and for Celo Euros, it's cEUR.

tip

View available token addresses for Celo assets to add to MetaMask here.

warning

We strongly suggest that you disable your dApp's functionality when MetaMask is connected to a non-Celo network. MetaMask has an API for determining what network/chain you're connected to. See here for more documentation around that.

MetaMask Programmatic Setup on Celo | Celo Documentation (2024)
Top Articles
Thycotic | Thales
Construction Loans: What You Need To Know
$4,500,000 - 645 Matanzas CT, Fort Myers Beach, FL, 33931, William Raveis Real Estate, Mortgage, and Insurance
DPhil Research - List of thesis titles
Nyu Paralegal Program
Www.politicser.com Pepperboy News
Kansas Craigslist Free Stuff
Holly Ranch Aussie Farm
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
A Fashion Lover's Guide To Copenhagen
Craigslist Heavy Equipment Knoxville Tennessee
Saberhealth Time Track
Best Nail Salon Rome Ga
Cpt 90677 Reimbursem*nt 2023
Michael Shaara Books In Order - Books In Order
Craigslist Toy Hauler For Sale By Owner
Keck Healthstream
Little Rock Skipthegames
Inbanithi Age
Hannah Palmer Listal
Sand Dollar Restaurant Anna Maria Island
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Is Light Raid Hard
Wku Lpn To Rn
Delta Math Login With Google
Cavanaugh Photography Coupon Code
Inmate Search Disclaimer – Sheriff
Math Minor Umn
In Branch Chase Atm Near Me
JD Power's top airlines in 2024, ranked - The Points Guy
Yoshidakins
Ljw Obits
Jefferson Parish Dump Wall Blvd
Craigslist Georgia Homes For Sale By Owner
Los Garroberros Menu
South Bend Tribune Online
Yogu Cheshire
Colorado Parks And Wildlife Reissue List
More News, Rumors and Opinions Tuesday PM 7-9-2024 — Dinar Recaps
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
Lonely Wife Dating Club בקורות וחוות דעת משתמשים 2021
Kent And Pelczar Obituaries
Cocaine Bear Showtimes Near Cinemark Hollywood Movies 20
Paul Shelesh
Celsius Claims Agent
Martha's Vineyard – Travel guide at Wikivoyage
Brauche Hilfe bei AzBilliards - Billard-Aktuell.de
Avance Primary Care Morrisville
Gabrielle Abbate Obituary
Mmastreams.com
300 Fort Monroe Industrial Parkway Monroeville Oh
Peugeot-dealer Hedin Automotive: alles onder één dak | Hedin
Latest Posts
Article information

Author: Frankie Dare

Last Updated:

Views: 6060

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Frankie Dare

Birthday: 2000-01-27

Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

Phone: +3769542039359

Job: Sales Manager

Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.