paint-brush
How to Get Started on Celo with Infura RPC Endpointsby@0xpaulie
643 reads
643 reads

How to Get Started on Celo with Infura RPC Endpoints

by 0xPaulieNovember 29th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Learn about the Celo layer-one blockchain network and how to start building on it using Infura RPC Endpoints.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to Get Started on Celo with Infura RPC Endpoints
0xPaulie HackerNoon profile picture

Onboarding the next wave of users to Web3 is a massive undertaking that many projects in the ecosystem are building for. One project with a unique approach to this is Celo, a layer-one blockchain network. Celo gives a superior new-user experience by being a mobile-first layer-1 blockchain that is easy to use with just a mobile phone. Your phone number acts as your address rather than a complex string, and the network allows users the option to pay gas fees with other tokens than the native currency.

However, the user experience is just one side of the onboarding coin. Developer experience is the other. After all, a new network is just as good as the RPCs that let you use it. Only some developers have the resources to run a node.

Infura, one of the most popular Web3 node providers, now offers Celo Network RPC nodes to all users. So if you want to start building on this mobile-first network, there’s never been a better time. Before you start building, let’s learn more about Celo.

This article will provide a high-level overview of the Celo Blockchain Network and how you can start building on it using Infura.

What is Celo?

Celo is a high-throughput layer-1 networkthat focuses on mobile users.

Mapping Phone Numbers to Public Keys

Celo is easier for mobile phone users than other networks. Celo maps phone numbers to public keys, allowing users to send tokens to people who don’t have wallets. A decentralized attestation protocol does the mapping and links an account to a phone number. This service never receives the phone number in clear text to maintain privacy.

How Celo’s attestation protocol works – Image from celo.org



As a result, user experience is better than most blockchains, as all interactions are done through phone numbers, rather than 30+ character-long strings that are easy to make mistakes with and impossible to memorize.

Paying Gas Fees with ERC-20 Tokens

Another usability hurdle is that most networks require users to pay gas fees with a native token. This results in users exchanging other tokens for native ones just to be able to send transactions.

This is a problem for two reasons. First, it adds a non-trivial step to every transaction if the user doesn’t have enough native tokens. Second, exchanging tokens is taxable in some countries, so they need to keep track of each time they exchange to a native token just to cover gas fees.

With Celo, you can pay with any approved ERC-20 token currently available, even stablecoins, lowering yet another barrier to entry and making costs more predictable. However, there is one caveat: transactions paid with non-CELO gas currencies will cost roughly 50k additional gas. It’s also important to note that there is a governable list of accepted currencies.

When developing, Celo comes with a dapp SDK called ContractKit. This SDK is a suite of packages that make building on Celo more straightforward. Connect, one of ContractKit’s main packages, acts as a wrapper around web3.js that handles the different currencies to pay the fees.

You can set your preferred currency as default for all transactions, like in this example:


import { CeloContract } from "@celo/contractkit"

const accounts = await kit.web3.eth.getAccounts()
kit.defaultAccount = accounts[0]
await kit.setFeeCurrency(CeloContract.StableToken)


With this in your code, you are setting the default currency if the feeCurrencyfield is left blank when sending a transaction. The user can still select another currency to use.

ContractKit comes with a list of contract addresses that include all core Celo currencies. In the example CeloContract.StableTokenrefers to cUSD.

It’s also possible to set your preferred currency per transaction. In this example, we send cUSD and also pay with cUSD.


const contract = await kit.contracts.getStableToken()
await contract.transfer(recipientAddress, amount)
  .send({ feeCurrency: contract.address })


Celo’s virtual machine is also EVM compatible since it originated as a fork of Geth. This compatibility enables you to reuse most of your Solidity skills when deploying your smart contracts on Celo. However, there are some notable differences.

The first difference is that transaction objects have additional fields like feeCurrencygatewayFee, and gatewayFeeRecipient. They provide full-node incentives and allow users to pay their gas fees with different tokens. This doesn’t affect you when porting smart contracts from Ethereum to Celo, but it could be an issue when porting from Celo to Ethereum.

The second difference could have implications for your Ethereum-based smart contracts. The DIFFICULTY and GASLIMITopcodes aren’t supported, and the fields are also missing from block headers.

A third difference is that the key derivation path is m/44'/52752'/0'/0 and not m/44'/60'/0'/0like in Ethereum. Essentially, this derivation path allows wallets to generate different keys from one seed phrase.

The Network is Carbon Negative

CO2 production by blockchain networks has been a huge talking point in the last few years. Coming from Bitcoin, many of the early networks used the Proof-of-Work consensus algorithm to eliminate Sybil attacks.

The Celo protocol uses BFT Proof-of-Stake, which minimizes energy usage of the network by over 90%. Plus, it can create a new block in five seconds, less than half the time Ethereum needs.

Furthermore, all blocks are finalized immediately, so you and your users don’t have to wait for their actions to be written on-chain.

All this optimization still produces CO2, so Celo uses projects like Wren, a carbon offset subscription service that offsets 65.7 tons of CO2 monthly to get carbon negative. With tech-funded rainforest protection, Celo has already saved over 30,000 tons of CO2.


Why Use Celo with Infura?

Infura offers free RPCs for prominent wallets, and many big Web3 projectsuse them as their RPC provider, including Brave, Uniswap, Compound, Gnosis, and Maker, just to name a few. Additionally, Infura has achieved 99.99% uptime and about 10 times faster response times than other service providers like Alchemy or Quicknode.

ConsenSys, the company behind Infura also created and maintains crucial Web3 projects such as MetaMask and the Truffle Suite. So the shared know-how of creating wallets, dev tools, and RPCs creates synergies you won’t get from any other RPC provider. This also means you get trusted and complementary end-to-end tooling from the ConsenSys suite of products that flawlessly integrate with Infura RPCs.

With the release of Celo RPCs, Infura now supports 10 different networks, so you can build on multiple chains at once. Best of all, it’s free to access these networks and their archived data!


Summary

Celo is an exciting chain that tackles Web3 user and developer experience pain-points with innovative solutions. With its mobile-first approach, users can interact with the network and receive tokens with their phone number rather than a crypto wallet, making onboarding to the network easier for Web3 newcomers.

With the option to pay gas fees with other tokens rather than the native currency, Celo also removed a massive hurdle in the daily use of a blockchain network. Other networks require fees paid with a native and potentially volatile token.

Now that Infura offers RPC nodes for the Celo network, it’s the perfect time to start building on this mobile-first blockchain network. For more information, check out Infura’s docs.


Also Published Here