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
Spot Price
What is credit card forbearance?
Chris Provost Daughter Addie
Bashas Elearning
Noaa Charleston Wv
Obor Guide Osrs
Don Wallence Auto Sales Vehicles
Evil Dead Rise Showtimes Near Massena Movieplex
Obituaries
House Share: What we learned living with strangers
83600 Block Of 11Th Street East Palmdale Ca
Caliber Collision Burnsville
Chicken Coop Havelock Nc
Craigslist Pets Longview Tx
Craigslist Blackshear Ga
Craigslist Panama City Fl
Tamilrockers Movies 2023 Download
Swedestats
Pizza Hut In Dinuba
Walgreens San Pedro And Hildebrand
Www.publicsurplus.com Motor Pool
Graphic Look Inside Jeffrey Dahmer
Dragger Games For The Brain
Nsa Panama City Mwr
Student Portal Stvt
Mdt Bus Tracker 27
Inter Miami Vs Fc Dallas Total Sportek
4 Methods to Fix “Vortex Mods Cannot Be Deployed” Issue - MiniTool Partition Wizard
Pokemon Inflamed Red Cheats
Restored Republic
N.J. Hogenkamp Sons Funeral Home | Saint Henry, Ohio
Kamzz Llc
Trust/Family Bank Contingency Plan
A Plus Nails Stewartville Mn
Bitchinbubba Face
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
Citibank Branch Locations In Orlando Florida
Atom Tickets – Buy Movie Tickets, Invite Friends, Skip Lines
Luvsquad-Links
Ladyva Is She Married
Fedex Passport Locations Near Me
Juiced Banned Ad
Love Words Starting with P (With Definition)
Sechrest Davis Funeral Home High Point Nc
FedEx Authorized ShipCenter - Edouard Pack And Ship at Cape Coral, FL - 2301 Del Prado Blvd Ste 690 33990
Sapphire Pine Grove
Union Supply Direct Wisconsin
Lebron James Name Soundalikes
Pronósticos Gulfstream Park Nicoletti
Fresno Craglist
Parks And Rec Fantasy Football Names
Secondary Math 2 Module 3 Answers
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.