Skip to content

Instantly share code, notes, and snippets.

View kermankohli's full-sized avatar
✌️

Kerman kermankohli

✌️
View GitHub Profile
@kermankohli
kermankohli / defi_guide.md
Last active October 18, 2020 09:17
Getting Started DeFi Guide

1. Understanding Blockchains

These are core concepts in understanding what a basic blockcahin is and how it works. Without this knowledge you'll struggle.

My goal is to keep this list as short as possible so making sure you go through each resource is pretty important.

Keybase proof

I hereby claim:

  • I am kermankohli on github.
  • I am kermankohli (https://keybase.io/kermankohli) on keybase.
  • I have a public key ASBNO9gp38nIFOAkuOosZzc-ujb-2DRimBkZiMAUrW884go

To claim this, I am signing this object:

@kermankohli
kermankohli / typed_params.mustache
Created October 28, 2018 07:07
Partials - Typed Params
{{#each inputs}}
{{name}}: {{#parameterType type components}}{{/parameterType}},
{{/each}}
@kermankohli
kermankohli / tx.mustache
Created October 28, 2018 07:06
Partials - tx
public {{this.name}} = {
async sendTransactionAsync(
{{> typed_params inputs=inputs}}
{{#this.payable}}
txData: TxDataPayable = {},
{{/this.payable}}
{{^this.payable}}
txData: TxData = {},
{{/this.payable}}
): Promise<string> {
@kermankohli
kermankohli / return_type.mustache
Created October 28, 2018 07:05
Partials - Return Types
{{#hasReturnValue}}
{{#singleReturnValue}}
{{#returnType outputs.0.type components}}{{/returnType}}
{{/singleReturnValue}}
{{^singleReturnValue}}
[{{#each outputs}}{{#returnType type components}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}]
{{/singleReturnValue}}
{{/hasReturnValue}}
{{^hasReturnValue}}
void
@kermankohli
kermankohli / params.mustache
Created October 28, 2018 07:04
Partials - Params
{{#each inputs}}
{{name}},
{{/each}}
@kermankohli
kermankohli / call.mustache
Created October 28, 2018 07:03
Partials - call
public {{this.name}} = {
async callAsync(
{{> typed_params inputs=inputs}}
defaultBlock?: any,
): Promise<{{> return_type outputs=outputs}}> {
const self = this as {{contractName}}Contract;
const result = await promisify<{{> return_type outputs=outputs}}>(
self.web3ContractInstance.{{this.name}}.call,
self.web3ContractInstance,
)(
@kermankohli
kermankohli / index.ts
Created October 28, 2018 06:57
Base Contract Src
import * as _ from "lodash";
import * as Web3 from "web3";
import { BigNumber } from "bignumber.js";
import { TxData, TxDataPayable } from '@your-project/types';
export const CONTRACT_WRAPPER_ERRORS = {
CONTRACT_NOT_FOUND_ON_NETWORK: (contractName: string, networkId: number) =>
`Unable to find address for contract ${contractName} on network with id ${networkId}`,
@kermankohli
kermankohli / package.json
Created October 28, 2018 06:55
Base Contract Package JSON
{
"name": "@your-project/base-contract",
"version": "0.2.0",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"clean": "rimraf rm -rf dist",
"build": "npm run clean && tsc"
@kermankohli
kermankohli / tsconfig.json
Created October 28, 2018 06:51
Base Contract TSConfig
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": ["dom", "es2015", "es2016", "es2017"],
"sourceMap": true,
"declaration": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"noImplicitReturns": true,