<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by josh on Medium]]></title>
        <description><![CDATA[Stories by josh on Medium]]></description>
        <link>https://medium.com/@joshc_?source=rss-7770a3d83e7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*R5yIeCYMoH5fFhEMOxquIA.jpeg</url>
            <title>Stories by josh on Medium</title>
            <link>https://medium.com/@joshc_?source=rss-7770a3d83e7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:57:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joshc_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introduction to creating NFTs on Celo]]></title>
            <link>https://medium.com/@joshc_/introduction-to-creating-nfts-on-celo-eb7240a71cc0?source=rss-7770a3d83e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb7240a71cc0</guid>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[erc721]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[celos]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[josh]]></dc:creator>
            <pubDate>Mon, 02 May 2022 16:18:53 GMT</pubDate>
            <atom:updated>2022-05-02T16:18:53.008Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial will walk through the basic steps required to create an NFT collection (of ERC-721 tokens) on Celo. There are more efficient ways to create large NFT collections that use scripting and APIs, but this tutorial will focus on using friendly user interfaces to help you build your understanding of the steps involved in the process.</p><h3>Getting Started</h3><p>In this example, we will be using <a href="https://ipfs.io/">IPFS</a> for off-chain storage, but you can use whatever off-chain storage mechanism you want. Decentralized storage services are preferred.</p><h3>Setup your wallet</h3><p>Install <a href="https://metamask.io/">Metamask</a>.</p><p><a href="https://docs.celo.org/getting-started/wallets/using-metamask-with-celo/manual-setup#adding-a-celo-network-to-metamask">Add the Celo network</a> to Metamask. We suggest adding the Alfajores testnet to Metamask as well, so you can test contract deployments before deploying to mainnet.</p><p>Add a small amount of CELO to your Metamask account. In this example, we will deploy to the Alfajores testnet, so we need Alfajores CELO, which you can get from the faucet <a href="https://celo.org/developers/faucet">here</a>.</p><h3>Prepare the NFT Metadata</h3><p><a href="https://nftschool.dev/reference/metadata-schemas/#intro-to-json-schemas">NFT metadata</a> is typically stored off-chain since storing data on blockchains is expensive. We will be storing the metadata on IPFS using Pinata.</p><p>Go to <a href="https://app.pinata.cloud/">https://app.pinata.cloud/</a> and sign up for an account if you don’t have one already. Pinata is a service that allows you to easily upload files to IPFS.</p><p>Upload your NFT images to IPFS. In this example, we are creating a set of NFTs that reference pictures of trees. I uploaded all of the images of trees to IPFS individually. The names of the images correspond to the token ID. This isn’t necessary, I just did it for convenience. Notice that each image has a corresponding CID hash, this is the unique identifier for that file or folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TUyal_ksaOjzPhWg" /><figcaption>Pinata dashboard</figcaption></figure><p>Once all of your images have been uploaded, you will need to prepare the token metadata in a new folder.</p><p>I created a folder called “prosper factory metadata”. You can view the contents of the folder <a href="https://gateway.pinata.cloud/ipfs/QmdmA3gwGukA8QDPH7Ypq1WAoVfX82nx7SaXFvh1T7UmvZ">here</a>. The folder contains 14 files, numbered 0–13. The names of these files are important. These file names correspond to the token ID of each NFT that will be created by the contract. Make sure that there are no extensions (.txt, .json, .jpeg, .png) on your files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*chHkn0xWh5vthSnG" /><figcaption>NFT metadata folder on IPFS</figcaption></figure><p>Click on one of the files. The files contain the NFT metadata. In this simple example, the metadata only contains a reference to the unique tree image. You can view the image in a browser that supports IPFS (we are using Brave) here. Each file should have a unique image reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wgCpfI2Fu1AOPqmd" /><figcaption>Basic NFT metadata</figcaption></figure><p>You will need to create a similarly structured folder containing metadata for all of the NFTs that you want to create.</p><p>Upload the folder containing all of the token metadata to IPFS. This will make your NFT data publicly available. I called mine“prosper factory metadata”. Note the CID (identifier) of this folder. I will use it shortly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AE6rnFuDz6b4F54E" /></figure><h3>Design and Deploy the Smart Contracts<a href="https://docs.celo.org/blog/2022/01/05/no-code-erc721#design-and-deploy-the-smart-contracts">​</a></h3><p>Go to <a href="https://docs.openzeppelin.com/contracts/4.x/wizard">https://docs.openzeppelin.com/contracts/4.x/wizard</a></p><p>Select ERC721 as the token choice.</p><p>Enter your token information.</p><p>I am calling my token the ProsperityFactory, symbol PF.</p><p>I entered the IPFS CID of the token metadata folder (prosper factory metadata) in the “Base URI” field. Be sure to add a trailing “/” to the base URI because the token ID will be appended to the end of the base URI to get the IPFS metadata file. So the complete Base URI for our NFT contract is ipfs://QmdmA3gwGukA8QDPH7Ypq1WAoVfX82nx7SaXFvh1T7UmvZ/. Again, you can view the folder <a href="https://gateway.pinata.cloud/ipfs/QmdmA3gwGukA8QDPH7Ypq1WAoVfX82nx7SaXFvh1T7UmvZ">here</a>.</p><p>I made the token “mintable” and it will automatically increment the token IDs as new tokens are minted. The counter starts at 0 and adds 1 to each successive token. It is important that the file contents of the IPFS metadata folder are labeled accordingly (ie. 0–13) and correspond to the token IDs.</p><p>The contract is also marked Ownable, meaning that only the owner of the contract (which is initially set to the account that deploys the contract) can mint new NFTs. You can remove the onlyOwner modifier on the safeMint function to allow anyone to mint NFTs from the contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u17W6bRsnuDbc3jM" /></figure><p>Click “Open in Remix”. Remix will pop open with your contract code already filled in. You can make any modifications you’d like to the contract in Remix.</p><p>Click the big blue button on the left side of Remix that says “Compile contract-xxxx.sol”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AnYwgvPj3inFaVVw" /></figure><p>Once the contract is compiled, click the Ethereum logo on the left side of the window. A new sidebar will appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iA5wMvCcjq9iWa5_" /></figure><p>In the “Environment” dropdown, select “Injected Web3”. This will connect Remix and Metamask. Make sure that Metamask is connected to the correct network. In this example, I am deploying to the Alfajores testnet, so I see a textbox below the dropdown that says Custom (44787) network. 44787 is the network id for Alfajores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*8-qereQAy_CrO7sk" /></figure><p>Select the contract that you want to deploy. We titled the contract the ProsperityFactory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/0*FZe0GNr4AZDyMxEO" /></figure><p>Click Deploy. Metamask will pop up asking to confirm the transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v88LWpx-MP2Zwp15" /></figure><p>Once the contract is deployed, Remix will show a newly deployed contract on the bottom left corner of the window. Expand the ProsperityFactory dropdown to see all of the contract functions. You can see the deployed ProsperityFactory NFT contract <a href="https://alfajores-blockscout.celo-testnet.org/address/0xD8ea7beC4820dbC22aCf87EB0cCFE50203a45A6F/transactions">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-FZ4DLKfmf1_nUpr" /></figure><p>Let’s mint the first NFT. To do that I will call the safeMint function. The safeMint function needs an account address as an input, so it knows who to mint the token to. I’ll just enter my first Metamask address and click the orange button. Metamask will pop up, confirm the transaction. When the transaction is confirmed, this will have minted the first NFT with token ID 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/0*jaw1vj8Yi54VqdXL" /></figure><p>Check the token metadata. You can verify that the token was minted by calling the “tokenURI” function with the expected token ID. We call the contract with token ID 0 and it returns an IPFS reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*wqrr9f2oXx7tJ0oS" /></figure><p>Navigating to this IPFS reference will show the token metadata for that NFT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DoX-nUfNqNj-3QK3" /></figure><p>Going to that IPFS reference will show the image for the token.</p><p>I went through the same process and minted all 14 NFTs from this contract.</p><p>That’s it! You now know how to create your own NFT contract with corresponding metadata!</p><p>Let me know what you end up building and reach out if you have any questions, <a href="https://twitter.com/critesjosh_">@critesjosh_</a> on Twitter or joshc#0001 on Discord. Join the Celo discord at <a href="https://chat.celo.org/">https://chat.celo.org</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb7240a71cc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Verifying Contracts with Hardhat]]></title>
            <link>https://medium.com/celodevelopers/verifying-contracts-with-hardhat-c4bcc191389b?source=rss-7770a3d83e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4bcc191389b</guid>
            <category><![CDATA[sourcify]]></category>
            <category><![CDATA[celos]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[hard-hat]]></category>
            <dc:creator><![CDATA[josh]]></dc:creator>
            <pubDate>Mon, 02 May 2022 16:18:06 GMT</pubDate>
            <atom:updated>2022-05-02T16:18:06.523Z</atom:updated>
            <content:encoded><![CDATA[<p>Hardhat is one of the most popular developer tools for writing contracts for EVM compatible blockchains. Hardhat is a great tool for developing smart contracts for Celo — you can find more information about this in the Celo documentation <a href="https://docs.celo.org/developer-resources/deploy-hardhat">here</a>.</p><p>In this tutorial I will go over how to use the <a href="https://github.com/wighawag/hardhat-deploy">hardhat-deploy plugin</a> for hardhat, specifically to verify deployed contracts on the <a href="https://explorer.celo.org/">Celo block explorer</a> via <a href="https://sourcify.dev/">Sourcify</a>. You can verify contracts with the plugin whether you deployed them using the plugin or not.</p><p>In this post I will cover</p><ul><li>setting up a hardhat project with the hardhat-deploy plugin</li><li>deploying contracts using the plugin</li><li>how to verify the contracts on sourcify</li></ul><h3>Verify contracts using hardhat-deploy<a href="https://docs.celo.org/blog/hardhat-deploy-verify#verify-contracts-using-hardhat-deploy">​</a></h3><h3>Setup<a href="https://docs.celo.org/blog/hardhat-deploy-verify#setup">​</a></h3><p>First, I will cover how to deploy contracts using the plugin. This will help provide some context around how a project using this plugin is different from a regular hardhat project. This guide assumes that you already have a hardhat project set up. If you don’t, refer to <a href="https://docs.celo.org/developer-resources/deploy-hardhat">this page</a>.</p><p>TIP</p><p>You can reference the ‘hardhat-deploy’ branch of <a href="https://github.com/critesjosh/celo-hardhat/tree/hardhat-deploy">this github repo</a> to see how the project is structured.</p><p>Install the plugin in your hardhat project:</p><pre>npm install -D hardhat-deploy</pre><p>Import the plugin in your hardhat.config.js file.</p><pre>require(&#39;hardhat-deploy&#39;);</pre><p>Since hardhat-deploy-ethers is a fork of @nomiclabs/hardhat-ethers and that other plugin might have an hardcoded dependency on @nomiclabs/hardhat-ethers the best way to install hardhat-deploy-ethers and ensure compatibility is the following:</p><pre>npm install --save-dev  @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers</pre><p>Which means you then need to do require(&quot;@nomiclabs/hardhat-ethers&quot;) instead of require(&quot;hardhat-deploy-ethers&quot;) in your hardhat.config.js file.</p><p>The plugin also supports Typescript, which you can find more information about <a href="https://github.com/wighawag/hardhat-deploy#typescript-support">here</a>.</p><p>The plugin also has a concept of namedAccounts which makes it easier to reference available accounts. You can read more about the details <a href="https://github.com/wighawag/hardhat-deploy#1-namedaccounts-ability-to-name-addresses">here</a>. For our purposes, keep it simple and add namedAccounts to the exports in hardhat.config.js like so</p><pre>//hardhat.config.js<br>...<br>module.exports = {<br> defaultNetwork: &quot;alfajores&quot;,<br> namedAccounts: {<br>   deployer: 0<br> },<br> networks: {<br>...</pre><p>You can see my source file <a href="https://github.com/critesjosh/celo-hardhat/blob/085cf7bc304ec3b0924de1419fe32e37b57e7185/hardhat.config.js#L23">here</a>.</p><h3>Deploy<a href="https://docs.celo.org/blog/hardhat-deploy-verify#deploy">​</a></h3><p>Deployment scripts used by hardhat-deploy live in a folder called deploy in the root of the project. The deployment scripts will save deployment information in a deployments folder in the project root as well.</p><p><a href="https://github.com/critesjosh/celo-hardhat/blob/hardhat-deploy/deploy/00-deploy.js">Here</a> is the deployment script for deploying the <a href="https://github.com/critesjosh/celo-hardhat/blob/hardhat-deploy/contracts/Greeter.sol">Greeter contract</a> in the example repo.</p><pre>// deploy/00_deploy_my_contract.js<br>module.exports = <em>async</em> ({getNamedAccounts, deployments}) =&gt; {<br>   <em>const</em> {deploy} = deployments;<br>   <em>const</em> {deployer} = <em>await</em> getNamedAccounts();<br>   <em>await</em> deploy(&#39;Greeter&#39;, {<br>     <em>from</em>: deployer,<br>     args: [&quot;hello world&quot;],<br>     log: true,<br>   });<br> };<br> module.exports.tags = [&#39;Greeter&#39;];</pre><p>It is a simple function that takes the namedAccounts, configuration info and the contract constructor arguments and deploys the contract. You can read more about deploy scripts <a href="https://github.com/wighawag/hardhat-deploy#deploy-scripts">here</a>.</p><p>To run the deployment, use the command</p><pre>npx hardhat --network alfajores deploy</pre><p>There should be terminal output similar to this:</p><pre>Downloading compiler 0.8.4<br>Compiling 1 file with 0.8.4<br>Compilation finished successfully<br>deploying &quot;Greeter&quot; (tx: 0x7fedbd14877cdca23485a96108e22ae6764b65348eddbaa1cbec9504707b7186)...: deployed at 0x9F163C9138faA5cdc731b94E1e9632C05764C23e with 493178 gas</pre><h3>Verify<a href="https://docs.celo.org/blog/hardhat-deploy-verify#verify">​</a></h3><p>Once the contract is deployed, you can verify it with the command:</p><pre>npx hardhat --network alfajores sourcify</pre><p>Which should output</p><pre>verifying Greeter (0x9F163C9138faA5cdc731b94E1e9632C05764C23e on chain 44787) ...<br> =&gt; contract Greeter is now verified</pre><p>You can check the verification on the block explorer, <a href="https://alfajores-blockscout.celo-testnet.org/address/0x9F163C9138faA5cdc731b94E1e9632C05764C23e/contracts">https://alfajores-blockscout.celo-testnet.org/address/0x9F163C9138faA5cdc731b94E1e9632C05764C23e/contracts</a> in this case.</p><p>I hope this is helpful and feel free to <a href="https://chat.celo.org/">join the Celo Discord</a> server and reach out if you have any questions. My handle is joshc#0001.</p><p>You can view my hardhat-deploy repository for reference on GitHub here: <a href="https://github.com/critesjosh/celo-hardhat/tree/hardhat-deploy">https://github.com/critesjosh/celo-hardhat/tree/hardhat-deploy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4bcc191389b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/celodevelopers/verifying-contracts-with-hardhat-c4bcc191389b">Verifying Contracts with Hardhat</a> was originally published in <a href="https://medium.com/celodevelopers">Celo Academy Community Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending CELO & Stable Coins]]></title>
            <link>https://medium.com/celodevelopers/sending-celo-stable-coins-65fbcdbce078?source=rss-7770a3d83e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/65fbcdbce078</guid>
            <category><![CDATA[celos]]></category>
            <category><![CDATA[token]]></category>
            <dc:creator><![CDATA[josh]]></dc:creator>
            <pubDate>Mon, 02 May 2022 16:13:47 GMT</pubDate>
            <atom:updated>2022-05-02T16:13:47.270Z</atom:updated>
            <content:encoded><![CDATA[<p>How to connect to the Celo test network and transfer tokens using ContractKit.</p><h3>Hello Celo: sending value with Celo<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#hello-celo-sending-value-with-celo">​</a></h3><p>In this guide we are going to write a Node.js script to introduce some of the basic concepts that are important to understand how Celo works. This will get us started with connecting to the Celo network and learning how to develop more advanced applications.</p><p>We assume you already have Node.js and NPM installed on your computer.</p><h3>Learning Objectives<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#learning-objectives">​</a></h3><p>At the end of this guide, you will be able to:</p><ul><li>Connect to the Celo test network, called Alfajores</li><li>Get test CELO, Celo Dollars (cUSD) and Celo Euros (cEUR) from the faucet</li><li>Read account and contract information from the test network</li><li>Transferring CELO, cUSD and cEUR on the test network</li></ul><h3>Getting Started<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#getting-started">​</a></h3><p>To start, <a href="https://github.com/critesjosh/helloCelo">clone this GitHub repo</a>. This is a Node.js application.</p><pre>git clone <a href="https://github.com/critesjosh/helloCelo.git">https://github.com/critesjosh/helloCelo.git</a></pre><p>We will be using the Celo ContractKit SDK to interact with the Celo test network (Alfajores). Let’s install it. It is already defined in the package.json, so we can get it with</p><pre>cd helloCelo<br>npm install</pre><h3>Importing ContractKit<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#importing-contractkit">​</a></h3><p>We will be writing our Node.js app in the helloCelo.js file.</p><p>Import the contract kit into our script with</p><pre>// helloCelo.js</pre><pre>// 1. Import web3 and contractkit<br><em>const</em> Web3 = require(&quot;web3&quot;);<br><em>const</em> ContractKit = require(&quot;@celo/contractkit&quot;);</pre><p>Now we can use the ContractKit to connect to the test network.</p><pre>// helloCelo.js</pre><pre>// 2. Init a new kit, connected to the alfajores testnet<br><em>const</em> web3 = <em>new</em> Web3(&quot;https://alfajores-forno.celo-testnet.org&quot;);<br><em>const</em> kit = ContractKit.newKitFromWeb3(web3);</pre><p>At any point in the file you can console.log() variables to print their output when you run the script.</p><h3>Reading from Alfajores<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#reading-alfajores">​</a></h3><p>ContractKit contains a contracts property that we can use to access certain information about deployed Celo contracts.</p><p>The Celo blockchain has two native assets, CELO (CELO) and the Celo Dollar (cUSD). Both of these assets implement the <a href="https://eips.ethereum.org/EIPS/eip-20">ERC20 token standard</a> from Ethereum. The CELO asset is managed by the CELO smart contract and Celo Dollars is managed by the cUSD contract. We can access the CELO contract via the SDK with kit.contracts.getGoldToken() and the cUSD contract with kit.contracts.getStableToken(). These functions return promises, so we have to wait for them to resolve before we can interact with the token contracts. If you are unfamiliar with Promises in Javascript, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">check out this documentation.</a> Promises are a common tool in blockchain development. In this guide, we use the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await">async/await syntax for promises</a>.</p><p>Let’s read some token balances from the blockchain. Add the following line in the readAccount() function.</p><pre>// helloCelo.js</pre><pre>// 3. Get the token contract wrappers<br><em>let</em> celotoken = <em>await</em> kit.contracts.getGoldToken();<br><em>let</em> cUSDtoken = <em>await</em> kit.contracts.getStableToken();<br><em>let</em> cEURtoken = <em>await</em> kit.contracts.getStableToken(&quot;cEUR&quot;);</pre><p>We can get the CELO balance of an account using the token wrappers like goldtoken.balanceOf(address). Let&#39;s check the balance of this address &#39;0xD86518b29BB52a5DAC5991eACf09481CE4B0710d&#39;.</p><pre>// helloCelo.js</pre><pre>// 4. Address to look up<br><em>let</em> anAddress = &quot;0xD86518b29BB52a5DAC5991eACf09481CE4B0710d&quot;;</pre><pre>// 5. Get token balances<br><em>let</em> celoBalance = <em>await</em> celotoken.balanceOf(anAddress);<br><em>let</em> cUSDBalance = <em>await</em> cUSDtoken.balanceOf(anAddress);<br><em>let</em> cEURBalance = <em>await</em> cEURtoken.balanceOf(anAddress);</pre><pre>// Print balances<br>console.log(`${anAddress} CELO balance: ${celoBalance.toString()}`);<br>console.log(`${anAddress} cUSD balance: ${cUSDBalance.toString()}`);<br>console.log(`${anAddress} cEUR balance: ${cEURBalance.toString()}`);</pre><p>The balanceOf(address) function also returns a Promise, so we wait for the promise to resolve then we print the result.</p><p>To view the balances, run the script from the termainal with</p><pre>node helloCelo.js</pre><p>Note that the balanceOf() function returns objects with type <a href="https://github.com/MikeMcl/bignumber.js/">BigNumber</a> because balances are represented in Celo as a 256 bit unsigned integer, and JavaScript&#39;s number type cannot safely handle numbers of that size. Note also that the balance values are reported in units of CELO Wei, where one CELO = 10**18 CELO Wei.</p><p>Reading all account balances is a powerful feature of blockchains. Next, let’s see how we can send value to each other on the testnet.</p><p>In order to do transfers (aka <a href="https://docs.celo.org/getting-started/glossary#transaction">transactions</a>), we need to:</p><ol><li>Create an <a href="https://docs.celo.org/getting-started/glossary#account">account</a> (by creating a private key)</li><li>Fund it with test CELO and cUSDs</li><li>Sign and send transactions to the network</li></ol><h3>Accounts<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#accounts">​</a></h3><p>We are accessing the Celo network via a remote <a href="https://docs.celo.org/getting-started/glossary#node">node</a> via HTTP requests at &#39;https://alfajores-forno.celo-testnet.org&#39;.</p><p>Don’t worry about what this means right now, just understand that it is easier to get started using Celo by accessing remote nodes, rather than running them locally on your machine. You can <a href="https://github.com/critesjosh/celo-monorepo/tree/8542c1bc3ad32bc48eed33073f4d34a36fd91fae/packages/docs/celo-sdk/walkthroughs/overview.md#topology-of-a-celo-network">read more about the details of the Celo network here.</a></p><p>Because we are accessing the network remotely, we need to generate an account to sign transactions and fund that account with test CELO.</p><p>There is a short script in getAccount.js to either get a Celo account from a mnemonic in the .secret file, or create a random account if the file is empty. In the script, we useweb3.js to create a new private key/account pair. <a href="https://web3js.readthedocs.io/">Web3.js</a> is a popular javascript library for handling Ethereum related functionality. Celo is a cousin of Ethereum, so this library works well for generating Celo accounts.</p><p>!!! This is not the standard way of managing Celo accounts. In a production environment, the <a href="https://docs.celo.org/celo-codebase/wallet">Celo Wallet</a> will manage accounts for you. Accessing accounts from the Celo Wallet will be discussed in future guides.</p><p>We can now use this account to get account information (ie the private key and account address) and to send transactions from account.address. Add the following code to read the account balance. Continue adding to helloCelo.js.</p><pre>// helloCelo.js</pre><pre>//<br>// Create an Account<br>//</pre><pre>// 6. Import the getAccount function<br><em>const</em> getAccount = require(&quot;./getAccount&quot;).getAccount;</pre><pre><em>async</em> <em>function</em> getBalances() {<br>  // 7. Get your account<br>  <em>let</em> account = <em>await</em> getAccount();</pre><pre>  // 8. Get the token contract wrappers<br>  <em>let</em> celotoken = <em>await</em> kit.contracts.getGoldToken();<br>  <em>let</em> cUSDtoken = <em>await</em> kit.contracts.getStableToken();<br>  <em>let</em> cEURtoken = <em>await</em> kit.contracts.getStableToken(&quot;cEUR&quot;);</pre><pre>  // 9. Get your token balances<br>  <em>let</em> celoBalance = <em>await</em> celotoken.balanceOf(account.address);<br>  <em>let</em> cUSDBalance = <em>await</em> cUSDtoken.balanceOf(account.address);<br>  <em>let</em> cEURBalance = <em>await</em> cEURtoken.balanceOf(account.address);</pre><pre>  // Print your account info<br>  console.log(`Your account address: ${account.address}`);<br>  console.log(`Your account CELO balance: ${celoBalance.toString()}`);<br>  console.log(`Your account cUSD balance: ${cUSDBalance.toString()}`);<br>  console.log(`Your account cEUR balance: ${cEURBalance.toString()}`);<br>}</pre><p>Run this script again with node helloCelo.js. This will print 0, as we have not funded the associated account yet.</p><h3>Using the faucet<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#using-the-faucet">​</a></h3><p>We can get free test CELO and cUSDs on the test network for development via <a href="https://celo.org/build/faucet">the Celo Alfajores faucet</a>.</p><p>Copy your randomly generated account address from the console output mentioned above, and paste it into the faucet.</p><p>Once your account has been funded, run $ node helloCelo.js again to see your updated balance.</p><h3>Sending Value<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#sending-value">​</a></h3><p>We have an account with CELO and cUSD in it, now how do we send tokens to another account? Remember the token wrappers we used to read account balances earlier? We can use the same wrappers to send tokens, you just need to add the private key associated with your account to ContractKit (see line 10).</p><p>The token wrappers have a method called transfer(address, amount) that allows you to send value to the specified address (line 14).</p><p>You need to send() the transaction to the network after you construct it. The send() methods accepts an option that allows you to specify the feeCurrency, which allows the sender to pay transaction fees in CELO or cUSD. The default feeCurrency is CELO. In the following example, let&#39;s pay transaction fees in CELO when we transfer CELO and pay with cUSD when we transfer cUSD.</p><p>The send() method returns a transaction object. We will wait for the transaction receipt (which will be returned when the transaction has been included in the blockchain) and print it when we get it. This receipt contains information about the transaction.</p><p>After we read the receipt, we check the balance of our account again, using the balanceOf() function. The logs print our updated balance!</p><p>You may notice that the account balance is a bit smaller than the amount of tokens that we sent. This is because you have to pay for every update to the network.</p><p>Add the following code to the send() function in helloCelo.js to send a transaction.</p><pre>// helloCelo.js</pre><pre><em>async</em> <em>function</em> send() {<br>  // 10. Get your account<br>  <em>let</em> account = <em>await</em> getAccount();</pre><pre>  // 11. Add your account to ContractKit to sign transactions<br>  kit.connection.addAccount(account.privateKey);</pre><pre>  // 12. Specify recipient Address<br>  <em>let</em> anAddress = &quot;0xD86518b29BB52a5DAC5991eACf09481CE4B0710d&quot;;</pre><pre>  // 13. Specify an amount to send<br>  <em>let</em> amount = 100000;</pre><pre>  // 14. Get the token contract wrappers<br>  <em>let</em> celotoken = <em>await</em> kit.contracts.getGoldToken();<br>  <em>let</em> cUSDtoken = <em>await</em> kit.contracts.getStableToken();<br>  <em>let</em> cEURtoken = <em>await</em> kit.contracts.getStableToken(&quot;cEUR&quot;);</pre><pre>  // 15. Transfer CELO and cUSD from your account to anAddress<br>  // Optional: specify the feeCurrency, default feeCurrency is CELO<br>  <em>let</em> celotx = <em>await</em> celotoken<br>    .transfer(anAddress, amount)<br>    .send({ <em>from</em>: account.address });<br>  <em>let</em> cUSDtx = <em>await</em> cUSDtoken<br>    .transfer(anAddress, amount)<br>    .send({ <em>from</em>: account.address, feeCurrency: cUSDtoken.address });<br>  <em>let</em> cEURtx = <em>await</em> cEURtoken<br>    .transfer(anAddress, amount)<br>    .send({ <em>from</em>: account.address });</pre><pre>  // 16. Wait for the transactions to be processed<br>  <em>let</em> celoReceipt = <em>await</em> celotx.waitReceipt();<br>  <em>let</em> cUSDReceipt = <em>await</em> cUSDtx.waitReceipt();<br>  <em>let</em> cEURReceipt = <em>await</em> cEURtx.waitReceipt();</pre><pre>  // 17. Print receipts<br>  console.log(&quot;CELO Transaction receipt: %o&quot;, celoReceipt);<br>  console.log(&quot;cUSD Transaction receipt: %o&quot;, cUSDReceipt);<br>  console.log(&quot;cEUR Transaction receipt: %o&quot;, cEURReceipt);</pre><pre>  // 18. Get your new balances<br>  <em>let</em> celoBalance = <em>await</em> celotoken.balanceOf(account.address);<br>  <em>let</em> cUSDBalance = <em>await</em> cUSDtoken.balanceOf(account.address);<br>  <em>let</em> cEURBalance = <em>await</em> cEURtoken.balanceOf(account.address);</pre><pre>  // 19. Print new balance<br>  console.log(`Your new account CELO balance: ${celoBalance.toString()}`);<br>  console.log(`Your new account cUSD balance: ${cUSDBalance.toString()}`);<br>  console.log(`Your new account cUSD balance: ${cEURBalance.toString()}`);<br>}</pre><p>Run $ node helloCelo.js again to send the transactions and see the printed output in the console.</p><h3>Connecting to a Ledger Device from a Web Application<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#connecting-to-a-ledger-device-from-a-web-application">​</a></h3><p>The above instructions apply to building NodeJS applications. If you want to build an integration with a web application, you can still use the ContractKit by following slightly modified instructions.</p><p>The following code examples are typescript so should be stored in a .tsc file, you will also need to install typescript and then compile your typescript to javascript with npx tsc before you can run the code with node.</p><pre>npm install --save-dev typescript<br>npm install web3 @celo/contractkit @celo/wallet-ledger @ledgerhq/hw-app-eth @ledgerhq/hw-transport-u2f @ledgerhq/hw-transport-webusb</pre><p>Then, you can create a new instance of the ContractKit with the following code:</p><pre><em>import</em> { ContractKit, newKitFromWeb3 } <em>from</em> &quot;@celo/contractkit&quot;;<br><em>import</em> { newLedgerWalletWithSetup } <em>from</em> &quot;@celo/wallet-ledger&quot;;<br><em>import</em> Eth <em>from</em> &quot;@ledgerhq/hw-app-eth&quot;;<br><em>import</em> TransportU2F <em>from</em> &quot;@ledgerhq/hw-transport-u2f&quot;;<br><em>import</em> TransportUSB <em>from</em> &quot;@ledgerhq/hw-transport-webusb&quot;;<br><em>import</em> Web3 <em>from</em> &quot;web3&quot;;</pre><pre>// Handle getting the Celo Ledger transport.<br><em>const</em> getCeloLedgerTransport = () =&gt; {<br>  <em>if</em> (<em>window</em>.USB) {<br>    <em>return</em> TransportUSB.create();<br>  } <em>else</em> <em>if</em> (<em>window</em>.u2f) {<br>    <em>return</em> TransportU2F.create();<br>  }</pre><pre>  <em>throw</em> <em>new</em> Error(<br>    &quot;Ledger Transport not support, please use Chrome, Firefox, Brave, Opera or Edge.&quot;<br>  );<br>};</pre><pre>// Handle creating a new Celo ContractKit<br><em>const</em> getContractKit = <em>async</em> () =&gt; {<br>  // Create a Web3 provider by passing in the testnet/mainnet URL<br>  <em>const</em> web3 = <em>new</em> Web3(&quot;https://alfajores-forno.celo-testnet.org&quot;);</pre><pre>  // Get the appropriate Ledger Transport<br>  <em>const</em> transport = <em>await</em> getCeloLedgerTransport();</pre><pre>  // Create a new instance of the ETH Ledger Wallet library<br>  <em>const</em> eth = <em>new</em> Eth(transport);</pre><pre>  // Use the Celo Ledger Wallet setup util<br>  <em>const</em> wallet = <em>await</em> newLedgerWalletWithSetup(eth.transport);</pre><pre>  // Instantiate the ContractKit<br>  <em>const</em> kit: ContractKit = newKitFromWeb3(web3, wallet);</pre><pre>  <em>return</em> kit;<br>};</pre><p>Once you have successfully created the ContractKit, you can use the various Celo contracts to sign transactions with a connected Ledger device. For example, here’s how to transfer gold tokens (just like above in the NodeJS example):</p><pre>// Use the gold token contract to transfer tokens<br><em>const</em> transfer = <em>async</em> (<em>from</em>, to, amount) =&gt; {<br>  <em>const</em> celoTokenContract = <em>await</em> kit.contracts.getGoldToken();<br>  <em>const</em> tx = <em>await</em> celoTokenContract.transfer(to, amount).send({ <em>from</em> });<br>  <em>const</em> receipt = <em>await</em> tx.waitReceipt();<br>  console.log(&quot;Transaction Receipt: &quot;, receipt);<br>};</pre><p>This is the basic setup to integrate the Celo Ledger App with a web application. You can also view the <a href="https://github.com/celo-org/celo-ledger-web-app">Celo Ledger App example codebase</a> for some other examples of connecting to a Ledger Device from a web application.</p><h3>Wrapping Up<a href="https://docs.celo.org/blog/developer-guide/start/hellocelo#wrapping-up">​</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dv64z1YvqLAxRILlSxiO_w.png" /></figure><p>Congratulations! You have accomplished a lot in this short introduction to developing on Celo.</p><p>We covered:</p><ul><li>Installing and setting up ContractKit</li><li>Connecting to the Celo Alfajores network</li><li>Getting the CELO contract wrapper</li><li>Reading account balances using the CELO wrapper</li><li>Generating a new account in Celo</li><li>Funding an account using the Celo Alfajores Faucet</li><li>Sending CELO</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65fbcdbce078" width="1" height="1" alt=""><hr><p><a href="https://medium.com/celodevelopers/sending-celo-stable-coins-65fbcdbce078">Sending CELO &amp; Stable Coins</a> was originally published in <a href="https://medium.com/celodevelopers">Celo Academy Community Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy & Mint a Token on Celo]]></title>
            <link>https://medium.com/celodevelopers/deploy-mint-a-token-on-celo-a80085c46ad2?source=rss-7770a3d83e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a80085c46ad2</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[remix]]></category>
            <category><![CDATA[token]]></category>
            <category><![CDATA[celos]]></category>
            <dc:creator><![CDATA[josh]]></dc:creator>
            <pubDate>Mon, 02 May 2022 16:03:39 GMT</pubDate>
            <atom:updated>2022-05-02T16:03:39.910Z</atom:updated>
            <content:encoded><![CDATA[<p>How to deploy a token contract that use the ERC20 token standard to Celo without writing code.</p><h3>Getting Started<a href="https://docs.celo.org/blog/2022/01/04/no-code-erc20#getting-started">​</a></h3><p>In this tutorial, we will go over how to deploy an ERC20 token contract. The process is very similar for deploying other tokens as well.</p><ol><li>Install <a href="https://metamask.io/">Metamask</a>.</li><li><a href="https://docs.celo.org/getting-started/wallets/using-metamask-with-celo/manual-setup#adding-a-celo-network-to-metamask">Add the Celo network</a> to Metamask. We suggest adding the Alfajores testnet to Metamask as well, so you can test contract deployments before deploying to mainnet.</li><li>Add a small amount of CELO to your Metamask account. In this example, we will deploy to the Alfajores testnet, so we need Alfajores CELO, which you can get from the faucet <a href="https://celo.org/developers/faucet">here</a>.</li><li>Go to the <a href="https://docs.openzeppelin.com/contracts/4.x/wizard">Open Zeppelin Contracts Wizard</a>.</li><li>Select ERC20 as the type of contract that you would like to deploy.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*--Z4TurHP7rwm8Xy" /></figure><ol><li>Name your token. We are calling our token “ProsperityToken” in this example.</li><li>Select the features for your token. We are making ProsperityToken mintable, burnable and enabling snapshots, so the token may be used for governance. We are also making the contract Ownable, so the deployer of the contract can mint new tokens and distribute them as desired. Ideally, the owner account will be a multi-signature contract, so no single person has control over this token contract. If you want the block explorer to recognize your token then leave “Upgradeability” unchecked and do not select one of the two radio options below it. Selecting one of these options will prevent the <a href="https://explorer.celo.org/">Celo block explorer</a> from recognizing your deployed contract as a token. If you want upgradability and do not care about the block explorer, feel free to make your token contract upgradable.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O_jQbFR3hZuJAxQa" /></figure><ol><li>Open your contract in Remix by clicking “Open in Remix”. Remix will pop open with the contract code already filled in.</li><li>Click the big blue button that says “Compile contract-xxxxx.sol”. The contract should compile without error.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zZ06AsDPcM7Q4oct" /></figure><ol><li>Click the Ethereum logo in the left sidebar. This will bring up a new interface for deploying the contract.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3qKWkma9PHYrDt9C" /></figure><ol><li>In the “Environment” section on the top left, select “Injected Web3”. This will connect Remix to Metamask. Now clicking the “deploy” button will deploy the contracts to whichever network Metamask is connected to. You should see a small textbox indicating that Remix is connected to a custom network. The Alfajores network id is 44787.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*DBkLrK-SF3PJsW7p" /></figure><ol><li>In the Contract dropdown, select the contract that you want to deploy. In this example, it is called ProsperityToken.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*uGZl97e7IX2AS6LM" /></figure><ol><li>Click Deploy. Metamask should pop open.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_R3Ibu4cQWhPbA-T" /></figure><ol><li>Click Confirm. Once the transaction confirms (less than 5 seconds), a contract interface will appear in the bottom left, and transaction details will appear in the console at the bottom.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h1eeY5Nx9oE9YTs8" /></figure><p>That’s it! We now have ProsperityToken deployed on Alfajores with the Metamask account as the contract owner.</p><p>You can see the contract information on the <a href="https://alfajores-blockscout.celo-testnet.org/">Alfajores block explorer</a>. Copy and paste the contract address or deployment transaction hash from the console output and paste it into the block explorer search bar or look up the deployment transaction info in the Metamask activity.</p><h3>Deploying your token on the Mainnet<a href="https://docs.celo.org/blog/2022/01/04/no-code-erc20#deploying-your-token-on-the-mainnet">​</a></h3><p>When you’re ready to deploy your token to the Celo Mainnet make sure to change the network of your connected wallet from Alfajores to the Celo Mainnet. Once you have done this you can simply redeploy the contract (you will not need to recompile it).</p><p>Note: When deploying to the Mainnet you will need to use real Celo to pay the gas fee (as opposed to using the faucet on the testnet). As of December 2021 this cost is less than $0.01 US. You can learn how to <a href="https://celo.org/buy">get Celo here</a>.</p><p>You can read about how to add your new token to the Celo Wallet <a href="https://docs.celo.org/blog/add-token-celo-wallet">here</a>.</p><h3>Verify<a href="https://docs.celo.org/blog/2022/01/04/no-code-erc20#verify">​</a></h3><p>If you are unable to view your token on the block explorer, you may need to Verify it first. If you are able to see your token, you may skip this section.</p><p>Verifying your contract with Remix is straight-forward and allows anyone to read and interact with the contract on the block explorer. You can read more about verifying a contract with Remix on <a href="https://docs.celo.org/developer-resources/deploy-remix#verify-the-smart-contract">this page</a>.</p><p>You can find my example contract <a href="https://alfajores-blockscout.celo-testnet.org/address/0x97d550A2540F902F4501e21A6c09f12B69173261/transactions">here</a>.</p><p>Let me know what you end up building and reach out if you have any questions, <a href="https://twitter.com/critesjosh_">@critesjosh_</a> on Twitter or joshc#0001 on Discord. Join the Celo discord at <a href="https://chat.celo.org/">https://chat.celo.org</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a80085c46ad2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/celodevelopers/deploy-mint-a-token-on-celo-a80085c46ad2">Deploy &amp; Mint a Token on Celo</a> was originally published in <a href="https://medium.com/celodevelopers">Celo Academy Community Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Celo Valora + WalletConnect v1]]></title>
            <link>https://medium.com/@joshc_/celo-valora-walletconnect-v1-7fc105455779?source=rss-7770a3d83e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fc105455779</guid>
            <category><![CDATA[valora]]></category>
            <category><![CDATA[celos]]></category>
            <category><![CDATA[walletconnect]]></category>
            <dc:creator><![CDATA[josh]]></dc:creator>
            <pubDate>Mon, 02 May 2022 16:01:26 GMT</pubDate>
            <atom:updated>2022-05-02T16:26:20.516Z</atom:updated>
            <content:encoded><![CDATA[<p>How to use <a href="https://docs.walletconnect.com/1.0/">WalletConnect version 1</a> in a DApp to connect to <a href="https://valoraapp.com/">Valora</a>.</p><h3>Getting Started<a href="https://docs.celo.org/blog/2022/01/08/valora-wc-v1#getting-started">​</a></h3><p>In this example, we will demonstrate how to add WalletConnect to a simple React app.</p><p>This is a simple DApp that focuses on demonstrating how to connect WalletConnect to Valora, but also shows how to set up <a href="https://docs.celo.org/developer-guide/contractkit">ContractKit</a> and make a simple cUSD transfer. You can view the DApp code <a href="https://github.com/critesjosh/valora-wallet-connect-v1">here</a>.</p><h3>Add Packages<a href="https://docs.celo.org/blog/2022/01/08/valora-wc-v1#add-packages">​</a></h3><p>Add the packages that you need to your project.</p><ul><li><a href="https://www.npmjs.com/package/@walletconnect/web3-provider">@walletconnect/web3-provider</a></li><li><a href="https://www.npmjs.com/package/@celo/contractkit">Contractkit</a></li><li><a href="https://www.npmjs.com/package/web3">Web3</a></li></ul><pre>yarn add @wallet-connect/web3-provider web3 @celo/contractkit</pre><p>Import the packages to your project code.</p><pre><em>import</em> WalletConnectProvider <em>from</em> &quot;@walletconnect/web3-provider&quot;;<br><em>import</em> Web3 <em>from</em> &quot;web3&quot;;<br><em>import</em> { newKitFromWeb3 } <em>from</em> &quot;@celo/contractkit&quot;;</pre><h3>Connect<a href="https://docs.celo.org/blog/2022/01/08/valora-wc-v1#connect">​</a></h3><p>If the DApp does not detect a <a href="https://docs.walletconnect.com/1.0/quick-start/dapps/web3-provider">wallet connect provider</a>, the user will be presented with a button to initiate a wallet connection.</p><p>If the DApp is being accessed on a computer or device other than the mobile device with the wallet, the user can connect to the mobile wallet by scanning the presented QR code. If the DApp is being accessed on the same device as the wallet, the connection will be made via the appropriate linking mechanism (iOS and Android are different). You can read more about that <a href="https://docs.walletconnect.com/1.0/mobile-linking#wallet-support">here</a>.</p><p>When a provider is detected, the DApp will show a button to send some cUSD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BNJPFnCGicN1yfVD.png" /></figure><p>The connect function sets up the WalletConnect Provider and initializes ContractKit with the provider and user account. It also sets up a listener that will log when the user changes accounts. The DApp then saves the provider and initialized Contractkit in the <a href="https://reactjs.org/docs/faq-state.html">React component state</a>.</p><pre>connect = <em>async</em> () =&gt; {<br>  <em>const</em> provider = <em>new</em> WalletConnectProvider({<br>    rpc: {<br>      44787: &quot;https://alfajores-forno.celo-testnet.org&quot;,<br>      42220: &quot;https://forno.celo.org&quot;,<br>    },<br>  });</pre><pre>  <em>await</em> provider.enable();<br>  <em>const</em> web3 = <em>new</em> Web3(provider);<br>  <em>let</em> kit = newKitFromWeb3(web3);</pre><pre>  kit.defaultAccount = provider.accounts[0];</pre><pre>  provider.on(&quot;accountsChanged&quot;, (accounts) =&gt; {<br>    console.log(accounts);<br>  });</pre><pre>  <em>this</em>.setState({ provider, kit });<br>};</pre><p>DApp:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nC1qn-V_Nca6ZmZh.png" /></figure><p>Valora:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BNOw029qnmD4vX5y.jpg" /></figure><p>When the provider has been set and the DApp is connected to Valora, the UI will update the button and display the user account address below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BlaR6pwnRf2IYiWo.png" /></figure><h3>Send cUSD<a href="https://docs.celo.org/blog/2022/01/08/valora-wc-v1#send-cusd">​</a></h3><p>Clicking the new button will prompt the user to send 0.001 cUSD to a hard-coded address. The user will have to click Allow to send the transaction. Once the transaction is confirmed, the transaction receipt will be printed in the DApp browser console.</p><p>You can code the transaction approval request with just a few lines, demonstrated in the sendcUSD function.</p><ul><li>Get the saved instance of ContractKit from this.state.kit</li><li>Get the stabletoken (cUSD) contract</li><li>Call transfer and send with the recipient and amount</li></ul><pre>sendcUSD = <em>async</em> () =&gt; {<br>  <em>let</em> kit = <em>this</em>.state.kit;</pre><pre>  <em>let</em> amount = kit.web3.utils.toWei(&quot;0.001&quot;, &quot;ether&quot;);</pre><pre>  <em>const</em> stabletoken = <em>await</em> kit.contracts.getStableToken();<br>  <em>const</em> tx = <em>await</em> stabletoken.transfer(<em>this</em>.state.someAddress, amount).send();<br>  <em>const</em> receipt = <em>await</em> tx.waitReceipt();</pre><pre>  console.log(receipt);<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rbbuFxXHQHcDY4fB.jpg" /></figure><p>The receipt will be logged once the user approves the transaction and it is confirmed on the network.</p><h3>Pay Fees in Stable currencies<a href="https://docs.celo.org/blog/2022/01/08/valora-wc-v1#pay-fees-in-stable-currencies">​</a></h3><p>Specifying the feeCurrency field in the transaction will allow users to pay transaction fees in that currency. Here&#39;s how you can have users pay transaction fees in cUSD, for example:</p><pre><em>const</em> stabletoken = <em>await</em> kit.contracts.getStableToken();<br><em>let</em> tx = <em>await</em> stabletoken<br>  .transfer(<em>this</em>.state.someAddress, amount)<br>  .send({ feeCurrency: stabletoken.address });</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fc105455779" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessing Randomness in Celo Smart Contracts]]></title>
            <link>https://medium.com/@joshc_/accessing-randomness-in-celo-smart-contracts-c01c4e324a82?source=rss-7770a3d83e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c01c4e324a82</guid>
            <category><![CDATA[randomness]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[celos]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[josh]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 17:44:39 GMT</pubDate>
            <atom:updated>2022-05-02T16:30:39.994Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to query randomness from Celo’s Random.sol protocol contract.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foVecqNLyNquNiNIYJTKsQ.png" /></figure><p>Accessing random numbers in a deterministic computing environment (like the EVM) is a difficult challenge. Fortunately the Celo blockchain includes a source of randomness in a protocol smart contract that is available to application developers.</p><p>On-chain randomness is used for selecting validators to perform phone number verification. Read more about how on-chain randomness is produced at the provided page.</p><p><a href="https://docs.celo.org/celo-codebase/protocol/identity/randomness">Celo Randomness | Celo Docs</a></p><p>This randomness can be used by any smart contracts deployed to a Celo network.</p><p>You can query randomness from the Random.sol contract by getting the contract from the Celo protocol contract registry, or through inheritance of UsingRegistry.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bf223f744470f77318857c9d2b7f947/href">https://medium.com/media/0bf223f744470f77318857c9d2b7f947/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c01c4e324a82" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>