Nanoswap Business Logic


pip install bizlogic


Here is the overall workflow. Note, this isn't how end users will actually interact with the platform. This will need to be deployed to a webserver with a UI for users to access. The private webserver deployment removes fraud opportunities. At time of writing there isn't functionality to create a sharable link to have someone you know "vouch" you - the names are just to make the workflow easier to understand.

Parameters and terminology:

  • Adam needs money, he is the "borrower"

  • Eugene is Adam's dad, and will cosign his application.

  • A "vouch" is a way to publicly approve of someone else's credit activity.

  • Eugene is the "voucher"

  • Adam is the "vouchee"

  • Sarah is Adam's rich Aunt, who will fund his loan. She is the "lender"


  1. Adam creates a loan application.
    from ipfsclient.ipfs import Ipfs
    from bizlogic.application import LoanApplicationWriter

    ipfsclient = Ipfs()
    amount_asking = 1000  # in raw XNO

    # Create a loan application and write the data to IPFS
    writer = LoanApplicationWriter(ipfsclient, <borrower_id>, amount_asking)
  1. Eugene vouches Adam
    from ipfsclient.ipfs import Ipfs
    from bizlogic.vouch import VouchWriter

    ipfsclient = Ipfs()

    # Create a vouch and write the data to IPFS
    writer = VouchWriter(ipfsclient, <voucher_id>, <vouchee_id>)
  1. Sarah searches for the loan application and vouches. Bizlogic does not cover credit checks, that will be a separate package.
    from ipfsclient.ipfs import Ipfs
    from bizlogic.application import LoanApplicationReader
    from bizlogic.vouch import VouchReader

    ipfsclient = Ipfs()

    # search for applications (Adam's request for 1000 raw XNO)
    reader = LoanApplicationReader(ipfsclient)
    applications = reader.get_open_loan_applications()

    # parse borrower from applications

    # search for vouchees (Eugene's id will be in the response data)
    reader = VouchReader(ipfsclient)
    vouchees = reader.get_vouchees_for_borrower(<borrower_id>)

    # search for vouchers (the people Adam vouched for)
    vouchers = reader.get_vouchers_for_borrower(<borrower_id>)
  1. Sarah creates a loan offer for Adam.
    from ipfsclient.ipfs import Ipfs
    from import LoanWriter
    from import PaymentSchedule
    import datetime

    ipfsclient = Ipfs()
    expiry = + datetime.timedelta(days=30)
    repayment_schedule = PaymentSchedule.create_payment_schedule(
        amount=1000,  # in raw XNO
        interest_rate=1.05,  # 5%

    # Create the loan offer and write it to IPFS
    writer = LoanWriter(
        expiry  # the time the borrower has to accept the offer
  1. Adam views his loan offers and accepts the offer.
    from ipfsclient.ipfs import Ipfs
    from import LoanReader

    ipfsclient = Ipfs()

    # List open loan offers
    reader = LoanReader(ipfsclient)
    offers = reader.get_open_loan_offers(<borrower_id>)

    # Parse the loan_data and loan_id from the offers result
    loan_data = ...
    loan_id = ...

    # Accept the offer they select
    writer = LoanWriter.from_data(ipfsclient, loan_data)
  1. Adam gets his active loans and makes a payment
    from ipfsclient.ipfs import Ipfs
    from import LoanReader
    from import LoanWriter

    ipfsclient = Ipfs()

    # read loans
    reader = LoanReader()
    loans = reader.query_for_borrower(<borrower_id>)

    # make the XNO payment
    transaction_id = ...

    # register the payment
    writer = LoanWriter()