Skip to content

Instantly share code, notes, and snippets.

pragma solidity >=0.5.0 <0.7.0;
// In remix you can import from github
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/GSN/GSNRecipient.sol";
// I think in other deployments you'll need to import this way
// import "@openzeppelin/contracts-ethereum-package/contracts/GSN/GSNRecipient.sol";
contract CashPoints is GSNRecipient {
uint public Count;
@jsaur
jsaur / CreditRegistry.sol
Last active October 22, 2019 13:35
This is a simple version of the credit registry. You can test it in http://remix.ethereum.org.
pragma solidity ^0.5.11;
/*
* Note that Solidity can't return an array of strings :(
* https://solidity.readthedocs.io/en/v0.4.21/frequently-asked-questions.html#is-it-possible-to-return-an-array-of-strings-string-from-a-solidity-function
* So rather than allow arbitrary lengthed strings for DIDs and hashes we use a fixed size bytes32. This is the largest native bype size in solidity
* so if we find that we need more, we will have to come up with another solution.
* Another option if we wanted to support strings would be to use ABIEncoderV2, however if we can guaruntee fixed lengths it will be more performant
*/
contract CreditRegistry {
@jsaur
jsaur / API Loans Fetch Endpoint
Last active May 15, 2018 17:12
Example JSON data for the Partner API loan fetch endpoint
GET https://api.dev.kivaws.org/v3/partner/123/loans?status=inactive&limit=50
Authorization header: "xxx_partner_token_xxx"
OR
GET https://api.dev.kivaws.org/v3/partner/123/loans?query=123_MIS_loan_id
Response:
{
"total_records":1,
"data":{
"12345":{
@jsaur
jsaur / Partner API Journal JSON
Created February 2, 2018 19:13
Example JSON data for the Partner API journal endpoint
POST https://api.dev.kivaws.org/v3/partner/123/journals
{
"partner_token":"xxx",
"journals": [
{
"internal_loan_id": "loan_123",
"internal_client_id": "client_123(optional)",
"subject":"Journal subject 1",
"body": "Journal body 1 with some interesting content",
"image_url": "https://site.com/image1.jpg"
@jsaur
jsaur / Partner API Group Loan Draft JSON
Last active April 2, 2018 22:28
Example JSON data for the Partner API loan draft endpoint for a group loan
POST https://api.dev.kivaws.org/v3/partner/123/loan_draft
{
"partner_token": "xxx",
"description_language_id":1,
"theme_type_id":"227",
"activity_id":"56",
"location":"Dahod: India",
"rep_person_id":"1234",
"internal_client_id":"group_client_123",
"internal_loan_id":"group_loan_123",
@jsaur
jsaur / Partner API Individual Loan Draft JSON
Last active April 2, 2018 22:28
Example JSON data for the Partner API loan draft endpoint for an individual loan
POST https://api.dev.kivaws.org/v3/partner/123/loan_draft
{
"partner_token": "xxxx",
"description_language_id":1,
"activity_id":"56",
"theme_type_id":"227",
"location":"Dahod: India",
"rep_person_id":"1234",
"client_waiver_signed":true,
"loanuse":"Loan Use",
@jsaur
jsaur / Partner API Repayments JSON
Last active April 2, 2018 22:28
Example JSON data for the Partner API repayments endpoint
POST https://api.dev.kivaws.org/v3/partner/123/repayments
{
"partner_token":"xxxx",
"user_id":234,
"repayments":[
{
"loan_id":"1234",
"client_id":"abc(optional)",
"amount":33.33
},
{
"client_waiver_signed":true,
"internal_client_id":"group-client-1",
"internal_loan_id":"group-loan-1",
"group_name":"group-name",
"entreps":[
{
"first_name":"borrower-given-1",
"last_name":"borrower-family-1",
"gender":"male",
[
{
"loan_theme_instance_id": 991,
"pfp_min_lenders": 25,
"pfp_expiration_days": 15
},
{
"loan_theme_instance_id": 992,
"pfp_min_lenders": 85,
"pfp_expiration_days": 12
{
"theme_name":"General",
"description_language":"English",
"activity":"Rickshaw",
"location":"Ali Pur Chatta: Pakistan",
"loan_representative":"Jim Jones",
"image_url":"dropbox.come/image/1234.jpg",
"client_waiver_signed":true,
"loanuse":"Some loan use",