Skip to content

Instantly share code, notes, and snippets.

View critesjosh's full-sized avatar
🥸

josh crites critesjosh

🥸
View GitHub Profile
// In this example, we will go over how to look up a Celo address that is registered with a phone number with ODIS
// 1. Import the appropriate packages
const ContractKit = require('@celo/contractkit')
const OdisUtils = require('@celo/identity').OdisUtils
const id = require('@celo/identity')
const Web3 = require('web3')
require('dotenv').config()
// 2. Import these packages to help with private key management for the example
@critesjosh
critesjosh / index.js
Created December 10, 2021 00:35
index.js file for the react app example in the celo docs here: https://docs.celo.org/developer-guide/start/web-dapp
import React, { useCallback, useEffect, useState } from 'react'
import { useContractKit } from '@celo-tools/use-contractkit';
import { ContractKitProvider } from '@celo-tools/use-contractkit';
import '@celo-tools/use-contractkit/lib/styles.css';
function App () {
const { address, connect } = useContractKit()
return (
<main>
@critesjosh
critesjosh / App.js
Last active November 12, 2021 20:35
sending tx with cEUR as feeCurrency, valora + wallet connect v1
import logo from './celoLogo.svg';
import './App.css';
import WalletConnectProvider from '@walletconnect/web3-provider';
import Web3 from 'web3';
import React from 'react';
import { newKitFromWeb3 } from '@celo/contractkit';
class App extends React.Component {
constructor(props){
// SPDX-License-Identifier: MIT
/**
*Submitted for verification at BscScan.com on 2021-05-29
*/
// File: @openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.0;
@critesjosh
critesjosh / contracts...MolochSummoner.sol
Last active October 14, 2021 20:37
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.3+commit.10d17f24.js&optimize=false&runs=200&gist=
pragma solidity 0.5.3;
pragma solidity 0.5.3;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
@critesjosh
critesjosh / contracts...artifacts...MolochSummoner_metadata.json
Created October 14, 2021 20:25
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
{
"compiler": {
"version": "0.5.3+commit.10d17f24"
},
"language": "Solidity",
"output": {
"abi": [
{
"constant": false,
"inputs": [
@critesjosh
critesjosh / sendcEUR.js
Created September 7, 2021 15:20
example tx to send cUSD using cEUR as tx fees.
const Web3 = require('web3')
const ContractKit = require('@celo/contractkit')
const web3 = new Web3(`https://celo-alfajores--rpc.datahub.figment.io/apikey/${process.env.FIGMENT_API_KEY}/`)
async function sendCELOTx(){
// Connect to the network and get the current tx count
let nonce = await kit.web3.eth.getTransactionCount(kit.defaultAccount)
// Send 0.1 CELO
@critesjosh
critesjosh / rename.sh
Created August 26, 2021 00:16
a script to modify typedoc output for docusaurus for the celo docs
#!/bin/bash
string="sdk-docs/contractkit/"
for f in docs/**/_*; do
newfile="$(echo ${f} | sed -e 's/\_//')";
line=$(head -n 1 $f);
title="$(echo ${line} | sed -e 's/.*://')";
echo -e "---\ntitle: ${title}\nslug: $string/${f}\n---\n\n$(cat $f)" > $f
mv $f $newfile;
@critesjosh
critesjosh / app.js
Created August 6, 2021 19:41
main file for a React / Magic example
import { StatusBar } from 'expo-status-bar';
import React, { useEffect, useState } from 'react';
import { StyleSheet, ScrollView, Text, View, TextInput, Pressable, Linking } from 'react-native';
import { magic, web3 } from './magic';
import { abi } from './contract/abi.js';
export default function App() {
// User
const [email, setEmail] = useState('');
const [user, setUser] = useState('');
@critesjosh
critesjosh / App.js
Created June 22, 2021 16:12
@celo/wallet-walletconnect create react app demo
import './App.css';
import React from "react";
import ReactDOM from "react-dom";
import { WalletConnectWallet } from '@celo/wallet-walletconnect'
import QRCode from 'qrcode.react'
class App extends React.Component {
constructor(props){
super(props)