Skip to content

Instantly share code, notes, and snippets.

critesjosh / signTx.js
Created Apr 2, 2021
an example script to show how to sign a Celo transaction
View signTx.js
const Web3 = require("web3")
const ContractKit = require('@celo/contractkit')
const web3 = new Web3('')
const kit = ContractKit.newKitFromWeb3(web3)
let anAddress = '0xD86518b29BB52a5DAC5991eACf09481CE4B0710d'
async function signTx(){
let goldtoken = await kit.contracts.getGoldToken()
critesjosh / EIP20Factory.sol
Created Feb 22, 2018
erc20 token factory
View EIP20Factory.sol
// Abstract contract for the full ERC 20 Token standard
pragma solidity ^0.4.18;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
critesjosh / BaseCaller.sol
Last active Mar 6, 2021
Inter-contract execution in Solidity
View BaseCaller.sol
pragma solidity ^0.5.0;
contract Base {
uint x;
constructor() public {
x = 10;
View api_response.json
// API call:
"status": "1",
"result": {
"value": "0",
"to": "0x6d67b41236129cb4f6ffaf6e37223485b20d1d06",
"timeStamp": "1610353070",
"success": true,
"next_page_params": null,
critesjosh / Splitter.sol
Last active Dec 7, 2020
A contract to split funds between addresses. Demostrates pushing vs pulling transfers
View Splitter.sol
pragma solidity ^0.4.6;
contract Splitter {
mapping(address => uint) public balances;
function unsafeSplit(address address1, address address2)
returns(bool success)
critesjosh / cUSD_abi.json
Last active Nov 20, 2020
An example script for watching for events emitted by a Celo contract via Forno
View cUSD_abi.json
critesjosh / lookup.js
Created Sep 28, 2020
A node script to run a phone number lookup with ODIS on the Celo blockchain
View lookup.js
// 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/contractkit').OdisUtils
const AuthSigner = require('@celo/contractkit/lib/identity/odis/query').AuthSigner
// 2. Import these packages to help with private key management for the example
const privateKeyToAddress = require('@celo/utils/lib/address').privateKeyToAddress
const normalizeAddressWith0x = require('@celo/utils/lib/address').normalizeAddressWith0x
critesjosh / CELOtransfer.js
Created Sep 21, 2020
Celo token native transfer and ERC20 transfer using contractkit
View CELOtransfer.js
// Import ContractKit
const ContractKit = require('@celo/contractkit')
// Create a new instance of ContractKit, connecting to a local Celo node
//const contractKit = ContractKit.newKit('http://localhost:8545')
const contractKit = ContractKit.newKit('')
// Specify an arbitrary recipient of the transaction
const recipient = '0xB9727f7f1e1f4a5229a49E260fBBBD410d10f2Ff'
const privateKey = '3a26ebc37944c305670a21ea6a5d16c1084db2f18bc6635ba95f487e5c59868f'
critesjosh / index.js
Last active May 6, 2020
This script is a demo of how to use the ContractKit to send a transaction on the Celo network (
View index.js
#!/usr/bin/env node
This script is a demo of how to use the ContractKit to send a transaction on the Celo network (
With npm installed, run this script with the command:
// Import ContractKit
const ContractKit = require('@celo/contractkit')
critesjosh / getInfo.js
Created Apr 9, 2020
A node.js script to print details about the Celo blockchain that is connected at http://localhost:8545
View getInfo.js
// Run this script in a npm project with contractkit installed
const Kit = require('@celo/contractkit')
const CeloContract = Kit.CeloContract
const kit = Kit.newKit('http://localhost:8545')
async function wrapper(){
let accounts = await kit.web3.eth.getAccounts()